@researchdatabox/redbox-dev-tools 0.0.1-beta.9950 → 5.0.0-RC1
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 +25 -3
- package/bin/wrapper-webpack.js +31 -12
- package/dist/cli.js +6 -2
- package/dist/commands/form-config.js +8 -11
- package/dist/commands/sync-translation.d.ts +23 -0
- package/dist/commands/sync-translation.js +348 -0
- package/dist/templates/hook-archetype.js +4 -3
- package/package.json +4 -4
- package/templates/hook-archetype/standard/.gitignore.hbs +1 -0
- package/templates/hook-archetype/standard/.npmignore.hbs +2 -1
- package/templates/hook-archetype/standard/AGENTS.md.hbs +18 -1
- package/templates/hook-archetype/standard/Dockerfile.hbs +12 -11
- package/templates/hook-archetype/standard/README.md.hbs +28 -10
- package/templates/hook-archetype/standard/assets/default/.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/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 +10 -6
- package/templates/hook-archetype/standard/src/index.ts.hbs +11 -11
- package/templates/hook-archetype/standard/src/migrations/index.ts.hbs +19 -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 +53 -20
- 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 +45 -11
- package/templates/hook-archetype/standard/support/integration-testing/run-mocha-hook.sh.hbs +5 -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 +3 -1
- package/templates/hook-archetype/standard/test/unit/index.test.ts.hbs +11 -5
- package/templates/hook-archetype/standard/views/default/.gitkeep +1 -0
|
@@ -0,0 +1,100 @@
|
|
|
1
|
+
#!/usr/bin/env bash
|
|
2
|
+
|
|
3
|
+
set -euo pipefail
|
|
4
|
+
set -o xtrace
|
|
5
|
+
|
|
6
|
+
cd /opt/redbox-portal
|
|
7
|
+
|
|
8
|
+
rm -rf /opt/redbox-portal/coverage/mocha/* || true
|
|
9
|
+
rm /opt/redbox-portal/.tmp/junit/backend-mocha/backend-mocha.xml || true
|
|
10
|
+
|
|
11
|
+
node_cmd=(node)
|
|
12
|
+
|
|
13
|
+
export TS_NODE_PROJECT=/opt/redbox-portal/tsconfig.json
|
|
14
|
+
export TS_NODE_TRANSPILE_ONLY=true
|
|
15
|
+
export TS_NODE_COMPILER_OPTIONS='{"module":"commonjs","moduleResolution":"node","esModuleInterop":true}'
|
|
16
|
+
|
|
17
|
+
export RBPORTAL_COVERAGE_DIR=${RBPORTAL_COVERAGE_DIR:-/tmp/coverage/mocha}
|
|
18
|
+
mkdir -p "$RBPORTAL_COVERAGE_DIR"
|
|
19
|
+
chmod 777 "$RBPORTAL_COVERAGE_DIR" || true
|
|
20
|
+
|
|
21
|
+
export NYC_OUTPUT=${NYC_OUTPUT:-/tmp/nyc_output}
|
|
22
|
+
mkdir -p "$NYC_OUTPUT"
|
|
23
|
+
chmod 777 "$NYC_OUTPUT" || true
|
|
24
|
+
|
|
25
|
+
test_args=()
|
|
26
|
+
if [[ -n "${RBPORTAL_MOCHA_TEST_PATHS:-}" ]]; then
|
|
27
|
+
mapfile -t env_test_args <<< "${RBPORTAL_MOCHA_TEST_PATHS}"
|
|
28
|
+
test_args+=("${env_test_args[@]}")
|
|
29
|
+
fi
|
|
30
|
+
|
|
31
|
+
if [[ ${#@} -gt 0 ]]; then
|
|
32
|
+
test_args+=("$@")
|
|
33
|
+
fi
|
|
34
|
+
|
|
35
|
+
if [[ ${#test_args[@]} -eq 0 ]]; then
|
|
36
|
+
test_args=(test/integration/**/*.test.ts)
|
|
37
|
+
fi
|
|
38
|
+
|
|
39
|
+
if [[ ! -x node_modules/.bin/mocha ]] || [[ ! -x node_modules/.bin/nyc ]]; then
|
|
40
|
+
echo "Test dependencies not found. Running npm install..."
|
|
41
|
+
npm install
|
|
42
|
+
fi
|
|
43
|
+
|
|
44
|
+
if [[ ! -f node_modules/redoc/bundles/redoc.standalone.js ]]; then
|
|
45
|
+
npm install --no-save --ignore-scripts --strict-peer-deps redoc@2.5.2
|
|
46
|
+
fi
|
|
47
|
+
|
|
48
|
+
npm run webpack
|
|
49
|
+
|
|
50
|
+
rm -rf node_modules/redoc node_modules/should
|
|
51
|
+
|
|
52
|
+
echo "Generating shims via redbox-core loader..."
|
|
53
|
+
node -e "
|
|
54
|
+
const { generateAllShims } = require('@researchdatabox/redbox-core');
|
|
55
|
+
generateAllShims(process.cwd(), {
|
|
56
|
+
forceRegenerate: true,
|
|
57
|
+
verbose: true
|
|
58
|
+
}).catch(err => {
|
|
59
|
+
console.error('Shim generation failed:', err);
|
|
60
|
+
process.exit(1);
|
|
61
|
+
});
|
|
62
|
+
"
|
|
63
|
+
|
|
64
|
+
bootstrap_test=test/bootstrap.test.ts
|
|
65
|
+
|
|
66
|
+
mocha_cmd=(node_modules/.bin/mocha)
|
|
67
|
+
nyc_cmd=(node_modules/.bin/nyc)
|
|
68
|
+
if [[ -n "${RBPORTAL_REMOTE_DEBUG:-}" ]]; then
|
|
69
|
+
nyc_cmd+=(--inspect="${RBPORTAL_REMOTE_DEBUG}")
|
|
70
|
+
fi
|
|
71
|
+
|
|
72
|
+
final_args=("${node_cmd[@]}" "${mocha_cmd[@]}")
|
|
73
|
+
|
|
74
|
+
mocha_config_args=()
|
|
75
|
+
if [[ -f test/integration/.mocharc.js ]]; then
|
|
76
|
+
mocha_config_args+=(--config test/integration/.mocharc.js)
|
|
77
|
+
else
|
|
78
|
+
mocha_config_args+=(
|
|
79
|
+
--require ts-node/register
|
|
80
|
+
--require chai
|
|
81
|
+
--extension ts,js
|
|
82
|
+
--recursive
|
|
83
|
+
--timeout 30s
|
|
84
|
+
--ui bdd
|
|
85
|
+
)
|
|
86
|
+
if [[ "${CI:-false}" == "true" ]]; then
|
|
87
|
+
mocha_config_args+=(--reporter mocha-junit-reporter --reporter-option mochaFile=./.tmp/junit/backend-mocha/backend-mocha.xml)
|
|
88
|
+
else
|
|
89
|
+
mocha_config_args+=(--reporter spec)
|
|
90
|
+
fi
|
|
91
|
+
fi
|
|
92
|
+
|
|
93
|
+
exec "${nyc_cmd[@]}" --no-clean \
|
|
94
|
+
--temp-dir "$NYC_OUTPUT" \
|
|
95
|
+
--report-dir "$RBPORTAL_COVERAGE_DIR" \
|
|
96
|
+
--reporter=lcov --exclude-after-remap=false \
|
|
97
|
+
"${final_args[@]}" \
|
|
98
|
+
\
|
|
99
|
+
"${mocha_config_args[@]}" \
|
|
100
|
+
--exit "${bootstrap_test}" "${test_args[@]}"
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
#! /bin/sh
|
|
2
|
+
MINIO_URL="${HOOK_S3_ENDPOINT:-http://minio:9000}"
|
|
3
|
+
MINIO_WAIT_SECONDS="${MINIO_WAIT_SECONDS:-180}"
|
|
4
|
+
|
|
5
|
+
wait_for_minio() {
|
|
6
|
+
echo "Waiting for MinIO at ${MINIO_URL}..."
|
|
7
|
+
for _ in $(seq 1 "${MINIO_WAIT_SECONDS}"); do
|
|
8
|
+
if curl -fsS "${MINIO_URL}/minio/health/ready" >/dev/null; then
|
|
9
|
+
return 0
|
|
10
|
+
fi
|
|
11
|
+
sleep 1
|
|
12
|
+
done
|
|
13
|
+
echo "MinIO did not become ready within ${MINIO_WAIT_SECONDS} seconds." >&2
|
|
14
|
+
return 1
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
ensure_mc() {
|
|
18
|
+
if [ ! -x /tmp/mc ]; then
|
|
19
|
+
case "$(uname -m)" in
|
|
20
|
+
x86_64) mc_arch=amd64 ;;
|
|
21
|
+
aarch64|arm64) mc_arch=arm64 ;;
|
|
22
|
+
*) echo "Unsupported architecture: $(uname -m)" >&2; return 1 ;;
|
|
23
|
+
esac
|
|
24
|
+
curl -fsSL -o /tmp/mc "https://dl.min.io/client/mc/release/linux-${mc_arch}/mc"
|
|
25
|
+
chmod +x /tmp/mc
|
|
26
|
+
fi
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
ensure_alias() {
|
|
30
|
+
/tmp/mc alias set local "${MINIO_URL}" "${HOOK_S3_ACCESS_KEY}" "${HOOK_S3_SECRET_KEY}" >/dev/null
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
ensure_bucket() {
|
|
34
|
+
if /tmp/mc stat "local/${HOOK_S3_BUCKET}" >/dev/null 2>&1; then
|
|
35
|
+
echo "Attachments bucket exists, skipping creation."
|
|
36
|
+
return 0
|
|
37
|
+
fi
|
|
38
|
+
|
|
39
|
+
/tmp/mc mb "local/${HOOK_S3_BUCKET}"
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
ensure_credentials() {
|
|
43
|
+
CREDS_DIR=/home/node/.aws
|
|
44
|
+
CREDS_FILE="${CREDS_DIR}/credentials"
|
|
45
|
+
DESIRED_CREDS_FILE=/tmp/minio-credentials
|
|
46
|
+
|
|
47
|
+
cat > "${DESIRED_CREDS_FILE}" <<EOF
|
|
48
|
+
[default]
|
|
49
|
+
aws_access_key_id = ${HOOK_S3_ACCESS_KEY}
|
|
50
|
+
aws_secret_access_key = ${HOOK_S3_SECRET_KEY}
|
|
51
|
+
EOF
|
|
52
|
+
|
|
53
|
+
mkdir -p "${CREDS_DIR}"
|
|
54
|
+
|
|
55
|
+
if [ -f "${CREDS_FILE}" ] && cmp -s "${CREDS_FILE}" "${DESIRED_CREDS_FILE}"; then
|
|
56
|
+
echo "Reusing existing credentials file: ${CREDS_FILE}"
|
|
57
|
+
rm -f "${DESIRED_CREDS_FILE}"
|
|
58
|
+
return 0
|
|
59
|
+
fi
|
|
60
|
+
|
|
61
|
+
echo "Writing credentials file: ${CREDS_FILE}"
|
|
62
|
+
mv "${DESIRED_CREDS_FILE}" "${CREDS_FILE}"
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
if [ -z "${HOOK_S3_BUCKET:-}" ]; then
|
|
66
|
+
echo "HOOK_S3_BUCKET is not set; skipping MinIO preparation."
|
|
67
|
+
exit 0
|
|
68
|
+
fi
|
|
69
|
+
|
|
70
|
+
ensure_mc
|
|
71
|
+
wait_for_minio
|
|
72
|
+
ensure_alias
|
|
73
|
+
ensure_bucket
|
|
74
|
+
ensure_credentials
|
|
@@ -1,13 +1,15 @@
|
|
|
1
1
|
const { expect, firstValueFrom } = require('@researchdatabox/redbox-dev-tools/testing');
|
|
2
2
|
|
|
3
3
|
describe('{{packageName}} integration', function () {
|
|
4
|
-
it('registers example services
|
|
4
|
+
it('registers example services, form configs, config, and migrations with the lifted portal', async function () {
|
|
5
5
|
expect(sails.services.exampleservice).to.exist;
|
|
6
6
|
|
|
7
7
|
const result = await firstValueFrom(sails.services.exampleservice.describe());
|
|
8
8
|
expect(result).to.deep.equal({ hook: '{{packageName}}', status: 'ready' });
|
|
9
9
|
|
|
10
10
|
const hookModule = require('{{packageName}}');
|
|
11
|
+
expect(hookModule.registerRedboxConfig()).to.have.property('brandingConfigurationDefaults');
|
|
11
12
|
expect(hookModule.registerRedboxFormConfigs()).to.have.property('generated-view-only');
|
|
13
|
+
expect(hookModule.registerRedboxMigrations()).to.deep.equal([]);
|
|
12
14
|
});
|
|
13
15
|
});
|
|
@@ -18,23 +18,29 @@ describe('hook entrypoint', function () {
|
|
|
18
18
|
});
|
|
19
19
|
|
|
20
20
|
it('exports the standard hook registrations and aliases', async function () {
|
|
21
|
-
|
|
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: [] });
|
|
22
27
|
expect(hookModule.registerRedboxServices()).to.have.property('ExampleService');
|
|
23
28
|
expect(hookModule.registerRedboxControllers()).to.have.property('ExampleController');
|
|
24
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());
|
|
25
32
|
expect(hookModule.registerFormConfig()).to.equal(hookModule.registerRedboxFormConfigs());
|
|
26
33
|
|
|
27
34
|
const result = await firstValueFrom(hookModule.registerRedboxServices().ExampleService.describe());
|
|
28
35
|
expect(result).to.deep.equal({ hook: '{{packageName}}', status: 'ready' });
|
|
29
36
|
});
|
|
30
37
|
|
|
31
|
-
it('
|
|
38
|
+
it('keeps configure empty while config is provided through registerRedboxConfig', function () {
|
|
32
39
|
const hook = hookModule((global as any).sails);
|
|
33
40
|
|
|
34
41
|
hook.configure?.();
|
|
35
42
|
|
|
36
|
-
expect((global as any).sails.config.brandingConfigurationDefaults
|
|
37
|
-
expect((global as any).sails.config.
|
|
38
|
-
expect((global as any).sails.config.reusableFormDefinitions).to.exist;
|
|
43
|
+
expect((global as any).sails.config.brandingConfigurationDefaults).to.deep.equal({});
|
|
44
|
+
expect((global as any).sails.config.reusableFormDefinitions).to.deep.equal({});
|
|
39
45
|
});
|
|
40
46
|
});
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
|