-
Notifications
You must be signed in to change notification settings - Fork 74
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Set up an internals/scripts package, and migrate start-example over (#…
- Loading branch information
1 parent
8616d33
commit 9de1206
Showing
9 changed files
with
151 additions
and
138 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,67 @@ | ||
{ | ||
"name": "@internals/scripts", | ||
"private": true, | ||
"type": "module", | ||
"version": "0.1.0", | ||
"description": "Scripts for managing the UpscalerJS Repo", | ||
"exports": { | ||
"./start-example": "./dist/bin/start-example.js", | ||
".": "./dist/index.js" | ||
}, | ||
"author": "Kevin Scott", | ||
"license": "MIT", | ||
"dependencies": { | ||
"@internals/common": "workspace:*" | ||
}, | ||
"scripts": { | ||
"start-example": "wireit", | ||
"build": "wireit", | ||
"test:run": "wireit", | ||
"test": "wireit" | ||
}, | ||
"wireit": { | ||
"start-example": { | ||
"command": "node ./dist/bin/start-example.js", | ||
"dependencies": [ | ||
"build" | ||
] | ||
}, | ||
"build": { | ||
"command": "tsc -p ./tsconfig.json", | ||
"dependencies": [ | ||
"../common:build" | ||
], | ||
"files": [ | ||
"src/**/*.ts", | ||
"src/**/*.mts", | ||
"!src/**/*.test.ts", | ||
"!src/**/*.test.mts", | ||
"package.json", | ||
"vite.config.ts", | ||
"tsconfig.json" | ||
], | ||
"output": [ | ||
"dist/**" | ||
] | ||
}, | ||
"test:run": { | ||
"command": "vitest run --config ./vite.config.ts", | ||
"dependencies": [ | ||
"../common:build" | ||
] | ||
}, | ||
"test": { | ||
"command": "vitest --config ./vite.config.ts", | ||
"dependencies": [ | ||
"../common:build" | ||
] | ||
} | ||
}, | ||
"engines": { | ||
"node": ">=20.0.0" | ||
}, | ||
"devDependencies": { | ||
"wireit": "latest", | ||
"vitest": "^0.34.2" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
/***** | ||
* This script spins up a local instance of a particular example, and sets up a watch command to build UpscalerJS. | ||
*/ | ||
|
||
import path from 'path'; | ||
import { spawn } from 'child_process'; | ||
import { EXAMPLES_DIR } from '@internals/common/constants'; | ||
import { stat, exists } from '@internals/common/fs'; | ||
import { parseArgs } from "node:util"; | ||
|
||
/**** | ||
* Main function | ||
*/ | ||
|
||
const startExample = (example: string) => { | ||
const examplePath = path.resolve(EXAMPLES_DIR, example); | ||
|
||
const command = 'npm install --force --no-package-lock && npm run dev'.split(' '); | ||
|
||
return spawn(command[0], command.slice(1), { | ||
shell: true, | ||
cwd: examplePath, | ||
stdio: "inherit" | ||
}); | ||
}; | ||
|
||
|
||
const isValidExample = async (exampleDirectory: string) => { | ||
const examplePath = path.resolve(EXAMPLES_DIR, exampleDirectory); | ||
return await exists(examplePath) && (await stat(examplePath)).isDirectory(); | ||
}; | ||
|
||
const main = async () => { | ||
const { | ||
positionals: [ | ||
exampleDirectory, | ||
] | ||
} = parseArgs({ | ||
allowPositionals: true, | ||
}); | ||
|
||
if (!await isValidExample(exampleDirectory)) { | ||
throw new Error(`Example directory does not exist: "${exampleDirectory}"`); | ||
} | ||
startExample(exampleDirectory); | ||
}; | ||
|
||
main(); |
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
{ | ||
"extends": "../tsconfig.json", | ||
"compilerOptions": { | ||
"rootDir": "./src", | ||
"outDir": "./dist", | ||
}, | ||
"include": ["./src/**/*.ts", "./src/**/*.mts"], | ||
"exclude": ["./src/**/*.test.ts", "./src/**/*.test.mts"], | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
import { defineConfig, mergeConfig } from 'vitest/config'; | ||
import configShared from '../vite.config'; | ||
|
||
export default mergeConfig(configShared, defineConfig({ | ||
})); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.