key-screen-framework 0.1.0 → 1.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
import { spawnSync } from 'node:child_process'
|
|
3
|
+
import { readFileSync } from 'node:fs'
|
|
4
|
+
import { fileURLToPath } from 'node:url'
|
|
5
|
+
|
|
6
|
+
const commands = {
|
|
7
|
+
'new-project': ['key-screen-new-project', 'new-project.mjs'],
|
|
8
|
+
migrate: ['key-screen-migrate', 'migrate-project.mjs'],
|
|
9
|
+
doctor: ['key-screen-doctor', 'doctor-project.mjs'],
|
|
10
|
+
generate: ['key-screen-generate', 'generate-screen.mjs'],
|
|
11
|
+
remove: ['key-screen-remove', 'remove-screen.mjs'],
|
|
12
|
+
sync: ['key-screen-sync', 'sync-screens.mjs'],
|
|
13
|
+
'setup-arduino': ['key-screen-setup-arduino', 'setup-arduino-cli.mjs'],
|
|
14
|
+
'check-arduino-bundle': ['key-screen-check-arduino-bundle', 'check-arduino-bundle.mjs']
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
const [command, ...args] = process.argv.slice(2)
|
|
18
|
+
|
|
19
|
+
if (!command || command === '--help' || command === '-h') {
|
|
20
|
+
console.log('Usage: npx key-screen-framework <command> [options]\n')
|
|
21
|
+
console.log('Commands:')
|
|
22
|
+
for (const name of Object.keys(commands)) {
|
|
23
|
+
console.log(` ${name}`)
|
|
24
|
+
}
|
|
25
|
+
console.log('\nExample: npx key-screen-framework new-project')
|
|
26
|
+
} else if (command === '--version' || command === '-v') {
|
|
27
|
+
const manifest = JSON.parse(readFileSync(new URL('../package.json', import.meta.url), 'utf8'))
|
|
28
|
+
console.log(manifest.version)
|
|
29
|
+
} else {
|
|
30
|
+
const entry = Object.hasOwn(commands, command)
|
|
31
|
+
? commands[command]
|
|
32
|
+
: Object.values(commands).find(([alias]) => alias === command)
|
|
33
|
+
if (!entry) {
|
|
34
|
+
console.error(`Unknown command: ${command}. Run key-screen-framework --help for available commands.`)
|
|
35
|
+
process.exitCode = 1
|
|
36
|
+
} else {
|
|
37
|
+
// Keep the caller's working directory and terminal for interactive prompts.
|
|
38
|
+
const result = spawnSync(process.execPath, [fileURLToPath(new URL(entry[1], import.meta.url)), ...args], {
|
|
39
|
+
stdio: 'inherit'
|
|
40
|
+
})
|
|
41
|
+
if (result.error) {
|
|
42
|
+
console.error(result.error.message)
|
|
43
|
+
process.exitCode = 1
|
|
44
|
+
} else if (result.signal) {
|
|
45
|
+
process.kill(process.pid, result.signal)
|
|
46
|
+
} else {
|
|
47
|
+
process.exitCode = result.status ?? 1
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "key-screen-framework",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "1.1.0",
|
|
4
4
|
"description": "Screen framework for Keyescape desktop projects.",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -79,6 +79,7 @@
|
|
|
79
79
|
"**/*.css"
|
|
80
80
|
],
|
|
81
81
|
"bin": {
|
|
82
|
+
"key-screen-framework": "./cli/key-screen-framework.mjs",
|
|
82
83
|
"key-screen-new-project": "./cli/new-project.mjs",
|
|
83
84
|
"key-screen-migrate": "./cli/migrate-project.mjs",
|
|
84
85
|
"key-screen-doctor": "./cli/doctor-project.mjs",
|