@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.
Files changed (129) hide show
  1. package/README.md +259 -14
  2. package/bin/cli.js +3 -0
  3. package/bin/run-hook-mocha.js +3 -0
  4. package/bin/run-hook-tsc.js +3 -0
  5. package/bin/wrapper-webpack.js +168 -0
  6. package/config/tsconfig.base.json +16 -0
  7. package/dist/bin/run-hook-mocha.d.ts +1 -0
  8. package/dist/bin/run-hook-mocha.js +49 -0
  9. package/dist/bin/run-hook-tsc.d.ts +1 -0
  10. package/dist/bin/run-hook-tsc.js +19 -0
  11. package/dist/cli-parsers.d.ts +9 -0
  12. package/dist/cli-parsers.js +131 -0
  13. package/dist/cli.d.ts +1 -0
  14. package/dist/cli.js +495 -0
  15. package/dist/commands/form-config.d.ts +6 -0
  16. package/dist/commands/form-config.js +401 -0
  17. package/dist/commands/sync-translation.d.ts +23 -0
  18. package/dist/commands/sync-translation.js +348 -0
  19. package/dist/completion/index.d.ts +1 -0
  20. package/dist/completion/index.js +218 -0
  21. package/dist/generators/add-method.d.ts +27 -0
  22. package/dist/generators/add-method.js +235 -0
  23. package/dist/generators/angular-app.d.ts +24 -0
  24. package/dist/generators/angular-app.js +342 -0
  25. package/dist/generators/angular-service.d.ts +21 -0
  26. package/dist/generators/angular-service.js +154 -0
  27. package/dist/generators/controller.d.ts +40 -0
  28. package/dist/generators/controller.js +195 -0
  29. package/dist/generators/form-component.d.ts +46 -0
  30. package/dist/generators/form-component.js +906 -0
  31. package/dist/generators/form-field.d.ts +15 -0
  32. package/dist/generators/form-field.js +160 -0
  33. package/dist/generators/migration.d.ts +15 -0
  34. package/dist/generators/migration.js +100 -0
  35. package/dist/generators/model.d.ts +42 -0
  36. package/dist/generators/model.js +206 -0
  37. package/dist/generators/service.d.ts +16 -0
  38. package/dist/generators/service.js +111 -0
  39. package/dist/runtime-resolver.d.ts +3 -0
  40. package/dist/runtime-resolver.js +27 -0
  41. package/dist/templates/hook-archetype.d.ts +12 -0
  42. package/dist/templates/hook-archetype.js +187 -0
  43. package/dist/testing.d.ts +7 -0
  44. package/dist/testing.js +53 -0
  45. package/dist/utils/config-helper.d.ts +71 -0
  46. package/dist/utils/config-helper.js +574 -0
  47. package/dist/utils/generator.d.ts +10 -0
  48. package/dist/utils/generator.js +68 -0
  49. package/dist/utils/hook-tsconfig.d.ts +9 -0
  50. package/dist/utils/hook-tsconfig.js +104 -0
  51. package/dist/utils/paths.d.ts +10 -0
  52. package/dist/utils/paths.js +60 -0
  53. package/index.js +4 -0
  54. package/package.json +76 -19
  55. package/runtime-resolver.d.ts +1 -0
  56. package/runtime-resolver.js +3 -0
  57. package/skills/redbox-angular-apps/SKILL.md +42 -0
  58. package/skills/redbox-angular-services/SKILL.md +29 -0
  59. package/skills/redbox-controllers/SKILL.md +65 -0
  60. package/skills/redbox-feature-design-planner/SKILL.md +169 -0
  61. package/skills/redbox-feature-implementation-review/SKILL.md +117 -0
  62. package/skills/redbox-form-components/SKILL.md +114 -0
  63. package/skills/redbox-form-config/SKILL.md +34 -0
  64. package/skills/redbox-hook-development/SKILL.md +66 -0
  65. package/skills/redbox-services/SKILL.md +54 -0
  66. package/skills/redbox-test-verification/SKILL.md +38 -0
  67. package/skills/redbox-testing/SKILL.md +64 -0
  68. package/skills/redbox-web-verification/SKILL.md +71 -0
  69. package/skills/redbox-web-verification/redbox-angular-apps/SKILL.md +48 -0
  70. package/skills/redbox-web-verification/redbox-angular-services/SKILL.md +30 -0
  71. package/skills/redbox-web-verification/redbox-controllers/SKILL.md +56 -0
  72. package/skills/redbox-web-verification/redbox-form-config/SKILL.md +29 -0
  73. package/skills/redbox-web-verification/redbox-hook-development/SKILL.md +61 -0
  74. package/skills/redbox-web-verification/redbox-services/SKILL.md +45 -0
  75. package/skills/redbox-web-verification/redbox-testing/SKILL.md +53 -0
  76. package/skills/redbox-web-verification/redbox-web-verification/SKILL.md +47 -0
  77. package/templates/hook-archetype/standard/.gitignore.hbs +5 -0
  78. package/templates/hook-archetype/standard/.npmignore.hbs +4 -0
  79. package/templates/hook-archetype/standard/.npmrc.hbs +6 -0
  80. package/templates/hook-archetype/standard/.nvmrc.hbs +1 -0
  81. package/templates/hook-archetype/standard/AGENTS.md.hbs +51 -0
  82. package/templates/hook-archetype/standard/Dockerfile.hbs +29 -0
  83. package/templates/hook-archetype/standard/README.md.hbs +57 -0
  84. package/templates/hook-archetype/standard/assets/default/.gitkeep +1 -0
  85. package/templates/hook-archetype/standard/assets/fonts/.gitkeep +1 -0
  86. package/templates/hook-archetype/standard/assets/images/.gitkeep +1 -0
  87. package/templates/hook-archetype/standard/assets/styles/.gitkeep +1 -0
  88. package/templates/hook-archetype/standard/language-defaults/.gitkeep +1 -0
  89. package/templates/hook-archetype/standard/language-defaults/README.md.hbs +10 -0
  90. package/templates/hook-archetype/standard/language-defaults/en/translation.json.hbs +3 -0
  91. package/templates/hook-archetype/standard/language-defaults/meta.json.hbs +6 -0
  92. package/templates/hook-archetype/standard/package.json.hbs +44 -0
  93. package/templates/hook-archetype/standard/src/api/controllers/ExampleController.ts.hbs +21 -0
  94. package/templates/hook-archetype/standard/src/api/controllers/index.ts.hbs +23 -0
  95. package/templates/hook-archetype/standard/src/api/services/ExampleService.ts.hbs +22 -0
  96. package/templates/hook-archetype/standard/src/api/services/index.ts.hbs +23 -0
  97. package/templates/hook-archetype/standard/src/config/brandingConfigurationDefaults.ts.hbs +9 -0
  98. package/templates/hook-archetype/standard/src/config/reusableFormDefinitions.ts.hbs +6 -0
  99. package/templates/hook-archetype/standard/src/form-config/default-1.0-draft.ts.hbs +20 -0
  100. package/templates/hook-archetype/standard/src/form-config/index.ts.hbs +8 -0
  101. package/templates/hook-archetype/standard/src/index.ts.hbs +55 -0
  102. package/templates/hook-archetype/standard/src/migrations/index.ts.hbs +19 -0
  103. package/templates/hook-archetype/standard/support/bootstrap-data/.gitkeep +1 -0
  104. package/templates/hook-archetype/standard/support/bootstrap-data/namedqueries/.gitkeep +1 -0
  105. package/templates/hook-archetype/standard/support/bootstrap-data/records/.gitkeep +1 -0
  106. package/templates/hook-archetype/standard/support/bootstrap-data/reports/.gitkeep +1 -0
  107. package/templates/hook-archetype/standard/support/bootstrap-data/vocabularies/.gitkeep +1 -0
  108. package/templates/hook-archetype/standard/support/development/core-mount.env.hbs +3 -0
  109. package/templates/hook-archetype/standard/support/development/docker-compose.core-mount.yml.hbs +37 -0
  110. package/templates/hook-archetype/standard/support/development/docker-compose.yml.hbs +108 -0
  111. package/templates/hook-archetype/standard/support/development/prepare-core-mount.sh.hbs +61 -0
  112. package/templates/hook-archetype/standard/support/integration-testing/docker-compose.mocha.yml.hbs +118 -0
  113. package/templates/hook-archetype/standard/support/integration-testing/run-mocha-hook.sh.hbs +14 -0
  114. package/templates/hook-archetype/standard/support/integration-testing/run-mocha-redbox.sh.hbs +100 -0
  115. package/templates/hook-archetype/standard/support/prepare-minio.sh.hbs +74 -0
  116. package/templates/hook-archetype/standard/test/integration/hook-registration.test.ts.hbs +15 -0
  117. package/templates/hook-archetype/standard/test/support/globals.ts.hbs +40 -0
  118. package/templates/hook-archetype/standard/test/tsconfig.json.hbs +8 -0
  119. package/templates/hook-archetype/standard/test/unit/.mocharc.cjs.hbs +9 -0
  120. package/templates/hook-archetype/standard/test/unit/index.test.ts.hbs +46 -0
  121. package/templates/hook-archetype/standard/tsconfig.json.hbs +15 -0
  122. package/templates/hook-archetype/standard/views/.gitkeep +1 -0
  123. package/templates/hook-archetype/standard/views/default/.gitkeep +1 -0
  124. package/testing.d.ts +1 -0
  125. package/testing.js +3 -0
  126. package/.travis.yml +0 -23
  127. package/commands/initProject.js +0 -129
  128. package/redbox-dev-tools +0 -70
  129. 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,8 @@
1
+ {
2
+ "extends": "../tsconfig.json",
3
+ "compilerOptions": {
4
+ "noEmit": true,
5
+ "types": ["node", "mocha", "chai"]
6
+ },
7
+ "include": ["./**/*.ts", "../src/**/*.ts"]
8
+ }
@@ -0,0 +1,9 @@
1
+ module.exports = {
2
+ require: ['ts-node/register'],
3
+ extension: ['ts'],
4
+ recursive: true,
5
+ timeout: '30s',
6
+ ui: 'bdd',
7
+ reporter: 'spec',
8
+ exit: true
9
+ };
@@ -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
+ }
package/testing.d.ts ADDED
@@ -0,0 +1 @@
1
+ export * from './dist/testing';
package/testing.js ADDED
@@ -0,0 +1,3 @@
1
+ 'use strict';
2
+
3
+ module.exports = require('./dist/testing.js');
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
@@ -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
- }