@researchdatabox/redbox-dev-tools 0.0.1 → 5.0.0-RC2
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/README.md +259 -14
- package/bin/cli.js +3 -0
- package/bin/run-hook-mocha.js +3 -0
- package/bin/run-hook-tsc.js +3 -0
- package/bin/wrapper-webpack.js +168 -0
- package/config/tsconfig.base.json +16 -0
- package/dist/bin/run-hook-mocha.d.ts +1 -0
- package/dist/bin/run-hook-mocha.js +49 -0
- package/dist/bin/run-hook-tsc.d.ts +1 -0
- package/dist/bin/run-hook-tsc.js +19 -0
- package/dist/cli-parsers.d.ts +9 -0
- package/dist/cli-parsers.js +131 -0
- package/dist/cli.d.ts +1 -0
- package/dist/cli.js +495 -0
- package/dist/commands/form-config.d.ts +6 -0
- package/dist/commands/form-config.js +401 -0
- package/dist/commands/sync-translation.d.ts +23 -0
- package/dist/commands/sync-translation.js +348 -0
- package/dist/completion/index.d.ts +1 -0
- package/dist/completion/index.js +218 -0
- package/dist/generators/add-method.d.ts +27 -0
- package/dist/generators/add-method.js +235 -0
- package/dist/generators/angular-app.d.ts +24 -0
- package/dist/generators/angular-app.js +342 -0
- package/dist/generators/angular-service.d.ts +21 -0
- package/dist/generators/angular-service.js +154 -0
- package/dist/generators/controller.d.ts +40 -0
- package/dist/generators/controller.js +195 -0
- package/dist/generators/form-component.d.ts +46 -0
- package/dist/generators/form-component.js +906 -0
- package/dist/generators/form-field.d.ts +15 -0
- package/dist/generators/form-field.js +160 -0
- package/dist/generators/migration.d.ts +15 -0
- package/dist/generators/migration.js +100 -0
- package/dist/generators/model.d.ts +42 -0
- package/dist/generators/model.js +206 -0
- package/dist/generators/service.d.ts +16 -0
- package/dist/generators/service.js +111 -0
- package/dist/runtime-resolver.d.ts +3 -0
- package/dist/runtime-resolver.js +27 -0
- package/dist/templates/hook-archetype.d.ts +12 -0
- package/dist/templates/hook-archetype.js +187 -0
- package/dist/testing.d.ts +7 -0
- package/dist/testing.js +53 -0
- package/dist/utils/config-helper.d.ts +71 -0
- package/dist/utils/config-helper.js +574 -0
- package/dist/utils/generator.d.ts +10 -0
- package/dist/utils/generator.js +68 -0
- package/dist/utils/hook-tsconfig.d.ts +9 -0
- package/dist/utils/hook-tsconfig.js +104 -0
- package/dist/utils/paths.d.ts +10 -0
- package/dist/utils/paths.js +60 -0
- package/index.js +4 -0
- package/package.json +76 -19
- package/runtime-resolver.d.ts +1 -0
- package/runtime-resolver.js +3 -0
- package/skills/redbox-angular-apps/SKILL.md +42 -0
- package/skills/redbox-angular-services/SKILL.md +29 -0
- package/skills/redbox-controllers/SKILL.md +65 -0
- package/skills/redbox-feature-design-planner/SKILL.md +169 -0
- package/skills/redbox-feature-implementation-review/SKILL.md +117 -0
- package/skills/redbox-form-components/SKILL.md +114 -0
- package/skills/redbox-form-config/SKILL.md +34 -0
- package/skills/redbox-hook-development/SKILL.md +66 -0
- package/skills/redbox-services/SKILL.md +54 -0
- package/skills/redbox-test-verification/SKILL.md +38 -0
- package/skills/redbox-testing/SKILL.md +64 -0
- package/skills/redbox-web-verification/SKILL.md +71 -0
- package/skills/redbox-web-verification/redbox-angular-apps/SKILL.md +48 -0
- package/skills/redbox-web-verification/redbox-angular-services/SKILL.md +30 -0
- package/skills/redbox-web-verification/redbox-controllers/SKILL.md +56 -0
- package/skills/redbox-web-verification/redbox-form-config/SKILL.md +29 -0
- package/skills/redbox-web-verification/redbox-hook-development/SKILL.md +61 -0
- package/skills/redbox-web-verification/redbox-services/SKILL.md +45 -0
- package/skills/redbox-web-verification/redbox-testing/SKILL.md +53 -0
- package/skills/redbox-web-verification/redbox-web-verification/SKILL.md +47 -0
- package/templates/hook-archetype/standard/.gitignore.hbs +5 -0
- package/templates/hook-archetype/standard/.npmignore.hbs +4 -0
- package/templates/hook-archetype/standard/.npmrc.hbs +6 -0
- package/templates/hook-archetype/standard/.nvmrc.hbs +1 -0
- package/templates/hook-archetype/standard/AGENTS.md.hbs +51 -0
- package/templates/hook-archetype/standard/Dockerfile.hbs +29 -0
- package/templates/hook-archetype/standard/README.md.hbs +57 -0
- package/templates/hook-archetype/standard/assets/default/.gitkeep +1 -0
- package/templates/hook-archetype/standard/assets/fonts/.gitkeep +1 -0
- package/templates/hook-archetype/standard/assets/images/.gitkeep +1 -0
- package/templates/hook-archetype/standard/assets/styles/.gitkeep +1 -0
- package/templates/hook-archetype/standard/language-defaults/.gitkeep +1 -0
- package/templates/hook-archetype/standard/language-defaults/README.md.hbs +10 -0
- package/templates/hook-archetype/standard/language-defaults/en/translation.json.hbs +3 -0
- package/templates/hook-archetype/standard/language-defaults/meta.json.hbs +6 -0
- package/templates/hook-archetype/standard/package.json.hbs +44 -0
- package/templates/hook-archetype/standard/src/api/controllers/ExampleController.ts.hbs +21 -0
- package/templates/hook-archetype/standard/src/api/controllers/index.ts.hbs +23 -0
- package/templates/hook-archetype/standard/src/api/services/ExampleService.ts.hbs +22 -0
- package/templates/hook-archetype/standard/src/api/services/index.ts.hbs +23 -0
- package/templates/hook-archetype/standard/src/config/brandingConfigurationDefaults.ts.hbs +9 -0
- package/templates/hook-archetype/standard/src/config/reusableFormDefinitions.ts.hbs +6 -0
- package/templates/hook-archetype/standard/src/form-config/default-1.0-draft.ts.hbs +20 -0
- package/templates/hook-archetype/standard/src/form-config/index.ts.hbs +8 -0
- package/templates/hook-archetype/standard/src/index.ts.hbs +55 -0
- package/templates/hook-archetype/standard/src/migrations/index.ts.hbs +19 -0
- package/templates/hook-archetype/standard/support/bootstrap-data/.gitkeep +1 -0
- package/templates/hook-archetype/standard/support/bootstrap-data/namedqueries/.gitkeep +1 -0
- package/templates/hook-archetype/standard/support/bootstrap-data/records/.gitkeep +1 -0
- package/templates/hook-archetype/standard/support/bootstrap-data/reports/.gitkeep +1 -0
- package/templates/hook-archetype/standard/support/bootstrap-data/vocabularies/.gitkeep +1 -0
- package/templates/hook-archetype/standard/support/development/core-mount.env.hbs +3 -0
- package/templates/hook-archetype/standard/support/development/docker-compose.core-mount.yml.hbs +37 -0
- package/templates/hook-archetype/standard/support/development/docker-compose.yml.hbs +108 -0
- package/templates/hook-archetype/standard/support/development/prepare-core-mount.sh.hbs +61 -0
- package/templates/hook-archetype/standard/support/integration-testing/docker-compose.mocha.yml.hbs +118 -0
- package/templates/hook-archetype/standard/support/integration-testing/run-mocha-hook.sh.hbs +14 -0
- package/templates/hook-archetype/standard/support/integration-testing/run-mocha-redbox.sh.hbs +100 -0
- package/templates/hook-archetype/standard/support/prepare-minio.sh.hbs +74 -0
- package/templates/hook-archetype/standard/test/integration/hook-registration.test.ts.hbs +15 -0
- package/templates/hook-archetype/standard/test/support/globals.ts.hbs +40 -0
- package/templates/hook-archetype/standard/test/tsconfig.json.hbs +8 -0
- package/templates/hook-archetype/standard/test/unit/.mocharc.cjs.hbs +9 -0
- package/templates/hook-archetype/standard/test/unit/index.test.ts.hbs +46 -0
- package/templates/hook-archetype/standard/tsconfig.json.hbs +15 -0
- package/templates/hook-archetype/standard/views/.gitkeep +1 -0
- package/templates/hook-archetype/standard/views/default/.gitkeep +1 -0
- package/testing.d.ts +1 -0
- package/testing.js +3 -0
- package/.travis.yml +0 -23
- package/commands/initProject.js +0 -129
- package/redbox-dev-tools +0 -70
- package/yarn.lock +0 -1061
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
const { _ } = require('@researchdatabox/redbox-dev-tools/testing');
|
|
2
|
+
|
|
3
|
+
type LogFn = (...args: unknown[]) => void;
|
|
4
|
+
|
|
5
|
+
const noop: LogFn = () => undefined;
|
|
6
|
+
|
|
7
|
+
function installHookTestGlobals(overrides: Record<string, unknown> = {}): void {
|
|
8
|
+
(global as any)._ = _;
|
|
9
|
+
(global as any).sails = {
|
|
10
|
+
config: {
|
|
11
|
+
appPath: process.cwd(),
|
|
12
|
+
appUrl: 'https://example.redbox.local',
|
|
13
|
+
http: {
|
|
14
|
+
rootContext: 'redbox'
|
|
15
|
+
},
|
|
16
|
+
brandingConfigurationDefaults: {},
|
|
17
|
+
reusableFormDefinitions: {},
|
|
18
|
+
...overrides
|
|
19
|
+
},
|
|
20
|
+
log: {
|
|
21
|
+
trace: noop,
|
|
22
|
+
verbose: noop,
|
|
23
|
+
info: noop,
|
|
24
|
+
warn: noop,
|
|
25
|
+
error: noop,
|
|
26
|
+
debug: noop
|
|
27
|
+
},
|
|
28
|
+
services: {}
|
|
29
|
+
};
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
function clearHookTestGlobals(): void {
|
|
33
|
+
delete (global as any)._;
|
|
34
|
+
delete (global as any).sails;
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
module.exports = {
|
|
38
|
+
installHookTestGlobals,
|
|
39
|
+
clearHookTestGlobals
|
|
40
|
+
};
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
const { expect, firstValueFrom } = require('@researchdatabox/redbox-dev-tools/testing');
|
|
2
|
+
const { clearHookTestGlobals, installHookTestGlobals } = require('../support/globals');
|
|
3
|
+
|
|
4
|
+
const hookModulePath = require.resolve('../../dist/index.js');
|
|
5
|
+
|
|
6
|
+
let hookModule;
|
|
7
|
+
|
|
8
|
+
describe('hook entrypoint', function () {
|
|
9
|
+
beforeEach(() => {
|
|
10
|
+
installHookTestGlobals();
|
|
11
|
+
delete require.cache[hookModulePath];
|
|
12
|
+
hookModule = require(hookModulePath);
|
|
13
|
+
});
|
|
14
|
+
|
|
15
|
+
afterEach(() => {
|
|
16
|
+
clearHookTestGlobals();
|
|
17
|
+
delete require.cache[hookModulePath];
|
|
18
|
+
});
|
|
19
|
+
|
|
20
|
+
it('exports the standard hook registrations and aliases', async function () {
|
|
21
|
+
const config = hookModule.registerRedboxConfig();
|
|
22
|
+
|
|
23
|
+
expect(config).to.have.property('brandingConfigurationDefaults');
|
|
24
|
+
expect(config).to.have.property('reusableFormDefinitions');
|
|
25
|
+
expect(config.brandingConfigurationDefaults.menu).to.deep.equal({ items: [], showSearch: true });
|
|
26
|
+
expect(config.brandingConfigurationDefaults.homePanels).to.deep.equal({ panels: [] });
|
|
27
|
+
expect(hookModule.registerRedboxServices()).to.have.property('ExampleService');
|
|
28
|
+
expect(hookModule.registerRedboxControllers()).to.have.property('ExampleController');
|
|
29
|
+
expect(hookModule.registerRedboxFormConfigs()).to.have.property('generated-view-only');
|
|
30
|
+
expect(hookModule.registerRedboxMigrations()).to.deep.equal([]);
|
|
31
|
+
expect(hookModule.MigrationExports).to.equal(hookModule.registerRedboxMigrations());
|
|
32
|
+
expect(hookModule.registerFormConfig()).to.equal(hookModule.registerRedboxFormConfigs());
|
|
33
|
+
|
|
34
|
+
const result = await firstValueFrom(hookModule.registerRedboxServices().ExampleService.describe());
|
|
35
|
+
expect(result).to.deep.equal({ hook: '{{packageName}}', status: 'ready' });
|
|
36
|
+
});
|
|
37
|
+
|
|
38
|
+
it('keeps configure empty while config is provided through registerRedboxConfig', function () {
|
|
39
|
+
const hook = hookModule((global as any).sails);
|
|
40
|
+
|
|
41
|
+
hook.configure?.();
|
|
42
|
+
|
|
43
|
+
expect((global as any).sails.config.brandingConfigurationDefaults).to.deep.equal({});
|
|
44
|
+
expect((global as any).sails.config.reusableFormDefinitions).to.deep.equal({});
|
|
45
|
+
});
|
|
46
|
+
});
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
{
|
|
2
|
+
"extends": "@researchdatabox/redbox-dev-tools/config/tsconfig.base.json",
|
|
3
|
+
"compilerOptions": {
|
|
4
|
+
"declaration": true,
|
|
5
|
+
"declarationMap": true,
|
|
6
|
+
"outDir": "./dist",
|
|
7
|
+
"strict": true,
|
|
8
|
+
"allowUmdGlobalAccess": true,
|
|
9
|
+
"typeRoots": [
|
|
10
|
+
"./node_modules/@types"
|
|
11
|
+
]
|
|
12
|
+
},
|
|
13
|
+
"include": ["src/**/*.ts", "src/**/*.d.ts"],
|
|
14
|
+
"exclude": ["dist/**/*.ts", "dist/**/*.d.ts"]
|
|
15
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
|
package/testing.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './dist/testing';
|
package/testing.js
ADDED
package/.travis.yml
DELETED
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
sudo: required
|
|
2
|
-
services:
|
|
3
|
-
- docker
|
|
4
|
-
language: node_js
|
|
5
|
-
node_js:
|
|
6
|
-
- '8'
|
|
7
|
-
env:
|
|
8
|
-
global:
|
|
9
|
-
- COMMIT=${TRAVIS_COMMIT::8}
|
|
10
|
-
- CXX=g++-4.9
|
|
11
|
-
- secure: g1WCGWA64MAgXY6X+1/XxKOab3ANBXq9aUJFE7HzIWvZ6xty/mTbHbz8cX16ltfMxHWyy4icFXsKxb4lEFS3Tj50osVFTbBRljG01kyzwT5S+gJPTmqaN0c/lV5pvaUNkg1bE3dHLIuZamunUk7kJIzgByeEVr5Of05H+/QRqycJx88aE91vhxOCODe268OypQZUOQ70BkIalvSIHunCYlrD5MflS+EmMs+eTet9mRNB4Wa2xDoymFQ4VS8QVA2XrSDpdFDKJyRW6AvfmUsJFr1yhZlwMSgZsHqAbyVqU28FbkmRHyFjxarxhGW3WACAPeYjLfzoyGE1DAkmRJFh2DIFa7xOCeI3e2lwN25qObN9ETlLPKTdxiOgQ9M74A7rpdem4wmu8Bws1Std04eAh03BXsFuTLHZ9sXtMHbNbyF+X2eLOBaw6r+OPxhSaxCrQa4ZNQI7HeY7Eb5GiJUje+q56Nsvzeo57qnbyfd6Brt7plNuaDBIFugE4twtjS7idE8asVf8KQBnsjF7Ef9tB+ouACHGo1Ne6ccNQ7KXqC4irpzjraqhRhXwUKcDhC/44hYTdAfboZlnE5QDxMNiDvMDTPGmp16rcx5/5QAgRzkdNQOe+RhY2UN99W7o8UORkuYKoNp5Vp42FT+ff7pXpH895TtkJVYGYj/szDdTe+4=
|
|
12
|
-
jobs:
|
|
13
|
-
include:
|
|
14
|
-
- stage: Build the package
|
|
15
|
-
before_install: npm install
|
|
16
|
-
install: true
|
|
17
|
-
deploy:
|
|
18
|
-
provider: npm
|
|
19
|
-
email: dev@redboxresearchdata.com.au
|
|
20
|
-
api_key: "$NPM_API_KEY"
|
|
21
|
-
skip_cleanup: true
|
|
22
|
-
on:
|
|
23
|
-
tags: true
|
package/commands/initProject.js
DELETED
|
@@ -1,129 +0,0 @@
|
|
|
1
|
-
let request = require('request');
|
|
2
|
-
let fs = require('fs');
|
|
3
|
-
let fsextra = require('fs-extra');
|
|
4
|
-
let process = require('process');
|
|
5
|
-
let downloadRelease = require('download-github-release');
|
|
6
|
-
let mustache = require('mustache');
|
|
7
|
-
let inly = require('inly');
|
|
8
|
-
|
|
9
|
-
class InitProject {
|
|
10
|
-
|
|
11
|
-
getHelp() {
|
|
12
|
-
const sections = [
|
|
13
|
-
{
|
|
14
|
-
header: 'ReDBox Dev Tools - Init Hook',
|
|
15
|
-
content: 'Initialises a hook project for use with ReDBox'
|
|
16
|
-
},
|
|
17
|
-
{
|
|
18
|
-
header: 'Usage',
|
|
19
|
-
content: '$ redbox-dev-tools init -p redbox-hook-name'
|
|
20
|
-
},
|
|
21
|
-
{
|
|
22
|
-
header: 'Available Flags',
|
|
23
|
-
optionList: [
|
|
24
|
-
{
|
|
25
|
-
name: 'packageName',
|
|
26
|
-
alias: 'p',
|
|
27
|
-
typeLabel: '{underline name}',
|
|
28
|
-
required: true,
|
|
29
|
-
description: 'The NPM package name for the sails hook.'
|
|
30
|
-
}
|
|
31
|
-
]
|
|
32
|
-
}
|
|
33
|
-
]
|
|
34
|
-
return sections;
|
|
35
|
-
}
|
|
36
|
-
execute(options) {
|
|
37
|
-
this.repo = 'redbox-hook-template';
|
|
38
|
-
this.downloadProjectTemplate(options);
|
|
39
|
-
}
|
|
40
|
-
|
|
41
|
-
setPackageJson(options) {
|
|
42
|
-
let template = fs.readFileSync(options.packageName+"/package.json.mst", 'utf8')
|
|
43
|
-
let output = mustache.render(template, options);
|
|
44
|
-
fs.writeFileSync(options.packageName+'/package.json', output);
|
|
45
|
-
}
|
|
46
|
-
|
|
47
|
-
setIndexJs(options) {
|
|
48
|
-
let template = fs.readFileSync(options.packageName+"/index.js.mst", 'utf8')
|
|
49
|
-
let output = mustache.render(template, options);
|
|
50
|
-
fs.writeFileSync(options.packageName+"/index.js", output);
|
|
51
|
-
}
|
|
52
|
-
|
|
53
|
-
setDockerCompose(options) {
|
|
54
|
-
let template = fs.readFileSync(options.packageName+"/support/development/docker-compose.yml.mst", 'utf8')
|
|
55
|
-
let output = mustache.render(template, options);
|
|
56
|
-
fs.writeFileSync(options.packageName+"/support/development/docker-compose.yml", output);
|
|
57
|
-
}
|
|
58
|
-
|
|
59
|
-
filterRelease(release) {
|
|
60
|
-
return release.prerelease === false;
|
|
61
|
-
}
|
|
62
|
-
|
|
63
|
-
filterAsset(asset) {
|
|
64
|
-
return asset.name.indexOf('tgz') >= 0;;
|
|
65
|
-
}
|
|
66
|
-
|
|
67
|
-
extractTgz(options) {
|
|
68
|
-
let regex = `redboxresearchdata\-${this.repo}.*\.tgz`;
|
|
69
|
-
let re = new RegExp(regex,"g");
|
|
70
|
-
this.tgzFilename = "";
|
|
71
|
-
fs.mkdirSync(options.packageName);
|
|
72
|
-
fs.readdirSync(".").forEach(file => {
|
|
73
|
-
if(file.match(re)) {
|
|
74
|
-
this.tgzFilename = file;
|
|
75
|
-
}
|
|
76
|
-
})
|
|
77
|
-
|
|
78
|
-
let extract = inly(this.tgzFilename, options.packageName);
|
|
79
|
-
|
|
80
|
-
extract.on('error', (error) => {
|
|
81
|
-
console.error(error);
|
|
82
|
-
});
|
|
83
|
-
|
|
84
|
-
let that = this;
|
|
85
|
-
extract.on('end', () => {
|
|
86
|
-
console.log("Initialising project");
|
|
87
|
-
//TODO: Find moustache templates and evaluate them rather than specifying each one
|
|
88
|
-
that.setPackageJson(options);
|
|
89
|
-
that.setIndexJs(options);
|
|
90
|
-
that.setDockerCompose(options);
|
|
91
|
-
that.tidyUp(options);
|
|
92
|
-
console.log("Initialisation complete.");
|
|
93
|
-
});
|
|
94
|
-
}
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
tidyUp(options) {
|
|
98
|
-
fsextra.removeSync(this.tgzFilename);
|
|
99
|
-
fsextra.removeSync(options.packageName+"/index.js.mst");
|
|
100
|
-
fsextra.removeSync(options.packageName+"/package.json.mst");
|
|
101
|
-
fsextra.removeSync(options.packageName+"/support/development/docker-compose.yml.mst");
|
|
102
|
-
}
|
|
103
|
-
|
|
104
|
-
downloadProjectTemplate(options) {
|
|
105
|
-
let user = 'redbox-mint-contrib';
|
|
106
|
-
|
|
107
|
-
let outputDir = ".";
|
|
108
|
-
let leaveZipped = false;
|
|
109
|
-
|
|
110
|
-
if (fs.existsSync(options.packageName)) {
|
|
111
|
-
//TODO: Improve the error message
|
|
112
|
-
console.error("Dir already exists");
|
|
113
|
-
process.exit(1);
|
|
114
|
-
}
|
|
115
|
-
|
|
116
|
-
let that = this;
|
|
117
|
-
downloadRelease(user, this.repo, outputDir, this.filterRelease, this.filterAsset, leaveZipped)
|
|
118
|
-
.then(function () {
|
|
119
|
-
that.extractTgz(options);
|
|
120
|
-
})
|
|
121
|
-
.catch(function (err) {
|
|
122
|
-
console.error(err.message);
|
|
123
|
-
});
|
|
124
|
-
}
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
}
|
|
128
|
-
|
|
129
|
-
module.exports = InitProject;
|
package/redbox-dev-tools
DELETED
|
@@ -1,70 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env node
|
|
2
|
-
|
|
3
|
-
const commandLineArgs = require('command-line-args')
|
|
4
|
-
const commandLineUsage = require('command-line-usage')
|
|
5
|
-
let readlineSync = require('readline-sync');
|
|
6
|
-
|
|
7
|
-
/* first - parse the main command */
|
|
8
|
-
const mainDefinitions = [{
|
|
9
|
-
name: 'command',
|
|
10
|
-
defaultOption: true
|
|
11
|
-
}]
|
|
12
|
-
const mainOptions = commandLineArgs(mainDefinitions, {
|
|
13
|
-
stopAtFirstUnknown: true
|
|
14
|
-
})
|
|
15
|
-
const argv = mainOptions._unknown || []
|
|
16
|
-
if (mainOptions.command === 'hook-init') {
|
|
17
|
-
const mergeDefinitions = [{
|
|
18
|
-
name: 'packageName',
|
|
19
|
-
alias: 'p'
|
|
20
|
-
}]
|
|
21
|
-
|
|
22
|
-
const mergeOptions = commandLineArgs(mergeDefinitions, {
|
|
23
|
-
argv
|
|
24
|
-
})
|
|
25
|
-
|
|
26
|
-
if (!mergeOptions.packageName) {
|
|
27
|
-
mergeOptions.packageName = readlineSync.question('What package name would you like to use for this hook? \n');
|
|
28
|
-
}
|
|
29
|
-
let InitProject = require('./commands/initProject');
|
|
30
|
-
let initProject = new InitProject();
|
|
31
|
-
initProject.execute(mergeOptions);
|
|
32
|
-
} else if (mainOptions.command === 'help' || !mainOptions.command) {
|
|
33
|
-
|
|
34
|
-
if (mainOptions.command === 'help' && argv[0]) {
|
|
35
|
-
if(argv[0] == "init") {
|
|
36
|
-
let InitProject = require('./commands/initProject');
|
|
37
|
-
let initProject = new InitProject();
|
|
38
|
-
const sections = initProject.getHelp();
|
|
39
|
-
const usage = commandLineUsage(sections)
|
|
40
|
-
console.log(usage);
|
|
41
|
-
}
|
|
42
|
-
} else {
|
|
43
|
-
const sections = [
|
|
44
|
-
|
|
45
|
-
{
|
|
46
|
-
header: 'ReDBox Dev Tools',
|
|
47
|
-
content: 'A set of tools aimed at developers working with the ReDBox platform'
|
|
48
|
-
},
|
|
49
|
-
{
|
|
50
|
-
header: 'Usage',
|
|
51
|
-
content: '$ redbox-dev-tools <command> <options>'
|
|
52
|
-
},
|
|
53
|
-
{
|
|
54
|
-
header: 'Available Commands',
|
|
55
|
-
content: [{
|
|
56
|
-
name: 'init',
|
|
57
|
-
summary: 'Initialises a hook code project ready for development'
|
|
58
|
-
},
|
|
59
|
-
{
|
|
60
|
-
name: 'help',
|
|
61
|
-
summary: 'Shows this help message or help for a specific command'
|
|
62
|
-
}
|
|
63
|
-
]
|
|
64
|
-
}
|
|
65
|
-
]
|
|
66
|
-
|
|
67
|
-
const usage = commandLineUsage(sections)
|
|
68
|
-
console.log(usage);
|
|
69
|
-
}
|
|
70
|
-
}
|