gsd-init 1.0.9 → 1.0.10
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.
- package/bin/gsd.js +54 -0
- package/package.json +3 -2
package/bin/gsd.js
ADDED
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
'use strict';
|
|
3
|
+
var major = parseInt(process.version.slice(1).split('.')[0], 10);
|
|
4
|
+
if (major < 16) {
|
|
5
|
+
process.stderr.write('gsd requires Node.js >= 16 (found ' + process.version + ')\n');
|
|
6
|
+
process.exit(1);
|
|
7
|
+
}
|
|
8
|
+
const { execFileSync } = require('child_process');
|
|
9
|
+
const path = require('path');
|
|
10
|
+
const fs = require('fs');
|
|
11
|
+
|
|
12
|
+
const args = process.argv.slice(2);
|
|
13
|
+
const cmd = args[0];
|
|
14
|
+
|
|
15
|
+
function findScript(name) {
|
|
16
|
+
var p = path.join(process.cwd(), '.gsd', 'scripts', name);
|
|
17
|
+
if (!fs.existsSync(p)) {
|
|
18
|
+
console.error('Error: ' + p + ' not found. Run "gsd init <project-name>" first.');
|
|
19
|
+
process.exit(1);
|
|
20
|
+
}
|
|
21
|
+
return p;
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
function runScript(name) {
|
|
25
|
+
var script = findScript(name);
|
|
26
|
+
execFileSync(script, { stdio: 'inherit' });
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
switch (cmd) {
|
|
30
|
+
case 'init': {
|
|
31
|
+
var projectName = args[1];
|
|
32
|
+
if (!projectName) {
|
|
33
|
+
console.error('Usage: gsd init <project-name>');
|
|
34
|
+
process.exit(1);
|
|
35
|
+
}
|
|
36
|
+
var initScript = path.join(__dirname, 'gsd-init.js');
|
|
37
|
+
execFileSync(process.execPath, [initScript, projectName], { stdio: 'inherit' });
|
|
38
|
+
break;
|
|
39
|
+
}
|
|
40
|
+
case 'start':
|
|
41
|
+
runScript('start.sh');
|
|
42
|
+
break;
|
|
43
|
+
case 'teardown':
|
|
44
|
+
runScript('teardown.sh');
|
|
45
|
+
break;
|
|
46
|
+
default:
|
|
47
|
+
console.log([
|
|
48
|
+
'Usage:',
|
|
49
|
+
' gsd init <project-name> Create project folder and install GSD',
|
|
50
|
+
' gsd start Start observer + worker tmux sessions',
|
|
51
|
+
' gsd teardown Kill all GSD tmux sessions',
|
|
52
|
+
].join('\n'));
|
|
53
|
+
process.exit(cmd ? 1 : 0);
|
|
54
|
+
}
|
package/package.json
CHANGED
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "gsd-init",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.10",
|
|
4
4
|
"description": "Set up GSD observer/worker tmux system in a project",
|
|
5
5
|
"bin": {
|
|
6
|
-
"gsd-init": "bin/gsd-init.js"
|
|
6
|
+
"gsd-init": "bin/gsd-init.js",
|
|
7
|
+
"gsd": "bin/gsd.js"
|
|
7
8
|
},
|
|
8
9
|
"files": [
|
|
9
10
|
"bin",
|