Move private/upload-cdn into packages/uppy (#5800)

This commit is contained in:
Merlijn Vos 2025-07-07 10:58:53 +02:00 committed by GitHub
parent a848a4f695
commit 36097dc67e
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
6 changed files with 33 additions and 39 deletions

View file

@ -44,7 +44,7 @@ jobs:
node-version: lts/*
- name: Install upload-to-cdn dependencies
if: ${{ inputs.version }}
run: corepack yarn workspaces focus @uppy-dev/upload-to-cdn
run: corepack yarn workspaces focus uppy
env:
# https://docs.cypress.io/guides/references/advanced-installation#Skipping-installation
CYPRESS_INSTALL_BINARY: 0

View file

@ -50,7 +50,7 @@
"test:ts": "yarn tsc -b && yarn workspace @uppy/svelte check",
"test:unit": "yarn run build && yarn test:watch --run",
"test:watch": "vitest --environment jsdom --dir packages/@uppy",
"uploadcdn": "yarn node ./private/upload-to-cdn/index.js",
"uploadcdn": "yarn workspace uppy exec -- node upload-to-cdn.js",
"version": "yarn node ./bin/after-version-bump.js",
"watch": "npm-run-all --parallel watch:js:bundle watch:js:lib",
"watch:js:bundle": "onchange 'packages/{@uppy/,}*/src/**/*.{js,ts,jsx,tsx,svelte,scss,css}' --initial --verbose -- yarn run build:bundle",

View file

@ -75,8 +75,15 @@
"build:bundle": "node build-bundle.mjs"
},
"devDependencies": {
"@aws-sdk/client-s3": "^3.338.0",
"adm-zip": "^0.5.5",
"chalk": "^5.0.0",
"concat-stream": "^2.0.0",
"esbuild": "^0.25.0",
"mime-types": "^2.1.26",
"npm-packlist": "^5.0.0",
"pacote": "^13.0.0",
"tar": "^6.1.0",
"typescript": "^5.8.3"
}
}

View file

@ -88,8 +88,10 @@ async function getRemoteDistFiles(packageName, version) {
* @returns a Map<string, Buffer>, filename content
*/
async function getLocalDistFiles(packageName) {
// Base file path of the package, eg. ./packages/@uppy/locales
const packagePath = path.join(__dirname, '..', '..', 'packages', packageName)
// Base file path of the package, eg. ./packages/@uppy/locales or ./packages/uppy
const packagePath = packageName.startsWith('@uppy/')
? path.join(__dirname, '..', packageName)
: path.join(__dirname)
console.log('Making local package from', packagePath)
@ -132,7 +134,7 @@ async function main(packageName, version) {
// version should only be a positional arg and semver string
// this deals with usage like `npm run uploadcdn uppy -- --force`
// where we force push a local build
if (version?.startsWith('-')) version = undefined
let resolvedVersion = version?.startsWith('-') ? undefined : version
const s3Client = new S3Client({
credentials: {
@ -142,11 +144,16 @@ async function main(packageName, version) {
region: AWS_REGION,
})
const remote = !!version
const remote = !!resolvedVersion
console.log('Using', remote ? 'Remote' : 'Local', 'build')
if (!remote) {
version = require(`../../packages/${packageName}/package.json`).version
// Updated path logic: now running from packages/uppy, need to reference the package directly
const packagePath = packageName.startsWith('@uppy/')
? path.join(__dirname, '..', packageName)
: path.join(__dirname)
resolvedVersion = require(path.join(packagePath, 'package.json')).version
}
// Warn if uploading a local build not from CI:
@ -166,7 +173,7 @@ async function main(packageName, version) {
? packageName.replace(/^@/, '')
: 'uppy'
const s3Dir = path.posix.join(dirName, `v${version}`)
const s3Dir = path.posix.join(dirName, `v${resolvedVersion}`)
const { Contents: existing } = await s3Client.send(
new ListObjectsV2Command({
@ -178,18 +185,18 @@ async function main(packageName, version) {
if (existing?.length > 0) {
if (process.argv.includes('--force')) {
console.warn(
`WARN Release files for ${dirName} v${version} already exist, overwriting...`,
`WARN Release files for ${dirName} v${resolvedVersion} already exist, overwriting...`,
)
} else {
console.error(
`Release files for ${dirName} v${version} already exist, exiting...`,
`Release files for ${dirName} v${resolvedVersion} already exist, exiting...`,
)
process.exit(1)
}
}
const files = remote
? await getRemoteDistFiles(packageName, version)
? await getRemoteDistFiles(packageName, resolvedVersion)
: await getLocalDistFiles(packageName)
if (packageName === 'uppy') {
@ -200,7 +207,7 @@ async function main(packageName, version) {
zip.addFile(filename, buffer)
}
files.set(`uppy-v${version}.zip`, zip.toBuffer())
files.set(`uppy-v${resolvedVersion}.zip`, zip.toBuffer())
}
if (files.size === 0) console.warn('No files to upload')

View file

@ -1,13 +0,0 @@
{
"name": "@uppy-dev/upload-to-cdn",
"private": true,
"devDependencies": {
"@aws-sdk/client-s3": "^3.338.0",
"adm-zip": "^0.5.5",
"concat-stream": "^2.0.0",
"mime-types": "^2.1.26",
"npm-packlist": "^5.0.0",
"pacote": "^13.0.0",
"tar": "^6.1.0"
}
}

View file

@ -11104,20 +11104,6 @@ __metadata:
languageName: unknown
linkType: soft
"@uppy-dev/upload-to-cdn@workspace:private/upload-to-cdn":
version: 0.0.0-use.local
resolution: "@uppy-dev/upload-to-cdn@workspace:private/upload-to-cdn"
dependencies:
"@aws-sdk/client-s3": "npm:^3.338.0"
adm-zip: "npm:^0.5.5"
concat-stream: "npm:^2.0.0"
mime-types: "npm:^2.1.26"
npm-packlist: "npm:^5.0.0"
pacote: "npm:^13.0.0"
tar: "npm:^6.1.0"
languageName: unknown
linkType: soft
"@uppy-example/angular@workspace:examples/angular-example":
version: 0.0.0-use.local
resolution: "@uppy-example/angular@workspace:examples/angular-example"
@ -31362,6 +31348,7 @@ __metadata:
version: 0.0.0-use.local
resolution: "uppy@workspace:packages/uppy"
dependencies:
"@aws-sdk/client-s3": "npm:^3.338.0"
"@uppy/audio": "workspace:^"
"@uppy/aws-s3": "workspace:^"
"@uppy/box": "workspace:^"
@ -31400,8 +31387,14 @@ __metadata:
"@uppy/webdav": "workspace:^"
"@uppy/xhr-upload": "workspace:^"
"@uppy/zoom": "workspace:^"
adm-zip: "npm:^0.5.5"
chalk: "npm:^5.0.0"
concat-stream: "npm:^2.0.0"
esbuild: "npm:^0.25.0"
mime-types: "npm:^2.1.26"
npm-packlist: "npm:^5.0.0"
pacote: "npm:^13.0.0"
tar: "npm:^6.1.0"
typescript: "npm:^5.8.3"
languageName: unknown
linkType: soft