@researchdatabox/redbox-dev-tools 0.0.1-beta.10173

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 (106) hide show
  1. package/README.md +255 -0
  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 +491 -0
  15. package/dist/commands/form-config.d.ts +6 -0
  16. package/dist/commands/form-config.js +404 -0
  17. package/dist/completion/index.d.ts +1 -0
  18. package/dist/completion/index.js +218 -0
  19. package/dist/generators/add-method.d.ts +27 -0
  20. package/dist/generators/add-method.js +235 -0
  21. package/dist/generators/angular-app.d.ts +24 -0
  22. package/dist/generators/angular-app.js +342 -0
  23. package/dist/generators/angular-service.d.ts +21 -0
  24. package/dist/generators/angular-service.js +154 -0
  25. package/dist/generators/controller.d.ts +40 -0
  26. package/dist/generators/controller.js +195 -0
  27. package/dist/generators/form-component.d.ts +46 -0
  28. package/dist/generators/form-component.js +906 -0
  29. package/dist/generators/form-field.d.ts +15 -0
  30. package/dist/generators/form-field.js +160 -0
  31. package/dist/generators/migration.d.ts +15 -0
  32. package/dist/generators/migration.js +100 -0
  33. package/dist/generators/model.d.ts +42 -0
  34. package/dist/generators/model.js +206 -0
  35. package/dist/generators/service.d.ts +16 -0
  36. package/dist/generators/service.js +111 -0
  37. package/dist/runtime-resolver.d.ts +3 -0
  38. package/dist/runtime-resolver.js +27 -0
  39. package/dist/templates/hook-archetype.d.ts +12 -0
  40. package/dist/templates/hook-archetype.js +186 -0
  41. package/dist/testing.d.ts +7 -0
  42. package/dist/testing.js +53 -0
  43. package/dist/utils/config-helper.d.ts +71 -0
  44. package/dist/utils/config-helper.js +574 -0
  45. package/dist/utils/generator.d.ts +10 -0
  46. package/dist/utils/generator.js +68 -0
  47. package/dist/utils/hook-tsconfig.d.ts +9 -0
  48. package/dist/utils/hook-tsconfig.js +104 -0
  49. package/dist/utils/paths.d.ts +10 -0
  50. package/dist/utils/paths.js +60 -0
  51. package/index.js +4 -0
  52. package/package.json +85 -0
  53. package/runtime-resolver.d.ts +1 -0
  54. package/runtime-resolver.js +3 -0
  55. package/skills/redbox-angular-apps/SKILL.md +42 -0
  56. package/skills/redbox-angular-services/SKILL.md +29 -0
  57. package/skills/redbox-controllers/SKILL.md +65 -0
  58. package/skills/redbox-feature-design-planner/SKILL.md +169 -0
  59. package/skills/redbox-feature-implementation-review/SKILL.md +117 -0
  60. package/skills/redbox-form-components/SKILL.md +114 -0
  61. package/skills/redbox-form-config/SKILL.md +34 -0
  62. package/skills/redbox-hook-development/SKILL.md +66 -0
  63. package/skills/redbox-services/SKILL.md +54 -0
  64. package/skills/redbox-test-verification/SKILL.md +38 -0
  65. package/skills/redbox-testing/SKILL.md +64 -0
  66. package/skills/redbox-web-verification/SKILL.md +71 -0
  67. package/skills/redbox-web-verification/redbox-angular-apps/SKILL.md +48 -0
  68. package/skills/redbox-web-verification/redbox-angular-services/SKILL.md +30 -0
  69. package/skills/redbox-web-verification/redbox-controllers/SKILL.md +56 -0
  70. package/skills/redbox-web-verification/redbox-form-config/SKILL.md +29 -0
  71. package/skills/redbox-web-verification/redbox-hook-development/SKILL.md +61 -0
  72. package/skills/redbox-web-verification/redbox-services/SKILL.md +45 -0
  73. package/skills/redbox-web-verification/redbox-testing/SKILL.md +53 -0
  74. package/skills/redbox-web-verification/redbox-web-verification/SKILL.md +47 -0
  75. package/templates/hook-archetype/standard/.gitignore.hbs +4 -0
  76. package/templates/hook-archetype/standard/.npmignore.hbs +3 -0
  77. package/templates/hook-archetype/standard/.npmrc.hbs +6 -0
  78. package/templates/hook-archetype/standard/.nvmrc.hbs +1 -0
  79. package/templates/hook-archetype/standard/AGENTS.md.hbs +34 -0
  80. package/templates/hook-archetype/standard/Dockerfile.hbs +28 -0
  81. package/templates/hook-archetype/standard/README.md.hbs +39 -0
  82. package/templates/hook-archetype/standard/assets/fonts/.gitkeep +1 -0
  83. package/templates/hook-archetype/standard/language-defaults/.gitkeep +1 -0
  84. package/templates/hook-archetype/standard/package.json.hbs +40 -0
  85. package/templates/hook-archetype/standard/src/api/controllers/ExampleController.ts.hbs +21 -0
  86. package/templates/hook-archetype/standard/src/api/controllers/index.ts.hbs +23 -0
  87. package/templates/hook-archetype/standard/src/api/services/ExampleService.ts.hbs +22 -0
  88. package/templates/hook-archetype/standard/src/api/services/index.ts.hbs +23 -0
  89. package/templates/hook-archetype/standard/src/config/brandingConfigurationDefaults.ts.hbs +9 -0
  90. package/templates/hook-archetype/standard/src/config/reusableFormDefinitions.ts.hbs +6 -0
  91. package/templates/hook-archetype/standard/src/form-config/default-1.0-draft.ts.hbs +20 -0
  92. package/templates/hook-archetype/standard/src/form-config/index.ts.hbs +8 -0
  93. package/templates/hook-archetype/standard/src/index.ts.hbs +55 -0
  94. package/templates/hook-archetype/standard/support/bootstrap-data/.gitkeep +1 -0
  95. package/templates/hook-archetype/standard/support/development/docker-compose.yml.hbs +75 -0
  96. package/templates/hook-archetype/standard/support/integration-testing/docker-compose.mocha.yml.hbs +84 -0
  97. package/templates/hook-archetype/standard/support/integration-testing/run-mocha-hook.sh.hbs +9 -0
  98. package/templates/hook-archetype/standard/test/integration/hook-registration.test.ts.hbs +13 -0
  99. package/templates/hook-archetype/standard/test/support/globals.ts.hbs +40 -0
  100. package/templates/hook-archetype/standard/test/tsconfig.json.hbs +8 -0
  101. package/templates/hook-archetype/standard/test/unit/.mocharc.cjs.hbs +9 -0
  102. package/templates/hook-archetype/standard/test/unit/index.test.ts.hbs +40 -0
  103. package/templates/hook-archetype/standard/tsconfig.json.hbs +15 -0
  104. package/templates/hook-archetype/standard/views/.gitkeep +1 -0
  105. package/testing.d.ts +1 -0
  106. package/testing.js +3 -0
@@ -0,0 +1,55 @@
1
+ import '@researchdatabox/redbox-core';
2
+ import { defineRedboxHook, type SailsConfig } from '@researchdatabox/redbox-core';
3
+ import type { FormConfigFrame } from '@researchdatabox/sails-ng-common';
4
+ import type { HookRedboxControllers } from './api/controllers';
5
+ import type { HookRedboxServices } from './api/services';
6
+ import { brandingConfigurationDefaults } from './config/brandingConfigurationDefaults';
7
+ import { reusableFormDefinitions } from './config/reusableFormDefinitions';
8
+
9
+ export {};
10
+
11
+ const hook = defineRedboxHook({
12
+ initialize(_sails, done) {
13
+ done();
14
+ },
15
+ routes() {
16
+ return {
17
+ before: {},
18
+ after: {
19
+ 'GET /hooks/{{hookShortName}}/status': 'ExampleController.index'
20
+ }
21
+ };
22
+ },
23
+ configure(sails) {
24
+ const brandingDefaults = (sails.config.brandingConfigurationDefaults || {}) as SailsConfig['brandingConfigurationDefaults'];
25
+ brandingDefaults.menu = brandingConfigurationDefaults.menu as SailsConfig['brandingConfigurationDefaults']['menu'];
26
+ brandingDefaults.homePanels = brandingConfigurationDefaults.homePanels as SailsConfig['brandingConfigurationDefaults']['homePanels'];
27
+ sails.config.brandingConfigurationDefaults = brandingDefaults;
28
+ sails.config.reusableFormDefinitions = reusableFormDefinitions;
29
+ },
30
+ defaults: {
31
+ __configKey__: {
32
+ _hookTimeout: 120000
33
+ },
34
+ policies: {}
35
+ },
36
+ registerRedboxConfig(): Partial<SailsConfig> {
37
+ return {};
38
+ },
39
+ registerRedboxControllers(): HookRedboxControllers {
40
+ return require('./api/controllers').ControllerExports as HookRedboxControllers;
41
+ },
42
+ registerRedboxServices(): HookRedboxServices {
43
+ return require('./api/services').ServiceExports as HookRedboxServices;
44
+ },
45
+ registerRedboxFormConfigs(): Record<string, FormConfigFrame> {
46
+ return require('./form-config').FormConfigExports as Record<string, FormConfigFrame>;
47
+ },
48
+ additionalExports: {
49
+ ControllerExports: require('./api/controllers').ControllerExports,
50
+ ServiceExports: require('./api/services').ServiceExports,
51
+ FormConfigExports: require('./form-config').FormConfigExports
52
+ }
53
+ });
54
+
55
+ module.exports = hook;
@@ -0,0 +1,75 @@
1
+ networks:
2
+ main:
3
+
4
+ services:
5
+ rbportal:
6
+ build:
7
+ context: '../../..'
8
+ dockerfile: '{{packageName}}/Dockerfile'
9
+ target: '{{packageName}}'
10
+ ports:
11
+ - "1500:1500"
12
+ volumes:
13
+ - "../../:/opt/redbox-portal/node_modules/{{packageName}}"
14
+ - "../../../redbox-portal/packages/redbox-core:/opt/redbox-portal/packages/redbox-core"
15
+ - "../../../redbox-portal/packages/redbox-dev-tools:/opt/redbox-portal/packages/redbox-dev-tools"
16
+ - "../../../redbox-portal/packages/sails-ng-common:/opt/redbox-portal/packages/sails-ng-common"
17
+ - "../../../redbox-portal/.tmp/public/angular/form:/opt/redbox-portal/.tmp/public/angular/form"
18
+ - "../../../redbox-portal/.tmp/public/angular/local-auth:/opt/redbox-portal/.tmp/public/angular/local-auth"
19
+ - "../../../redbox-portal/.tmp/public/angular/export:/opt/redbox-portal/.tmp/public/angular/export"
20
+ - "../../../redbox-portal/.tmp/public/angular/dashboard:/opt/redbox-portal/.tmp/public/angular/dashboard"
21
+ - "../../../redbox-portal/.tmp/public/angular/report:/opt/redbox-portal/.tmp/public/angular/report"
22
+ - "../../../redbox-portal/.tmp/public/angular/manage-users:/opt/redbox-portal/.tmp/public/angular/manage-users"
23
+ - "../../../redbox-portal/.tmp/public/angular/admin-vocabulary:/opt/redbox-portal/.tmp/public/angular/admin-vocabulary"
24
+ - "../../../redbox-portal/.tmp/public/angular/manage-roles:/opt/redbox-portal/.tmp/public/angular/manage-roles"
25
+ - "../../../redbox-portal/.tmp/public/angular/app-config:/opt/redbox-portal/.tmp/public/angular/app-config"
26
+ - "../../../redbox-portal/.tmp/public/angular/deleted-records:/opt/redbox-portal/.tmp/public/angular/deleted-records"
27
+ - "../../../redbox-portal/.tmp/public/angular/branding:/opt/redbox-portal/.tmp/public/angular/branding"
28
+ - "../../../redbox-portal/.tmp/public/angular/translation:/opt/redbox-portal/.tmp/public/angular/translation"
29
+ - "../../../redbox-portal/.tmp/public/angular/record-search:/opt/redbox-portal/.tmp/public/angular/record-search"
30
+ - "./.tmp/attachments/staging:/attachments/staging"
31
+ expose:
32
+ - "1500"
33
+ environment:
34
+ - NODE_ENV=docker
35
+ - NODE_PATH=/opt/redbox-portal/node_modules:/opt/redbox-portal/node_modules/@researchdatabox/redbox-core/node_modules
36
+ - LOAD_DEFAULT_FORMS=true
37
+ - PORT=1500
38
+ - NODE_TLS_REJECT_UNAUTHORIZED=0
39
+ - sails_angularDev='true'
40
+ networks:
41
+ main:
42
+ aliases:
43
+ - rbportal
44
+ entrypoint: >-
45
+ /bin/bash -c "set -x;
46
+ cd /opt/redbox-portal &&
47
+ node --enable-source-maps app.js;"
48
+
49
+ mongodb:
50
+ image: mongo:7
51
+ networks:
52
+ main:
53
+ aliases:
54
+ - mongodb
55
+ ports:
56
+ - "27017:27017"
57
+ volumes:
58
+ - ".tmp/mongo:/data/db"
59
+
60
+ solr:
61
+ image: solr:8.11.1
62
+ networks:
63
+ main:
64
+ aliases:
65
+ - solr
66
+ expose:
67
+ - "8983"
68
+ ports:
69
+ - "8983:8983"
70
+ environment:
71
+ - SOLR_HOME=/var/solr/data
72
+ entrypoint:
73
+ - docker-entrypoint.sh
74
+ - solr-precreate
75
+ - redbox
@@ -0,0 +1,84 @@
1
+ networks:
2
+ main:
3
+
4
+ x-rbportal-env: &rbportal-env
5
+ - NODE_ENV=integrationtest
6
+ - NODE_PATH=/opt/redbox-portal/node_modules:/opt/redbox-portal/node_modules/@researchdatabox/redbox-core/node_modules
7
+ - PORT=1500
8
+ - sails_redbox__mochaTesting=true
9
+ - sails_security__csrf=false
10
+ - LOAD_DEFAULT_FORMS=true
11
+ - CI=${CI:-false}
12
+ - RBPORTAL_COVERAGE_DIR=/tmp/coverage/mocha
13
+
14
+ x-rbportal-depends: &rbportal-depends
15
+ mongodb:
16
+ condition: service_healthy
17
+ solr:
18
+ condition: service_healthy
19
+
20
+ services:
21
+ redboxportal:
22
+ build:
23
+ context: ../../..
24
+ dockerfile: {{packageName}}/Dockerfile
25
+ target: {{packageName}}
26
+ ports:
27
+ - "1500:1500"
28
+ volumes:
29
+ - "../../:/opt/redbox-portal/node_modules/{{packageName}}:delegated"
30
+ - "../../../redbox-portal/test:/opt/redbox-portal/test"
31
+ - "../../../redbox-portal/support/integration-testing:/opt/redbox-portal/support/integration-testing"
32
+ - "../../../redbox-portal/tsconfig.json:/opt/redbox-portal/tsconfig.json"
33
+ - "../../test/integration:/opt/redbox-portal/test/integration/{{integrationDirName}}"
34
+ - "../../../redbox-portal/packages/redbox-core:/opt/redbox-portal/packages/redbox-core"
35
+ - "../../../redbox-portal/packages/redbox-dev-tools:/opt/redbox-portal/packages/redbox-dev-tools"
36
+ - "../../../redbox-portal/packages/sails-ng-common:/opt/redbox-portal/packages/sails-ng-common"
37
+ depends_on: *rbportal-depends
38
+ expose:
39
+ - "1500"
40
+ environment: *rbportal-env
41
+ networks:
42
+ main:
43
+ aliases:
44
+ - redboxportal
45
+ init: true
46
+ entrypoint:
47
+ - bash
48
+ - /opt/redbox-portal/node_modules/{{packageName}}/support/integration-testing/run-mocha-hook.sh
49
+
50
+ mongodb:
51
+ image: mongo:7
52
+ networks:
53
+ main:
54
+ aliases:
55
+ - mongodb
56
+ ports:
57
+ - "27017:27017"
58
+ healthcheck:
59
+ test: ['CMD-SHELL', "echo 'db.runCommand(\"ping\").ok' | mongosh"]
60
+ interval: '10s'
61
+ timeout: '5s'
62
+ retries: 10
63
+ start_period: '30s'
64
+
65
+ solr:
66
+ image: solr:8.11.1
67
+ expose:
68
+ - "8983"
69
+ ports:
70
+ - "8983:8983"
71
+ healthcheck:
72
+ test: ['CMD-SHELL', 'curl http://localhost:8983']
73
+ interval: '10s'
74
+ timeout: '5s'
75
+ retries: 10
76
+ start_period: '30s'
77
+ networks:
78
+ main:
79
+ aliases:
80
+ - solr
81
+ entrypoint:
82
+ - docker-entrypoint.sh
83
+ - solr-precreate
84
+ - redbox
@@ -0,0 +1,9 @@
1
+ #!/usr/bin/env bash
2
+
3
+ set -euo pipefail
4
+
5
+ cd /opt/redbox-portal
6
+
7
+ export RBPORTAL_MOCHA_TEST_PATHS=${RBPORTAL_MOCHA_TEST_PATHS:-$'test/integration/{{integrationDirName}}/**/*.test.ts'}
8
+
9
+ exec bash /opt/redbox-portal/support/integration-testing/run-mocha-redbox.sh
@@ -0,0 +1,13 @@
1
+ const { expect, firstValueFrom } = require('@researchdatabox/redbox-dev-tools/testing');
2
+
3
+ describe('{{packageName}} integration', function () {
4
+ it('registers example services and form configs with the lifted portal', async function () {
5
+ expect(sails.services.exampleservice).to.exist;
6
+
7
+ const result = await firstValueFrom(sails.services.exampleservice.describe());
8
+ expect(result).to.deep.equal({ hook: '{{packageName}}', status: 'ready' });
9
+
10
+ const hookModule = require('{{packageName}}');
11
+ expect(hookModule.registerRedboxFormConfigs()).to.have.property('generated-view-only');
12
+ });
13
+ });
@@ -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,40 @@
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
+ expect(hookModule.registerRedboxConfig()).to.deep.equal({});
22
+ expect(hookModule.registerRedboxServices()).to.have.property('ExampleService');
23
+ expect(hookModule.registerRedboxControllers()).to.have.property('ExampleController');
24
+ expect(hookModule.registerRedboxFormConfigs()).to.have.property('generated-view-only');
25
+ expect(hookModule.registerFormConfig()).to.equal(hookModule.registerRedboxFormConfigs());
26
+
27
+ const result = await firstValueFrom(hookModule.registerRedboxServices().ExampleService.describe());
28
+ expect(result).to.deep.equal({ hook: '{{packageName}}', status: 'ready' });
29
+ });
30
+
31
+ it('applies reusable form definitions and branding defaults during configure', function () {
32
+ const hook = hookModule((global as any).sails);
33
+
34
+ hook.configure?.();
35
+
36
+ expect((global as any).sails.config.brandingConfigurationDefaults.menu).to.deep.equal({ items: [], showSearch: true });
37
+ expect((global as any).sails.config.brandingConfigurationDefaults.homePanels).to.deep.equal({ panels: [] });
38
+ expect((global as any).sails.config.reusableFormDefinitions).to.exist;
39
+ });
40
+ });
@@ -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');