diff --git a/docs/src/components/homepage/homepage-code-embed/package.json b/docs/src/components/homepage/homepage-code-embed/package.json index 36a9a442b..607c0d562 100644 --- a/docs/src/components/homepage/homepage-code-embed/package.json +++ b/docs/src/components/homepage/homepage-code-embed/package.json @@ -12,7 +12,7 @@ "@tensorflow/tfjs": "~4.8.0", "@upscalerjs/esrgan-thick": "latest", "seedrandom": "^3.0.5", - "upscaler": "workspace:1.0.0-beta.17" + "upscaler": "workspace:*" }, "engines": { "npm": ">8.0.0" diff --git a/examples/basic-npm/package.json b/examples/basic-npm/package.json index 874fd9d18..d1a411f74 100644 --- a/examples/basic-npm/package.json +++ b/examples/basic-npm/package.json @@ -19,7 +19,7 @@ "dependencies": { "@tensorflow/tfjs": "~4.8.0", "seedrandom": "^3.0.5", - "upscaler": "1.0.0-beta.14" + "upscaler": "latest" }, "engines": { "npm": ">8.0.0" diff --git a/examples/basic-umd/package.json b/examples/basic-umd/package.json index 1382f7fd8..031032c1b 100644 --- a/examples/basic-umd/package.json +++ b/examples/basic-umd/package.json @@ -9,10 +9,6 @@ }, "author": "Kevin Scott", "license": "MIT", - "dependencies": { - "seedrandom": "^3.0.5", - "upscaler": "1.0.0-beta.14" - }, "engines": { "npm": ">8.0.0" }, diff --git a/examples/cancel/package.json b/examples/cancel/package.json index 961117e4f..673c64c3c 100644 --- a/examples/cancel/package.json +++ b/examples/cancel/package.json @@ -12,7 +12,7 @@ "dependencies": { "@tensorflow/tfjs": "~4.8.0", "seedrandom": "^3.0.5", - "upscaler": "1.0.0-beta.14" + "upscaler": "latest" }, "engines": { "npm": ">8.0.0" diff --git a/examples/cloudflare-worker/package.json b/examples/cloudflare-worker/package.json index 9ffc52584..7e1da1a77 100644 --- a/examples/cloudflare-worker/package.json +++ b/examples/cloudflare-worker/package.json @@ -23,7 +23,7 @@ "jpeg-js": "^0.4.4", "mock-aws-s3": "^4.0.2", "nock": "^13.3.2", - "upscaler": "1.0.0-beta.14" + "upscaler": "latest" }, "engines": { "npm": ">8.0.0" diff --git a/examples/custom-model-configurations/package.json b/examples/custom-model-configurations/package.json index 2c915b899..74e26b34a 100644 --- a/examples/custom-model-configurations/package.json +++ b/examples/custom-model-configurations/package.json @@ -12,7 +12,7 @@ "dependencies": { "@tensorflow/tfjs": "~4.8.0", "seedrandom": "^3.0.5", - "upscaler": "1.0.0-beta.14" + "upscaler": "latest" }, "engines": { "npm": ">8.0.0" diff --git a/examples/electron/package.json b/examples/electron/package.json index 97b76eed7..c5f3f62b6 100644 --- a/examples/electron/package.json +++ b/examples/electron/package.json @@ -23,7 +23,7 @@ "@tensorflow/tfjs": "^4.8.0", "esbuild": "^0.18.20", "seedrandom": "^3.0.5", - "upscaler": "1.0.0-beta.17" + "upscaler": "latest" }, "engines": { "npm": ">8.0.0" diff --git a/examples/memory-management/package.json b/examples/memory-management/package.json index 65b558e73..d251bd56a 100644 --- a/examples/memory-management/package.json +++ b/examples/memory-management/package.json @@ -12,7 +12,7 @@ "dependencies": { "@tensorflow/tfjs": "~4.8.0", "seedrandom": "^3.0.5", - "upscaler": "1.0.0-beta.14" + "upscaler": "latest" }, "engines": { "npm": ">8.0.0" diff --git a/examples/models/package.json b/examples/models/package.json index cb7c76110..578a434bd 100644 --- a/examples/models/package.json +++ b/examples/models/package.json @@ -13,7 +13,7 @@ "@tensorflow/tfjs": "~4.8.0", "@upscalerjs/esrgan-thick": "1.0.0-beta.8", "seedrandom": "^3.0.5", - "upscaler": "1.0.0-beta.14" + "upscaler": "latest" }, "engines": { "npm": ">8.0.0" diff --git a/examples/nodejs-custom-file-path/package.json b/examples/nodejs-custom-file-path/package.json index a8d337a64..68f4bd874 100644 --- a/examples/nodejs-custom-file-path/package.json +++ b/examples/nodejs-custom-file-path/package.json @@ -16,7 +16,7 @@ "@tensorflow/tfjs-node": "~4.8.0", "express": "4.18.2", "seedrandom": "3.0.5", - "upscaler": "1.0.0-beta.14" + "upscaler": "latest" }, "@upscalerjs": { "guide": { diff --git a/examples/nodejs-model/package.json b/examples/nodejs-model/package.json index 9b4a96cef..3edde8d50 100644 --- a/examples/nodejs-model/package.json +++ b/examples/nodejs-model/package.json @@ -15,7 +15,7 @@ "@upscalerjs/esrgan-thick": "1.0.0-beta.11", "express": "4.18.2", "seedrandom": "3.0.5", - "upscaler": "1.0.0-beta.14" + "upscaler": "latest" }, "@upscalerjs": { "guide": { diff --git a/examples/nodejs/package.json b/examples/nodejs/package.json index 19bfa7e83..bcdbd8bf2 100644 --- a/examples/nodejs/package.json +++ b/examples/nodejs/package.json @@ -16,7 +16,7 @@ "@tensorflow/tfjs-node": "~4.8.0", "express": "4.16.4", "seedrandom": "3.0.5", - "upscaler": "1.0.0-beta.14" + "upscaler": "latest" }, "@upscalerjs": { "guide": { diff --git a/examples/patch-sizes/package.json b/examples/patch-sizes/package.json index c626d2947..bebf66393 100644 --- a/examples/patch-sizes/package.json +++ b/examples/patch-sizes/package.json @@ -15,7 +15,7 @@ "dependencies": { "@tensorflow/tfjs": "~4.8.0", "seedrandom": "^3.0.5", - "upscaler": "1.0.0-beta.14" + "upscaler": "latest" }, "engines": { "npm": ">8.0.0" diff --git a/examples/progress/package.json b/examples/progress/package.json index c82a2d269..ec6a325d0 100644 --- a/examples/progress/package.json +++ b/examples/progress/package.json @@ -15,7 +15,7 @@ "dependencies": { "@tensorflow/tfjs": "~4.8.0", "seedrandom": "^3.0.5", - "upscaler": "1.0.0-beta.14" + "upscaler": "latest" }, "@upscalerjs": { "guide": { diff --git a/examples/react/package.json b/examples/react/package.json index 3580bbbd3..388a7e571 100644 --- a/examples/react/package.json +++ b/examples/react/package.json @@ -13,7 +13,7 @@ "react-scripts": "5.0.0", "seedrandom": "^3.0.5", "typescript": "^5.1.6", - "upscaler": "1.0.0-beta.14" + "upscaler": "latest" }, "scripts": { "dev": "react-scripts start" diff --git a/examples/self-hosting-models/package.json b/examples/self-hosting-models/package.json index 37d94687d..608dd9c5b 100644 --- a/examples/self-hosting-models/package.json +++ b/examples/self-hosting-models/package.json @@ -12,7 +12,7 @@ "dependencies": { "@tensorflow/tfjs": "~4.8.0", "seedrandom": "^3.0.5", - "upscaler": "1.0.0-beta.14" + "upscaler": "latest" }, "engines": { "npm": ">8.0.0" diff --git a/examples/tensors/package.json b/examples/tensors/package.json index 7ce128c5d..e5f28e65b 100644 --- a/examples/tensors/package.json +++ b/examples/tensors/package.json @@ -12,7 +12,7 @@ "dependencies": { "@tensorflow/tfjs": "~4.8.0", "seedrandom": "^3.0.5", - "upscaler": "1.0.0-beta.14" + "upscaler": "latest" }, "@upscalerjs": { "guide": { diff --git a/examples/upload/package.json b/examples/upload/package.json index e81fc8433..61329d6a0 100644 --- a/examples/upload/package.json +++ b/examples/upload/package.json @@ -15,7 +15,7 @@ "dependencies": { "@tensorflow/tfjs": "~4.8.0", "seedrandom": "^3.0.5", - "upscaler": "1.0.0-beta.14" + "upscaler": "latest" }, "@upscalerjs": { "guide": { diff --git a/examples/warmup/package.json b/examples/warmup/package.json index 0384a772a..67587b934 100644 --- a/examples/warmup/package.json +++ b/examples/warmup/package.json @@ -15,7 +15,7 @@ "dependencies": { "@tensorflow/tfjs": "~4.8.0", "seedrandom": "^3.0.5", - "upscaler": "1.0.0-beta.14" + "upscaler": "latest" }, "@upscalerjs": { "guide": { diff --git a/examples/webcam/package.json b/examples/webcam/package.json index a485afab3..745e6b1b4 100644 --- a/examples/webcam/package.json +++ b/examples/webcam/package.json @@ -14,7 +14,7 @@ "dependencies": { "@tensorflow/tfjs": "~4.8.0", "seedrandom": "^3.0.5", - "upscaler": "1.0.0-beta.14" + "upscaler": "latest" }, "@upscalerjs": { "guide": { diff --git a/examples/webworker/package.json b/examples/webworker/package.json index 3b39e6f98..ff15d547e 100644 --- a/examples/webworker/package.json +++ b/examples/webworker/package.json @@ -15,7 +15,7 @@ "dependencies": { "@tensorflow/tfjs": "~4.8.0", "seedrandom": "^3.0.5", - "upscaler": "1.0.0-beta.14" + "upscaler": "latest" }, "engines": { "npm": ">8.0.0" diff --git a/models/default-model/demo/package.json b/models/default-model/demo/package.json index e47b745ac..e52d89eeb 100644 --- a/models/default-model/demo/package.json +++ b/models/default-model/demo/package.json @@ -15,7 +15,7 @@ "@tensorflow/tfjs": "~4.8.0", "@upscalerjs/default-model": "1.0.0-beta.7", "seedrandom": "^3.0.5", - "upscaler": "1.0.0-beta.8" + "upscaler": "1.0.0-beta.18" }, "engines": { "npm": ">8.0.0" diff --git a/models/esrgan-legacy/demo/package.json b/models/esrgan-legacy/demo/package.json index 5c357ab0c..9873b6a96 100755 --- a/models/esrgan-legacy/demo/package.json +++ b/models/esrgan-legacy/demo/package.json @@ -15,7 +15,7 @@ "@tensorflow/tfjs": "~4.8.0", "@upscalerjs/esrgan-legacy": "1.0.0-beta.9", "seedrandom": "^3.0.5", - "upscaler": "1.0.0-beta.8" + "upscaler": "1.0.0-beta.18" }, "engines": { "npm": ">8.0.0" diff --git a/models/esrgan-medium/demo/package.json b/models/esrgan-medium/demo/package.json index 31a1a8576..c3981a105 100644 --- a/models/esrgan-medium/demo/package.json +++ b/models/esrgan-medium/demo/package.json @@ -15,7 +15,7 @@ "@tensorflow/tfjs": "~4.8.0", "@upscalerjs/esrgan-medium": "1.0.0-beta.7", "seedrandom": "^3.0.5", - "upscaler": "1.0.0-beta.8" + "upscaler": "1.0.0-beta.18" }, "engines": { "npm": ">8.0.0" diff --git a/models/esrgan-slim/demo/package.json b/models/esrgan-slim/demo/package.json index 144254873..3bfb47ef1 100644 --- a/models/esrgan-slim/demo/package.json +++ b/models/esrgan-slim/demo/package.json @@ -15,7 +15,7 @@ "@tensorflow/tfjs": "~4.8.0", "@upscalerjs/esrgan-slim": "1.0.0-beta.7", "seedrandom": "^3.0.5", - "upscaler": "1.0.0-beta.8" + "upscaler": "1.0.0-beta.18" }, "engines": { "npm": ">8.0.0" diff --git a/models/esrgan-thick/demo/package.json b/models/esrgan-thick/demo/package.json index 7ca7248bf..fc8e3deed 100644 --- a/models/esrgan-thick/demo/package.json +++ b/models/esrgan-thick/demo/package.json @@ -15,7 +15,7 @@ "@tensorflow/tfjs": "~4.8.0", "@upscalerjs/esrgan-thick": "1.0.0-beta.7", "seedrandom": "^3.0.5", - "upscaler": "1.0.0-beta.8" + "upscaler": "1.0.0-beta.18" }, "engines": { "npm": ">8.0.0" diff --git a/package.json b/package.json index 9a259e527..3f93dc02f 100644 --- a/package.json +++ b/package.json @@ -214,7 +214,11 @@ "command": "git add packages/upscalerjs/src/shared/constants.ts *examples/*/package.json* && git commit -m \"Updating CDN && example versions\" --no-verify" }, "example:start": { - "command": "pnpm --filter @upscalerjs/scripts example:start" + "command": "pnpm --filter @upscalerjs/scripts example:start", + "dependencies": [ + "./internals/common:build", + "./packages/upscalerjs:build" + ] }, "lint": { "command": "pnpm --parallel --filter=!./models/**/dist/** lint" diff --git a/packages/upscalerjs-wrapper/package.json b/packages/upscalerjs-wrapper/package.json index 133700fdb..59ebf3e5c 100644 --- a/packages/upscalerjs-wrapper/package.json +++ b/packages/upscalerjs-wrapper/package.json @@ -4,7 +4,7 @@ "description": "Wrapper for UpscalerJS", "main": "index.js", "dependencies": { - "upscaler": "workspace:1.0.0-beta.17" + "upscaler": "workspace:*" }, "author": "", "license": "MIT" diff --git a/packages/upscalerjs/package.json b/packages/upscalerjs/package.json index c4b020df5..096b0530a 100644 --- a/packages/upscalerjs/package.json +++ b/packages/upscalerjs/package.json @@ -1,6 +1,6 @@ { "name": "upscaler", - "version": "1.0.0-beta.17", + "version": "1.0.0-beta.18", "description": "Enhance Images with Javascript and AI. Increase resolution, retouch, denoise, and more. Open Source, Browser and Node Compatible, MIT License.", "exports": { "./node": { @@ -175,6 +175,9 @@ "lint": { "command": "eslint -c .eslintrc.js src --ext .ts" }, + "test": { + "command": "pnpm test:unit:browser:playwright && pnpm test:unit:browser:vite -- --run && pnpm test:unit:node -- --run" + }, "test:unit:browser:playwright": { "command": "playwright-test --config playwright.config.json" }, @@ -203,8 +206,7 @@ "prepublishOnly": "wireit", "format": "wireit", "lint": "wireit", - "lint:browser": "wireit", - "lint:node": "wireit", + "test": "wireit", "test:unit:browser:playwright": "wireit", "test:unit:browser:vite": "wireit", "test:unit:node": "wireit", diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index ec3c1a3d9..8f2dc52db 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -485,7 +485,7 @@ importers: specifier: ^3.0.5 version: 3.0.5 upscaler: - specifier: workspace:1.0.0-beta.17 + specifier: workspace:* version: link:../../../../../packages/upscalerjs docs/workers/image-search: @@ -908,7 +908,7 @@ importers: packages/upscalerjs-wrapper: dependencies: upscaler: - specifier: workspace:1.0.0-beta.17 + specifier: workspace:* version: link:../upscalerjs scripts: diff --git a/scripts/start-example.ts b/scripts/start-example.ts index b621bb4d5..63e6836cd 100644 --- a/scripts/start-example.ts +++ b/scripts/start-example.ts @@ -7,53 +7,47 @@ import path from 'path'; import { spawn } from 'child_process'; import yargs from 'yargs'; import { getString } from './package-scripts/prompt/getString'; -import { runPNPMScript } from '@internals/common'; import { Platform } from './package-scripts/prompt/types'; import { EXAMPLES_DIR } from './package-scripts/utils/constants'; /**** * Utility functions */ -const getPlatform = (packageJSON: Record): Platform => { - const deps = Object.keys(packageJSON.dependencies); - if (deps.includes('@tensorflow/tfjs')) { - return 'browser'; - } else if (deps.includes('@tensorflow/tfjs-node')) { - return 'node'; - } else if (deps.includes('@tensorflow/tfjs-node-gpu')) { - return 'node-gpu'; +const parseCommand = (_command: string | string[]) => { + const command = Array.isArray(_command) ? _command : _command.split(' '); + if (command[0] === 'npm' || command[0] === 'pnpm') { + return command.slice(1); } - - throw new Error('Could not determine valid TFJS dependency in example package.json') + return command; }; -const getExampleInfo = (examplePath: string) => { - const packageJSON = JSON.parse(fs.readFileSync(path.resolve(examplePath, 'package.json'), 'utf8')); - const exampleName = packageJSON.name; - const platform = getPlatform(packageJSON); +export const runPNPMScript = ( + command: string | string[], + cwd: string, + runner: 'npm' | 'pnpm' = 'npm', +) => new Promise((resolve, reject) => { + const child = spawn(runner, parseCommand(command), { + shell: true, + cwd, + stdio: "inherit" + }); - return { - exampleName, - platform, - }; -} + child.on('error', reject); + + child.on('close', (code) => { + if (code === 0) { + resolve(); + } else { + reject(code); + } + }); +}); /**** * Main function */ -const getProcessCommand = (platform: Platform, exampleName: string, skipUpscalerBuild?: boolean) => { - const startCommand = ['pnpm', '--filter', exampleName, 'start'] - if (skipUpscalerBuild) { - return startCommand; - } - return [ - 'pnpm', '--filter', 'upscaler', `build:${platform}`, '&&', - ...startCommand - ]; -}; - -const startExample = async (example: string, skipUpscalerBuild?: boolean) => { +const startExample = async (example: string) => { const examplePath = path.resolve(EXAMPLES_DIR, example); try { fs.accessSync(examplePath); @@ -62,14 +56,6 @@ const startExample = async (example: string, skipUpscalerBuild?: boolean) => { process.exit(1) } - // get package name from directory - const { platform } = getExampleInfo(examplePath); - - if (skipUpscalerBuild !== true) { - await runPNPMScript(`build:${platform}`, 'upscaler') - console.log(`** built upscaler: ${platform}`) - } - spawn("npm", ['install', '--no-package-lock', '&&', 'npm', 'run', 'dev'], { shell: true, cwd: examplePath, @@ -81,22 +67,21 @@ const startExample = async (example: string, skipUpscalerBuild?: boolean) => { /**** * Functions to expose the main function as a CLI tool */ -type Answers = { exampleDirectory: string, skipUpscalerBuild?: boolean } +type Answers = { exampleDirectory: string } const getArgs = async (): Promise => { const argv = await yargs(process.argv.slice(2)).options({ - skipUpscalerBuild: { type: 'boolean' }, }).help().argv; const exampleDirectory = await getString('Which example do you want to start?', argv._[0]); - return { exampleDirectory, skipUpscalerBuild: argv.skipUpscalerBuild }; + return { exampleDirectory, }; } if (require.main === module) { (async () => { - const { exampleDirectory, skipUpscalerBuild } = await getArgs(); + const { exampleDirectory } = await getArgs(); - await startExample(exampleDirectory, skipUpscalerBuild); + await startExample(exampleDirectory); })(); }