@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
package/README.md CHANGED
@@ -1,32 +1,277 @@
1
1
  # ReDBox Dev Tools
2
2
 
3
- A command line tool to assist with developing [ReDBox](https://www.redboxresearchdata.com.au) ([Sails.js](https://sailsjs.com)) hooks.
3
+ A development toolkit for creating and maintaining ReDBox customisation hooks.
4
+
5
+ ## Overview
6
+
7
+ The `@researchdatabox/redbox-dev-tools` package provides shared configuration, generators, and migration tooling for developing ReDBox hook projects. It ensures consistency across hook implementations and simplifies dependency management.
8
+
9
+ ## Features
10
+
11
+ - **Shared TypeScript configuration**: Pre-configured TypeScript settings and type definitions
12
+ - **Shared configuration**: Base `tsconfig.json` that follows ReDBox conventions
13
+ - **CLI scaffolding**: Quick project initialization with `npx`
14
+ - **Type safety**: Includes ReDBox core types as peer dependency
15
+ - **Version alignment**: Versioned to match ReDBox core releases
4
16
 
5
17
  ## Installation
6
18
 
7
- Install the tool using npm
19
+ ```bash
20
+ npm install --save-dev @researchdatabox/redbox-dev-tools
21
+ ```
22
+
23
+ ## Quick Start
24
+
25
+ Initialize a new hook project:
26
+
27
+ ```bash
28
+ npx @researchdatabox/redbox-dev-tools init redbox-hook-my-client
29
+ ```
30
+
31
+ This will:
32
+
33
+ - Generate the standard hook archetype in the current directory
34
+ - Create `src/`, `test/`, `support/`, `assets/`, `views/`, `language-defaults/`, and `support/bootstrap-data/`
35
+ - Create a `package.json` with the shared Redbox dependency contract
36
+ - Generate starter controller, service, form-config, config, migration registry, Docker, development, and test files
37
+
38
+ The standard archetype is based on the current hook structure used for migrated client hooks such as `redbox-hook-jcu` and `redbox-hook-cqu`, but stripped back to generic placeholders so a new client hook can start from the same shape without inheriting client-specific logic.
39
+
40
+ The archetype is now backed by file-based Handlebars templates under [templates/hook-archetype](templates/hook-archetype), which gives us a clean path for future variants such as branding-heavy hooks, lighter hooks, or alternate TypeScript setups.
41
+
42
+ ## TypeScript Configuration
43
+
44
+ Your hook project's `tsconfig.json` should extend the shared configuration:
45
+
46
+ ```json
47
+ {
48
+ "extends": "@researchdatabox/redbox-dev-tools/config/tsconfig.base.json",
49
+ "compilerOptions": {
50
+ "outDir": "./dist",
51
+ "typeRoots": ["node_modules/@types"]
52
+ },
53
+ "include": ["src/**/*.ts", "src/**/*.d.ts"]
54
+ }
55
+ ```
56
+
57
+ **Note:** Shared runtime path injection for packages such as `rxjs`, `axios`, `lodash`, and `@researchdatabox/sails-ng-common` is handled by the `run-hook-tsc` and `run-hook-mocha` entrypoints, not by hard-coded hook-local `paths` blocks.
58
+
59
+ ## Compiling TypeScript
60
+
61
+ Compile your TypeScript code using the toolchain provided by dev tools:
62
+
63
+ ```bash
64
+ node ./node_modules/@researchdatabox/redbox-dev-tools/bin/run-hook-tsc.js -p tsconfig.json
65
+ ```
66
+
67
+ Or add it to your `package.json` scripts:
68
+
69
+ ```json
70
+ {
71
+ "scripts": {
72
+ "compile": "node ./node_modules/@researchdatabox/redbox-dev-tools/bin/run-hook-tsc.js -p tsconfig.json"
73
+ }
74
+ }
75
+ ```
76
+
77
+ Then run:
78
+
79
+ ```bash
80
+ npm run compile
81
+ ```
82
+
83
+ ## Archetype Starter Files
84
+
85
+ ```typescript
86
+ import { defineRedboxHook } from '@researchdatabox/redbox-core';
87
+
88
+ const hook = defineRedboxHook({
89
+ registerRedboxControllers() {
90
+ return require('./api/controllers').ControllerExports;
91
+ },
92
+ registerRedboxServices() {
93
+ return require('./api/services').ServiceExports;
94
+ }
95
+ });
96
+
97
+ module.exports = hook;
98
+ ```
99
+
100
+ ## Shared Dependency Contract
101
+
102
+ Hooks should declare only:
103
+
104
+ - `peerDependencies.@researchdatabox/redbox-core`
105
+ - `devDependencies.@researchdatabox/redbox-core`
106
+ - `devDependencies.@researchdatabox/redbox-dev-tools`
107
+ - direct `dependencies` for hook-owned runtime libraries only
108
+
109
+ Do not directly declare shared Redbox runtime or toolchain packages in a hook if they are already supplied by the core or dev-tools contract. That includes `axios`, `rxjs`, `lodash`, `mocha`, `chai`, `ts-node`, and `typescript`.
110
+
111
+ `redbox-dev-tools` directly provides the shared hook authoring toolchain:
112
+
113
+ - `typescript`
114
+ - `ts-node`
115
+ - `mocha`
116
+ - `chai`
117
+ - `@types/node`
118
+ - `@types/mocha`
119
+ - `@types/chai`
120
+ - `@types/lodash`
121
+
122
+ For hook tests and authoring utilities, `redbox-dev-tools` also exposes shared resolution helpers via `@researchdatabox/redbox-dev-tools/testing` and `@researchdatabox/redbox-dev-tools/runtime-resolver`. These are for development-time use only. Hook runtime code should continue to import normal runtime packages such as `axios` and `rxjs` directly and rely on the Redbox host contract to provide them. The shared TypeScript config prefers resolving those runtime modules from the installed `@researchdatabox/redbox-core` dependency tree, and only falls back to the `redbox-dev-tools` install when package manager flattening hoists them there.
123
+
124
+ `@researchdatabox/redbox-core` is the runtime compatibility contract for hooks. It supplies the approved shared runtime dependency surface that hook authors may rely on implicitly, including `axios`, `rxjs`, and `lodash`.
125
+
126
+ ## Versioning
127
+
128
+ This package is versioned to match the ReDBox core release it supports. For example, version `4.5.1` is compatible with ReDBox Portal version `4.5.1`.
129
+
130
+ ## CLI Commands
131
+
132
+ ### `init`
133
+
134
+ Initialize a new ReDBox hook project from the standard archetype.
135
+
136
+ ```bash
137
+ npx @researchdatabox/redbox-dev-tools init redbox-hook-my-client
138
+ ```
139
+
140
+ Template variants are selected with `--template`:
141
+
142
+ ```bash
143
+ npx @researchdatabox/redbox-dev-tools init redbox-hook-my-client --template standard
144
+ ```
145
+
146
+ The generated project includes a typed migration registry under `src/migrations`, client customisation slots under `support/bootstrap-data`, `assets`, `views`, and `language-defaults`, and Docker-backed local development scripts:
147
+
148
+ ```bash
149
+ npm run dev:run:build
150
+ npm run dev:run
151
+ ```
152
+
153
+ To mount a local `redbox-portal` checkout while migrating a client hook, set `REDBOX_PORTAL_PATH` in `support/development/core-mount.env` and run:
154
+
155
+ ```bash
156
+ npm run dev:run:core
157
+ ```
158
+
159
+ ### `check`
160
+
161
+ Validate that the current hook package does not directly pin shared Redbox runtime or toolchain dependencies.
162
+
163
+ ```bash
164
+ npx @researchdatabox/redbox-dev-tools check
165
+ ```
166
+
167
+ ### `migrate-hook-dependencies`
168
+
169
+ Rewrite the current hook `package.json` to the minimal shared dependency contract.
170
+
171
+ ```bash
172
+ npx @researchdatabox/redbox-dev-tools migrate-hook-dependencies
173
+ ```
174
+
175
+ ### `install-skills`
176
+
177
+ Install the bundled agent skills using the `vercel-labs/skills` CLI. Bundled agent skills are curated prompt packs that teach supported agents how to work with ReDBox conventions, file layouts, and workflows. Install them to enable consistent, repo-aware assistance from your agent.
178
+
179
+ Prerequisites
180
+
181
+ - Install the external Skills CLI: `npx @vercel/skills --help` (or follow the install instructions in the Skills docs).
182
+ - Authenticate if required by your agent runtime (some agents prompt for login on first run).
183
+
184
+ Usage
185
+
186
+ - `-a <agent>`: Target agent runtime (for example `claude-code`).
187
+ - `--skill <pattern>`: Skill name or glob pattern (for example `redbox-*` or `*`).
188
+ - Skills are optional but recommended for consistent guidance and guardrails.
189
+
190
+ This will:
191
+
192
+ - Copy the bundled skill definitions from this package into the Skills CLI workspace.
193
+ - Register the skills for the specified agent runtime.
194
+ - Make the skills available for subsequent agent sessions.
195
+
196
+ ```bash
197
+ npx @researchdatabox/redbox-dev-tools install-skills -a claude-code --skill 'redbox-*'
198
+ ```
199
+
200
+ For advanced options, see the `vercel-labs/skills` documentation: https://github.com/vercel-labs/skills
201
+
202
+ ### `migrate-form-config`
203
+
204
+ Migrate a legacy v4 JavaScript form config to the v5 TypeScript form framework format.
205
+
206
+ ```bash
207
+ npx @researchdatabox/redbox-dev-tools migrate-form-config \
208
+ --input /path/to/legacy-form.js \
209
+ --output /path/to/migrated-form.ts
210
+ ```
211
+
212
+ ### `generate form-component`
213
+
214
+ Generate end-to-end scaffold for a new form component in Angular and `sails-ng-common`.
215
+
216
+ ```bash
217
+ npx @researchdatabox/redbox-dev-tools generate form-component my-widget --app form
218
+ ```
219
+
220
+ Optional Angular service scaffold:
221
+
222
+ ```bash
223
+ npx @researchdatabox/redbox-dev-tools generate form-component my-widget --app form --with-service
224
+ ```
225
+
226
+ ### `sync-translation`
227
+
228
+ Read translations from API and write to language defaults files.
229
+
230
+ ```bash
231
+ npx @researchdatabox/redbox-dev-tools sync-translation -a "https://example.com" -l ~/redbox-portal/language-defaults
232
+ ```
233
+
234
+ ### `help`
235
+
236
+ Show CLI help and usage information.
8
237
 
9
- ```$ npm install @researchdatabox/redbox-dev-tools```
238
+ ```bash
239
+ npx @researchdatabox/redbox-dev-tools help
240
+ ```
10
241
 
11
- ## Usage
242
+ ### `completion`
12
243
 
13
- ```$ redbox-dev-tools <command> <options>```
244
+ Output shell completion scripts for `bash`, `zsh`, `fish`, and `powershell`.
14
245
 
15
- ### Available Commands
246
+ ```bash
247
+ npx @researchdatabox/redbox-dev-tools completion <shell>
248
+ ```
16
249
 
17
- **init** Initialises a hook code project ready for development
250
+ Install examples:
18
251
 
19
- **help** Shows this help message or help for a specific command
252
+ ```bash
253
+ # bash
254
+ npx @researchdatabox/redbox-dev-tools completion bash > ~/.local/share/bash-completion/completions/redbox-dev-tools
20
255
 
256
+ # zsh
257
+ mkdir -p ~/.zsh/completions
258
+ npx @researchdatabox/redbox-dev-tools completion zsh > ~/.zsh/completions/_redbox-dev-tools
259
+ # then ensure your ~/.zshrc includes:
260
+ # fpath=(~/.zsh/completions $fpath)
261
+ # autoload -U compinit && compinit
21
262
 
22
- ## Commands
263
+ # fish
264
+ npx @researchdatabox/redbox-dev-tools completion fish > ~/.config/fish/completions/redbox-dev-tools.fish
23
265
 
24
- ### Initialise Hook Code Project
266
+ # powershell
267
+ npx @researchdatabox/redbox-dev-tools completion powershell > ~/.config/powershell/redbox-dev-tools-completion.ps1
268
+ # then source it from your PowerShell profile
269
+ ```
25
270
 
26
- #### Usage
27
- ```$ redbox-dev-tools init -p <hook name>```
271
+ ## Contributing
28
272
 
29
- #### Flags
273
+ See the main [ReDBox Portal repository](https://github.com/redbox-mint/redbox-portal) for contribution guidelines.
30
274
 
31
- **-p**, **--packageName** <u>name</u> The NPM package name for the sails hook.
275
+ ## License
32
276
 
277
+ ISC
package/bin/cli.js ADDED
@@ -0,0 +1,3 @@
1
+ #!/usr/bin/env node
2
+
3
+ require('../dist/cli.js');
@@ -0,0 +1,3 @@
1
+ #!/usr/bin/env node
2
+
3
+ require('../dist/bin/run-hook-mocha.js');
@@ -0,0 +1,3 @@
1
+ #!/usr/bin/env node
2
+
3
+ require('../dist/bin/run-hook-tsc.js');
@@ -0,0 +1,168 @@
1
+ // This file is a helper for dev only. It makes it easier to run webpack when parts of the mono repo are in different stages of being built. Refer to the redbox-core webpack.ts for how the hook runs webpack
2
+ const path = require('path');
3
+ const { createRequire } = require('module');
4
+
5
+ const requireFromHere = createRequire(__filename);
6
+ let redboxCore;
7
+
8
+ const getRedboxCore = () => {
9
+ if (redboxCore !== undefined) {
10
+ return redboxCore;
11
+ }
12
+
13
+ try {
14
+ redboxCore = require('@researchdatabox/redbox-core');
15
+ } catch (e) {
16
+ redboxCore = null;
17
+ }
18
+
19
+ return redboxCore;
20
+ };
21
+
22
+ const ensureTsNode = () => {
23
+ try {
24
+ require('ts-node/register/transpile-only');
25
+ return true;
26
+ } catch (e) {
27
+ return false;
28
+ }
29
+ };
30
+
31
+ let defineWebpackHook;
32
+ if (!defineWebpackHook) {
33
+ try {
34
+ defineWebpackHook = require('@researchdatabox/redbox-core/dist/hooks/webpack').defineWebpackHook;
35
+ } catch (e) {}
36
+ }
37
+ if (!defineWebpackHook && ensureTsNode()) {
38
+ try {
39
+ defineWebpackHook = requireFromHere('@researchdatabox/redbox-core/src/hooks/webpack.ts').defineWebpackHook;
40
+ } catch (e) {}
41
+ }
42
+ if (!defineWebpackHook) {
43
+ const core = getRedboxCore();
44
+ defineWebpackHook = core && (core.defineWebpackHook || (core.default && core.default.defineWebpackHook));
45
+ }
46
+
47
+ // Resolve webpack config: prefer exported `Config.webpack.config`, fall back to repo `config/webpack.js`.
48
+ let webpackConfig = [];
49
+ try {
50
+ // prefer repo config file
51
+ const repoWebpack = require(path.resolve(process.cwd(), 'config/webpack'));
52
+ if (repoWebpack && repoWebpack.webpack) {
53
+ webpackConfig = repoWebpack.webpack.config ? repoWebpack.webpack.config : repoWebpack.webpack;
54
+ } else {
55
+ webpackConfig = repoWebpack && repoWebpack.config ? repoWebpack.config : repoWebpack;
56
+ }
57
+ } catch (e) {
58
+ // ignore
59
+ }
60
+ if (!webpackConfig || (Array.isArray(webpackConfig) && webpackConfig.length === 0)) {
61
+ try {
62
+ const distWebpack = require('@researchdatabox/redbox-core/dist/config/webpack.config');
63
+ webpackConfig = distWebpack && distWebpack.webpack ? distWebpack.webpack.config : distWebpack.config || distWebpack;
64
+ } catch (e) {}
65
+ }
66
+ if (!webpackConfig || (Array.isArray(webpackConfig) && webpackConfig.length === 0)) {
67
+ if (ensureTsNode()) {
68
+ try {
69
+ const srcWebpack = requireFromHere('@researchdatabox/redbox-core/src/config/webpack.config.ts');
70
+ webpackConfig = srcWebpack && srcWebpack.webpack ? srcWebpack.webpack.config : srcWebpack.config || srcWebpack;
71
+ } catch (e) {}
72
+ }
73
+ }
74
+ if (!webpackConfig || (Array.isArray(webpackConfig) && webpackConfig.length === 0)) {
75
+ try {
76
+ const core = getRedboxCore();
77
+ const Config = core && (core.Config || (core.default && core.default.Config));
78
+ if (Config && Config.webpack && Config.webpack.config) {
79
+ webpackConfig = Config.webpack.config;
80
+ }
81
+ } catch (e) {
82
+ // ignore
83
+ }
84
+ }
85
+
86
+ sails = {
87
+ config: {
88
+ webpack: {
89
+ config: webpackConfig,
90
+ },
91
+ },
92
+ log: {
93
+ info: function (msg, data = null) {
94
+ console.info(msg, data);
95
+ },
96
+ warn: function (msg, data = null) {
97
+ console.warn(msg, data);
98
+ },
99
+ error: function (msg, data = null) {
100
+ console.error(msg, data);
101
+ },
102
+ },
103
+ };
104
+ async function main() {
105
+ if (!defineWebpackHook) {
106
+ console.warn('defineWebpackHook not available from @researchdatabox/redbox-core; running webpack directly');
107
+ // Fallback: run webpack directly using resolved config
108
+ const webpack = require('webpack');
109
+
110
+ if (!sails.config.webpack) {
111
+ sails.log.warn('sails-hook-webpack: No Webpack options have been defined.');
112
+ return;
113
+ }
114
+
115
+ if (
116
+ !sails.config.webpack.config ||
117
+ (Array.isArray(sails.config.webpack.config) && sails.config.webpack.config.length === 0)
118
+ ) {
119
+ sails.log.warn('sails-hook-webpack: Configure your config/webpack.js file.');
120
+ return;
121
+ }
122
+
123
+ if (process.env.NODE_ENV !== 'docker' || process.env.WEBPACK_SKIP === 'true') {
124
+ sails.log.warn(`sails-hook-webpack: Configured to skip webpack.`);
125
+ return;
126
+ }
127
+
128
+ if (process.env.WEBPACK_CSS_MINI === 'true') {
129
+ try {
130
+ sails.config.webpack.config[0].optimization.minimize = true;
131
+ sails.log.info(`Webpack wrapper is configured for CSS minimization.`);
132
+ } catch (e) {}
133
+ }
134
+
135
+ const compiler = webpack(sails.config.webpack.config);
136
+
137
+ const logCompileInfo = (err, stats) => {
138
+ if (err) {
139
+ sails.log.error('sails-hook-webpack: Build error: \n\n', err);
140
+ }
141
+ try {
142
+ sails.log[stats.hasErrors() ? 'error' : 'info'](
143
+ `sails-hook-webpack:\n${stats.toString({ colors: true, chunks: true })}`
144
+ );
145
+ } catch (e) {}
146
+ };
147
+
148
+ let called = false;
149
+ const compileCallback = (err, stats) => {
150
+ logCompileInfo(err, stats);
151
+ if (called) return;
152
+ called = true;
153
+ if (err || (stats && stats.hasErrors && stats.hasErrors())) {
154
+ console.error(err || stats.toString());
155
+ throw new Error('sails-hook-webpack failed');
156
+ }
157
+ console.log('Webpack wrapper done!');
158
+ };
159
+
160
+ compiler.run(compileCallback);
161
+ return;
162
+ }
163
+ await defineWebpackHook(sails).initialize(() => {
164
+ console.log('Webpack wrapper done!');
165
+ });
166
+ }
167
+
168
+ main();
@@ -0,0 +1,16 @@
1
+ {
2
+ "extends": "@tsconfig/node24/tsconfig.json",
3
+ "compilerOptions": {
4
+ "target": "ES2024",
5
+ "lib": ["ES2024"],
6
+ "module": "nodenext",
7
+ "moduleResolution": "nodenext",
8
+ "esModuleInterop": true,
9
+ "forceConsistentCasingInFileNames": true,
10
+ "skipLibCheck": true,
11
+ "types": ["node"],
12
+ "inlineSourceMap": true,
13
+ "experimentalDecorators": true,
14
+ "emitDecoratorMetadata": true
15
+ }
16
+ }
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,49 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ const module_1 = __importDefault(require("module"));
7
+ const path_1 = __importDefault(require("path"));
8
+ const child_process_1 = require("child_process");
9
+ const typescript_1 = __importDefault(require("typescript"));
10
+ const hook_tsconfig_1 = require("../utils/hook-tsconfig");
11
+ function getResolvedCompilerOptions(projectPath) {
12
+ const resolvedProjectPath = path_1.default.resolve(process.cwd(), projectPath);
13
+ const configFile = typescript_1.default.readConfigFile(resolvedProjectPath, typescript_1.default.sys.readFile);
14
+ if (configFile.error) {
15
+ throw new Error(typescript_1.default.flattenDiagnosticMessageText(configFile.error.messageText, '\n'));
16
+ }
17
+ const parsedConfig = typescript_1.default.parseJsonConfigFileContent(configFile.config, typescript_1.default.sys, path_1.default.dirname(resolvedProjectPath), undefined, resolvedProjectPath);
18
+ if (parsedConfig.errors.length > 0) {
19
+ throw new Error(typescript_1.default.flattenDiagnosticMessageText(parsedConfig.errors[0].messageText, '\n'));
20
+ }
21
+ const convertedConfig = typescript_1.default.convertToTSConfig(parsedConfig, resolvedProjectPath, typescript_1.default.sys);
22
+ return convertedConfig.compilerOptions ?? {};
23
+ }
24
+ const redboxCorePackageJson = require.resolve('@researchdatabox/redbox-core/package.json');
25
+ const redboxCoreDir = path_1.default.dirname(redboxCorePackageJson);
26
+ const workspaceNodeModules = path_1.default.resolve(redboxCoreDir, '..', '..', 'node_modules');
27
+ const coreNodeModules = path_1.default.join(redboxCoreDir, 'node_modules');
28
+ const existingNodePath = process.env.NODE_PATH ? process.env.NODE_PATH.split(path_1.default.delimiter) : [];
29
+ const tsNodeProject = process.env.TS_NODE_PROJECT ?? 'tsconfig.json';
30
+ const existingCompilerOptions = process.env.TS_NODE_COMPILER_OPTIONS
31
+ ? JSON.parse(process.env.TS_NODE_COMPILER_OPTIONS)
32
+ : {};
33
+ const resolvedCompilerOptions = getResolvedCompilerOptions(tsNodeProject);
34
+ const hookCompilerOptions = (0, hook_tsconfig_1.createHookCompilerOptions)(tsNodeProject);
35
+ process.env.NODE_PATH = [workspaceNodeModules, coreNodeModules, ...existingNodePath]
36
+ .filter((value, index, values) => value && values.indexOf(value) === index)
37
+ .join(path_1.default.delimiter);
38
+ process.env.TS_NODE_SKIP_PROJECT = 'true';
39
+ process.env.TS_NODE_COMPILER_OPTIONS = JSON.stringify({
40
+ ...resolvedCompilerOptions,
41
+ ...existingCompilerOptions,
42
+ ...hookCompilerOptions,
43
+ });
44
+ module_1.default._initPaths();
45
+ const result = (0, child_process_1.spawnSync)(process.execPath, [require.resolve('mocha/bin/mocha.js'), ...process.argv.slice(2)], {
46
+ stdio: 'inherit',
47
+ env: process.env,
48
+ });
49
+ process.exit(result.status ?? 1);
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,19 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const child_process_1 = require("child_process");
4
+ const hook_tsconfig_1 = require("../utils/hook-tsconfig");
5
+ const args = [...process.argv.slice(2)];
6
+ const projectArgIndex = args.findIndex(arg => arg === '-p' || arg === '--project');
7
+ const projectPath = projectArgIndex >= 0 ? args[projectArgIndex + 1] : 'tsconfig.json';
8
+ const tempTsconfigPath = (0, hook_tsconfig_1.createHookTsConfig)(projectPath ?? 'tsconfig.json');
9
+ if (projectArgIndex >= 0) {
10
+ args.splice(projectArgIndex, 2, '-p', tempTsconfigPath);
11
+ }
12
+ else {
13
+ args.unshift('-p', tempTsconfigPath);
14
+ }
15
+ const result = (0, child_process_1.spawnSync)(process.execPath, [require.resolve('typescript/bin/tsc'), ...args], {
16
+ stdio: 'inherit',
17
+ });
18
+ (0, hook_tsconfig_1.cleanupHookTsConfig)(tempTsconfigPath);
19
+ process.exit(result.status ?? 1);
@@ -0,0 +1,9 @@
1
+ import { RouteMapping } from './generators/controller';
2
+ import { ModelAttribute, ModelAssociation } from './generators/model';
3
+ import { NavigationMapping, LanguageDefaultEntry } from './utils/config-helper';
4
+ export declare function parseAttributes(val: string): ModelAttribute[];
5
+ export declare function parseRoutes(val: string): RouteMapping[];
6
+ export declare function parseNavMappings(val: string): NavigationMapping[];
7
+ export declare function parseLanguageDefaults(val: string): LanguageDefaultEntry[];
8
+ export declare function parseBelongsTo(val: string): ModelAssociation[];
9
+ export declare function parseHasMany(val: string): ModelAssociation[];