@abgov/nx-adsp 13.7.0 → 13.7.2
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 +26 -3
- package/package.json +2 -1
- package/src/generators/express-service/express-service.js +10 -10
- package/src/generators/express-service/express-service.js.map +1 -1
- package/src/generators/express-service/express-service.spec.ts +58 -0
- package/src/generators/express-service/files/AGENTS.md__tmpl__ +12 -3
- package/src/generators/express-service/files/src/environment.ts__tmpl__ +3 -3
- package/src/generators/express-service/files/src/routes/example.ts__tmpl__ +5 -1
- package/src/generators/express-service/files-mongo/.env.example__tmpl__ +8 -4
- package/src/generators/express-service/files-mongo/scripts/dev-db.sh__tmpl__ +8 -3
- package/src/generators/express-service/files-postgres/.env.example__tmpl__ +8 -4
- package/src/generators/express-service/files-postgres/scripts/dev-db.sh__tmpl__ +8 -3
- package/src/generators/vue-app/files/src/App.spec.ts__tmpl__ +17 -2
- package/src/generators/vue-components/vue-components.js +22 -13
- package/src/generators/vue-components/vue-components.js.map +1 -1
- package/src/generators/vue-components/vue-components.spec.ts +22 -0
package/README.md
CHANGED
|
@@ -55,8 +55,9 @@ authenticated as an account with **`write:packages`** on your registry org.
|
|
|
55
55
|
> option (name, `--env`, `--sandboxProject`, etc.) supplied — otherwise Nx prompts
|
|
56
56
|
> and your session hangs waiting for input. Setting `CI=true` in the env has the
|
|
57
57
|
> same effect and also skips the Nx Cloud prompt. (`nx run <target>` executors
|
|
58
|
-
> don't prompt — this only applies to `nx g` generators.)
|
|
59
|
-
>
|
|
58
|
+
> don't prompt — this only applies to `nx g` generators.) Also pass `--skipAgent`
|
|
59
|
+
> — see [Agent consultation](#agent-consultation) for why you want to, not just
|
|
60
|
+
> how. The commands below already follow this.
|
|
60
61
|
|
|
61
62
|
```bash
|
|
62
63
|
# 1. Empty folder → Nx workspace (the plugins require Nx 23)
|
|
@@ -71,7 +72,7 @@ npm i -D @abgov/nx-oc @abgov/nx-adsp "@nx/express@$NXV" "@nx/vue@$NXV" "@nx/node
|
|
|
71
72
|
npx @abgov/adsp-cli login --env test --tenant "<Your Tenant>" --scope adsp-cli-admin
|
|
72
73
|
|
|
73
74
|
# 4. Scaffold a Postgres + Express + Vue + Node solution
|
|
74
|
-
npx nx g @abgov/nx-adsp:pevn acme --env=dev --tenant=my-tenant --no-interactive
|
|
75
|
+
npx nx g @abgov/nx-adsp:pevn acme --env=dev --tenant=my-tenant --no-interactive --skipAgent
|
|
75
76
|
|
|
76
77
|
# 5. Add sandbox targets (registry derives from the git remote, or pass --registry=ghcr.io/<org>;
|
|
77
78
|
# the database is auto-detected from the service — no --database needed)
|
|
@@ -225,6 +226,28 @@ Generator flags that steer which tenant/token is used:
|
|
|
225
226
|
|
|
226
227
|
With none of these, the generator lets `adsp login`'s interactive picker resolve the tenant.
|
|
227
228
|
|
|
229
|
+
## Agent consultation
|
|
230
|
+
|
|
231
|
+
`express-service`, `react-app`, `angular-app`, `vue-app`, and the fullstack composites connect to
|
|
232
|
+
ADSP's own `agent-service` after base scaffolding and hold an interactive, multi-turn conversation
|
|
233
|
+
with an ADSP-aware agent that can read and modify key integration files (`main.ts`,
|
|
234
|
+
`environment.ts`, `events.ts`, `database.ts`) based on a description you provide. The socket
|
|
235
|
+
connection and file upload start immediately, in parallel with prompting for that description.
|
|
236
|
+
|
|
237
|
+
This needs the same tenant/token as [Authentication](#authentication) above, plus a reachable
|
|
238
|
+
`agent-service` — it falls back silently to base scaffolding if either is missing, or if the run
|
|
239
|
+
is non-interactive (`--no-interactive`, no TTY, or `CI=true`). Skip it explicitly with
|
|
240
|
+
`--skipAgent`, regardless of interactivity.
|
|
241
|
+
|
|
242
|
+
> **Note for coding agents:** skip this. It exists to let a *human* describe what they want built
|
|
243
|
+
> to a separate, remote agent working from nothing but that description. You already have the
|
|
244
|
+
> actual requirements and the surrounding codebase context that conversation exists to gather —
|
|
245
|
+
> make any needed customizations directly, after scaffolding, rather than through an indirect
|
|
246
|
+
> round-trip to a second, less-informed agent. Pass `--skipAgent` explicitly rather than relying
|
|
247
|
+
> on `--no-interactive` alone: `--skipAgent` is a plain option check at the generator level, while
|
|
248
|
+
> `--no-interactive`'s detection is built on argv inspection this plugin's own code notes could go
|
|
249
|
+
> stale on an Nx upgrade — belt and suspenders, not a real behavior difference today.
|
|
250
|
+
|
|
228
251
|
## nx-oc integration
|
|
229
252
|
|
|
230
253
|
If `@abgov/nx-oc` is installed in the workspace, the quickstart generators (`express-service`, `react-app`, `angular-app`, `dotnet-service`, `react-dotnet`) automatically include OpenShift deployment YAML in their output. See the [@abgov/nx-oc README](../nx-oc/README.md) for details.
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@abgov/nx-adsp",
|
|
3
|
-
"version": "13.7.
|
|
3
|
+
"version": "13.7.2",
|
|
4
4
|
"license": "Apache-2.0",
|
|
5
5
|
"main": "src/index.js",
|
|
6
6
|
"description": "Government of Alberta - Nx plugin for ADSP apps.",
|
|
@@ -18,6 +18,7 @@
|
|
|
18
18
|
"@nx/express": "^23.0.0",
|
|
19
19
|
"@nx/react": "^23.0.0",
|
|
20
20
|
"@nx/vue": "^23.0.0",
|
|
21
|
+
"eslint": "^8.0.0 || ^9.0.0 || ^10.0.0",
|
|
21
22
|
"tslib": "^2.0.0"
|
|
22
23
|
},
|
|
23
24
|
"peerDependenciesMeta": {
|
|
@@ -135,17 +135,17 @@ function default_1(host, options) {
|
|
|
135
135
|
const accessToken = (_f = normalizedOptions.accessToken) !== null && _f !== void 0 ? _f : normalizedOptions.adsp.accessToken;
|
|
136
136
|
const clientSecret = yield (0, keycloak_admin_1.ensureServiceClient)(normalizedOptions.adsp.accessServiceUrl, normalizedOptions.adsp.tenantRealm, clientId, accessToken);
|
|
137
137
|
if (clientSecret) {
|
|
138
|
-
|
|
139
|
-
|
|
138
|
+
// .env.local, not .env: CLIENT_SECRET is a generated, local-only value — the
|
|
139
|
+
// same tier `nx dev-db` already uses for DATABASE_URL/MONGODB_URI — and
|
|
140
|
+
// already unconditionally gitignored by create-nx-workspace's default
|
|
141
|
+
// .gitignore (.env.local, .env.*.local), so no gitignore management is
|
|
142
|
+
// needed here at all. .env itself is left alone: it holds non-secret,
|
|
143
|
+
// developer-owned config too (KEYCLOAK_ROOT_URL, DIRECTORY_URL, etc.) and
|
|
144
|
+
// shouldn't be blanket-gitignored.
|
|
145
|
+
const envLocalPath = `${normalizedOptions.projectRoot}/.env.local`;
|
|
146
|
+
const existing = host.exists(envLocalPath) ? host.read(envLocalPath).toString() : '';
|
|
140
147
|
if (!existing.includes('CLIENT_SECRET=')) {
|
|
141
|
-
host.write(
|
|
142
|
-
}
|
|
143
|
-
const gitignorePath = '.gitignore';
|
|
144
|
-
if (host.exists(gitignorePath)) {
|
|
145
|
-
const gitignoreContent = host.read(gitignorePath).toString();
|
|
146
|
-
if (!gitignoreContent.includes('.env')) {
|
|
147
|
-
host.write(gitignorePath, `${gitignoreContent.trimEnd()}\n${normalizedOptions.projectRoot}/.env\n`);
|
|
148
|
-
}
|
|
148
|
+
host.write(envLocalPath, `${existing ? existing.trimEnd() + '\n' : ''}CLIENT_SECRET=${clientSecret}\n`);
|
|
149
149
|
}
|
|
150
150
|
}
|
|
151
151
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"express-service.js","sourceRoot":"","sources":["../../../../../../packages/nx-adsp/src/generators/express-service/express-service.ts"],"names":[],"mappings":";;AAsGA,4BAkOC;;AAxUD,wCAA0I;AAC1I,uCAUoB;AACpB,uCAAoC;AACpC,6BAA6B;AAC7B,6CAAiD;AACjD,+DAAiE;AACjE,+DAA4D;AAC5D,iDAA0I;AAG1I,SAAe,gBAAgB,CAC7B,IAAU,EACV,OAAe;;;QAEf,MAAM,WAAW,GAAG,IAAA,cAAK,EAAC,OAAO,CAAC,IAAI,CAAC,CAAC,QAAQ,CAAC;QACjD,MAAM,WAAW,GAAG,GAAG,IAAA,2BAAkB,EAAC,IAAI,CAAC,C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CAAC;YACzC,CAAC,CAAC,CAAC,GAAG,CAAC,MAAA,aAAa,CAAC,IAAI,mCAAI,EAAE,CAAC,EAAE,KAAK,CAAC;YACxC,CAAC,CAAC,aAAa,CAAC,IAAI,CAAC;QAEzB,IAAA,mCAA0B,EAAC,IAAI,EAAE,iBAAiB,CAAC,WAAW,kCACzD,aAAa,KAChB,OAAO;YACP,IAAI,IACJ,CAAC;QAEH,IAAA,0BAAgB,EAAC,IAAI,EAAE,iBAAiB,CAAC,WAAW,CAAC,CAAC;QACtD,MAAM,IAAA,oBAAW,EAAC,IAAI,CAAC,CAAC;QAExB,IAAI,iBAAiB,CAAC,IAAI,EAAE,CAAC;YAC3B,MAAM,QAAQ,GAAG,WAAW,iBAAiB,CAAC,IAAI,CAAC,MAAM,IAAI,iBAAiB,CAAC,WAAW,EAAE,CAAC;YAC7F,MAAM,WAAW,GAAG,MAAA,iBAAiB,CAAC,WAAW,mCAAI,iBAAiB,CAAC,IAAI,CAAC,WAAW,CAAC;YACxF,MAAM,YAAY,GAAG,MAAM,IAAA,oCAAmB,EAC5C,iBAAiB,CAAC,IAAI,CAAC,gBAAgB,EACvC,iBAAiB,CAAC,IAAI,CAAC,WAAW,EAClC,QAAQ,EACR,WAAW,CACZ,CAAC;YACF,IAAI,YAAY,EAAE,CAAC;gBACjB,MAAM,
|
|
1
|
+
{"version":3,"file":"express-service.js","sourceRoot":"","sources":["../../../../../../packages/nx-adsp/src/generators/express-service/express-service.ts"],"names":[],"mappings":";;AAsGA,4BAkOC;;AAxUD,wCAA0I;AAC1I,uCAUoB;AACpB,uCAAoC;AACpC,6BAA6B;AAC7B,6CAAiD;AACjD,+DAAiE;AACjE,+DAA4D;AAC5D,iDAA0I;AAG1I,SAAe,gBAAgB,CAC7B,IAAU,EACV,OAAe;;;QAEf,MAAM,WAAW,GAAG,IAAA,cAAK,EAAC,OAAO,CAAC,IAAI,CAAC,CAAC,QAAQ,CAAC;QACjD,MAAM,WAAW,GAAG,GAAG,IAAA,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testing';
|
|
|
3
3
|
|
|
4
4
|
import * as utils from '@abgov/nx-oc';
|
|
5
5
|
import { environments } from '@abgov/nx-oc';
|
|
6
|
+
import * as keycloakAdmin from '../../utils/keycloak-admin';
|
|
6
7
|
import { Schema } from './schema';
|
|
7
8
|
import generator from './express-service';
|
|
8
9
|
|
|
@@ -17,6 +18,9 @@ utilsMock.getAdspConfiguration.mockResolvedValue({
|
|
|
17
18
|
utilsMock.deploymentGenerator.mockResolvedValue(undefined);
|
|
18
19
|
utilsMock.ensureAdspToken.mockResolvedValue('test-token');
|
|
19
20
|
|
|
21
|
+
jest.mock('../../utils/keycloak-admin');
|
|
22
|
+
const keycloakAdminMock = keycloakAdmin as jest.Mocked<typeof keycloakAdmin>;
|
|
23
|
+
|
|
20
24
|
describe('Express Service Generator', () => {
|
|
21
25
|
const options: Schema = {
|
|
22
26
|
name: 'test',
|
|
@@ -168,4 +172,58 @@ describe('Express Service Generator', () => {
|
|
|
168
172
|
false
|
|
169
173
|
);
|
|
170
174
|
}, 60000);
|
|
175
|
+
|
|
176
|
+
it('writes a provisioned CLIENT_SECRET to .env.local, not .env', async () => {
|
|
177
|
+
keycloakAdminMock.ensureServiceClient.mockResolvedValueOnce('super-secret');
|
|
178
|
+
const host = createTreeWithEmptyWorkspace({ layout: 'apps-libs' });
|
|
179
|
+
await generator(host, { ...options, accessToken: 'test-token' });
|
|
180
|
+
|
|
181
|
+
expect(host.read('apps/test/.env.local').toString()).toContain('CLIENT_SECRET=super-secret');
|
|
182
|
+
expect(host.exists('apps/test/.env')).toBeFalsy();
|
|
183
|
+
}, 60000);
|
|
184
|
+
|
|
185
|
+
it('does not modify .gitignore for the provisioned secret', async () => {
|
|
186
|
+
keycloakAdminMock.ensureServiceClient.mockResolvedValueOnce('super-secret');
|
|
187
|
+
const host = createTreeWithEmptyWorkspace({ layout: 'apps-libs' });
|
|
188
|
+
const gitignoreBefore = host.read('.gitignore')?.toString() ?? '';
|
|
189
|
+
await generator(host, { ...options, accessToken: 'test-token' });
|
|
190
|
+
|
|
191
|
+
expect(host.read('.gitignore')?.toString() ?? '').toBe(gitignoreBefore);
|
|
192
|
+
}, 60000);
|
|
193
|
+
|
|
194
|
+
it('does not overwrite or duplicate an existing CLIENT_SECRET in .env.local', async () => {
|
|
195
|
+
keycloakAdminMock.ensureServiceClient.mockResolvedValueOnce('freshly-provisioned-secret');
|
|
196
|
+
const host = createTreeWithEmptyWorkspace({ layout: 'apps-libs' });
|
|
197
|
+
// express-service is a one-shot scaffolder (re-running it against an
|
|
198
|
+
// existing project throws in @nx/express), so this exercises the guard
|
|
199
|
+
// directly rather than by calling the generator twice: a CLIENT_SECRET
|
|
200
|
+
// already present in .env.local (e.g. set by hand) must survive untouched.
|
|
201
|
+
host.write('apps/test/.env.local', 'CLIENT_SECRET=already-there\n');
|
|
202
|
+
await generator(host, { ...options, accessToken: 'test-token' });
|
|
203
|
+
|
|
204
|
+
const envLocal = host.read('apps/test/.env.local').toString();
|
|
205
|
+
expect(envLocal).toContain('CLIENT_SECRET=already-there');
|
|
206
|
+
expect(envLocal).not.toContain('freshly-provisioned-secret');
|
|
207
|
+
expect(envLocal.split('CLIENT_SECRET=').length - 1).toBe(1);
|
|
208
|
+
}, 60000);
|
|
209
|
+
|
|
210
|
+
it('preserves an existing .env.local value (e.g. a prior dev-db run) alongside CLIENT_SECRET', async () => {
|
|
211
|
+
keycloakAdminMock.ensureServiceClient.mockResolvedValueOnce('super-secret');
|
|
212
|
+
const host = createTreeWithEmptyWorkspace({ layout: 'apps-libs' });
|
|
213
|
+
host.write('apps/test/.env.local', 'DATABASE_URL=postgresql://test:test@localhost:5432/test_dev\n');
|
|
214
|
+
await generator(host, { ...options, accessToken: 'test-token' });
|
|
215
|
+
|
|
216
|
+
const envLocal = host.read('apps/test/.env.local').toString();
|
|
217
|
+
expect(envLocal).toContain('DATABASE_URL=postgresql://test:test@localhost:5432/test_dev');
|
|
218
|
+
expect(envLocal).toContain('CLIENT_SECRET=super-secret');
|
|
219
|
+
}, 60000);
|
|
220
|
+
|
|
221
|
+
it('writes nothing when no secret is provisioned', async () => {
|
|
222
|
+
keycloakAdminMock.ensureServiceClient.mockResolvedValueOnce(null);
|
|
223
|
+
const host = createTreeWithEmptyWorkspace({ layout: 'apps-libs' });
|
|
224
|
+
await generator(host, { ...options, accessToken: 'test-token' });
|
|
225
|
+
|
|
226
|
+
expect(host.exists('apps/test/.env.local')).toBeFalsy();
|
|
227
|
+
expect(host.exists('apps/test/.env')).toBeFalsy();
|
|
228
|
+
}, 60000);
|
|
171
229
|
});
|
|
@@ -157,7 +157,7 @@ import { authorize, createValidationHandler } from '@abgov/adsp-service-sdk';
|
|
|
157
157
|
import { z } from 'zod';
|
|
158
158
|
import * as items from '../services/items';
|
|
159
159
|
|
|
160
|
-
const CreateItem = z.object({ name: z.string().min(1) });
|
|
160
|
+
const CreateItem = z.object({ name: z.string().trim().min(1) });
|
|
161
161
|
|
|
162
162
|
export function itemsRouter(): Router {
|
|
163
163
|
const router = Router();
|
|
@@ -178,7 +178,13 @@ export function itemsRouter(): Router {
|
|
|
178
178
|
createValidationHandler(CreateItem),
|
|
179
179
|
async (req, res, next) => {
|
|
180
180
|
try {
|
|
181
|
-
|
|
181
|
+
// createValidationHandler validates req.body against the schema but
|
|
182
|
+
// doesn't replace it with the parsed result — req.body is still the
|
|
183
|
+
// raw body afterward. Invisible for a plain string, but any
|
|
184
|
+
// transform (.trim() here) or coercion (z.coerce.date(), a default)
|
|
185
|
+
// is silently lost if you read req.body directly instead of
|
|
186
|
+
// re-parsing. Parse again, here, to get the actual parsed value.
|
|
187
|
+
const { name } = CreateItem.parse(req.body);
|
|
182
188
|
res.status(201).json(await items.create(name));
|
|
183
189
|
} catch (err) {
|
|
184
190
|
next(err);
|
|
@@ -201,7 +207,10 @@ app.use('/<%= projectName %>/v1/items', itemsRouter());
|
|
|
201
207
|
|
|
202
208
|
`authorize(role)` → 403 if the user lacks the role; `createValidationHandler(schema)`
|
|
203
209
|
→ 400 on a bad body. Both forward errors to `next()`, which `createErrorHandler`
|
|
204
|
-
(mounted last in `main.ts`) turns into structured HTTP responses.
|
|
210
|
+
(mounted last in `main.ts`) turns into structured HTTP responses. Don't read
|
|
211
|
+
`req.body` directly in the handler and assert its type (`req.body as
|
|
212
|
+
z.infer<typeof Schema>`) — that's the raw, unparsed body, not the validated
|
|
213
|
+
one; parse it again with the same schema instead, as above.
|
|
205
214
|
|
|
206
215
|
## Recipe: add a resource end to end
|
|
207
216
|
|
|
@@ -5,13 +5,13 @@ import { resolve } from 'path';
|
|
|
5
5
|
config({
|
|
6
6
|
path: resolve(process.cwd(), '<%= projectRoot %>/.env'),
|
|
7
7
|
});
|
|
8
|
-
|
|
9
|
-
//
|
|
8
|
+
// .env.local holds generated, local-only values: CLIENT_SECRET (written once by
|
|
9
|
+
// this generator after Keycloak provisioning) and, when a database is
|
|
10
|
+
// configured, the connection string written by 'nx dev-db'.
|
|
10
11
|
config({
|
|
11
12
|
path: resolve(process.cwd(), '<%= projectRoot %>/.env.local'),
|
|
12
13
|
override: true,
|
|
13
14
|
});
|
|
14
|
-
<% } %>
|
|
15
15
|
|
|
16
16
|
export const environment = cleanEnv(process.env, {
|
|
17
17
|
KEYCLOAK_ROOT_URL: str({ default: '<%= accessServiceUrl %>' }),
|
|
@@ -46,7 +46,11 @@ export function exampleRouter(eventService: EventService): Router {
|
|
|
46
46
|
createValidationHandler(ExampleRequestSchema),
|
|
47
47
|
async (req, res, next) => {
|
|
48
48
|
try {
|
|
49
|
-
|
|
49
|
+
// createValidationHandler validates req.body but doesn't replace it
|
|
50
|
+
// with the parsed result — parse again here rather than asserting
|
|
51
|
+
// req.body's type, so any transform/coercion your schema adds later
|
|
52
|
+
// actually takes effect (see AGENTS.md's "Adding routes").
|
|
53
|
+
const { id } = ExampleRequestSchema.parse(req.body);
|
|
50
54
|
eventService.send(createExampleEvent(id));
|
|
51
55
|
res.json({ id });
|
|
52
56
|
} catch (err) {
|
|
@@ -1,8 +1,12 @@
|
|
|
1
|
-
#
|
|
2
|
-
#
|
|
1
|
+
# Every value below already has a matching default in src/environment.ts — you
|
|
2
|
+
# only need to copy this to .env if you want to override one (e.g. point at a
|
|
3
|
+
# different environment temporarily).
|
|
4
|
+
#
|
|
5
|
+
# CLIENT_SECRET is written automatically to .env.local after Keycloak
|
|
6
|
+
# provisioning (or set it there yourself, as CLIENT_SECRET=<value>, for manual
|
|
7
|
+
# setup). MONGODB_URI is written automatically to .env.local by
|
|
8
|
+
# 'nx dev-db <%= projectName %>'. Neither belongs here.
|
|
3
9
|
KEYCLOAK_ROOT_URL=<%= accessServiceUrl %>
|
|
4
10
|
DIRECTORY_URL=<%= directoryServiceUrl %>
|
|
5
11
|
TENANT_REALM=<%= tenantRealm %>
|
|
6
12
|
CLIENT_ID=urn:ads:<%= tenant %>:<%= projectName %>
|
|
7
|
-
CLIENT_SECRET=
|
|
8
|
-
MONGODB_URI=mongodb://localhost:27017/<%= projectName %>_dev
|
|
@@ -32,7 +32,12 @@ until podman exec "${CONTAINER}" mongosh --quiet --eval "quit()" &>/dev/null; do
|
|
|
32
32
|
done
|
|
33
33
|
echo "MongoDB is ready."
|
|
34
34
|
|
|
35
|
-
#
|
|
36
|
-
#
|
|
37
|
-
|
|
35
|
+
# Merge MONGODB_URI into .env.local rather than overwriting it wholesale —
|
|
36
|
+
# CLIENT_SECRET (written once by the generator after Keycloak provisioning) may
|
|
37
|
+
# already be there. Overridden by the Secret in OpenShift at runtime.
|
|
38
|
+
if [ -f .env.local ]; then
|
|
39
|
+
grep -v '^MONGODB_URI=' .env.local > .env.local.tmp || true
|
|
40
|
+
mv .env.local.tmp .env.local
|
|
41
|
+
fi
|
|
42
|
+
echo "MONGODB_URI=mongodb://localhost:${PORT}/${DB_NAME}" >> .env.local
|
|
38
43
|
echo "MONGODB_URI written to .env.local"
|
|
@@ -1,8 +1,12 @@
|
|
|
1
|
-
#
|
|
2
|
-
#
|
|
1
|
+
# Every value below already has a matching default in src/environment.ts — you
|
|
2
|
+
# only need to copy this to .env if you want to override one (e.g. point at a
|
|
3
|
+
# different environment temporarily).
|
|
4
|
+
#
|
|
5
|
+
# CLIENT_SECRET is written automatically to .env.local after Keycloak
|
|
6
|
+
# provisioning (or set it there yourself, as CLIENT_SECRET=<value>, for manual
|
|
7
|
+
# setup). DATABASE_URL is written automatically to .env.local by
|
|
8
|
+
# 'nx dev-db <%= projectName %>'. Neither belongs here.
|
|
3
9
|
KEYCLOAK_ROOT_URL=<%= accessServiceUrl %>
|
|
4
10
|
DIRECTORY_URL=<%= directoryServiceUrl %>
|
|
5
11
|
TENANT_REALM=<%= tenantRealm %>
|
|
6
12
|
CLIENT_ID=urn:ads:<%= tenant %>:<%= projectName %>
|
|
7
|
-
CLIENT_SECRET=
|
|
8
|
-
DATABASE_URL=postgresql://<%= projectName %>:<%= projectName %>@localhost:5432/<%= projectName %>_dev
|
|
@@ -37,7 +37,12 @@ until podman exec "${CONTAINER}" pg_isready -U "${DB_USER}" -d "${DB_NAME}" &>/d
|
|
|
37
37
|
done
|
|
38
38
|
echo "Postgres is ready."
|
|
39
39
|
|
|
40
|
-
#
|
|
41
|
-
#
|
|
42
|
-
|
|
40
|
+
# Merge DATABASE_URL into .env.local rather than overwriting it wholesale —
|
|
41
|
+
# CLIENT_SECRET (written once by the generator after Keycloak provisioning) may
|
|
42
|
+
# already be there. Overridden by the SECRET in OpenShift at runtime.
|
|
43
|
+
if [ -f .env.local ]; then
|
|
44
|
+
grep -v '^DATABASE_URL=' .env.local > .env.local.tmp || true
|
|
45
|
+
mv .env.local.tmp .env.local
|
|
46
|
+
fi
|
|
47
|
+
echo "DATABASE_URL=postgresql://${DB_USER}:${DB_PASS}@localhost:${PORT}/${DB_NAME}" >> .env.local
|
|
43
48
|
echo "DATABASE_URL written to .env.local"
|
|
@@ -16,11 +16,26 @@ vi.mock('@dsb-norge/vue-keycloak-js', async () => {
|
|
|
16
16
|
});
|
|
17
17
|
|
|
18
18
|
import { useKeycloak } from '@dsb-norge/vue-keycloak-js';
|
|
19
|
+
import { createMemoryHistory, createRouter } from 'vue-router';
|
|
19
20
|
import App from './App.vue';
|
|
20
21
|
|
|
22
|
+
// App.vue reads useRoute() for the layout-width feature (route.meta.layout,
|
|
23
|
+
// default 'page') — that needs a real router installed via `global.plugins`,
|
|
24
|
+
// not just a RouterView stub. Stubbing RouterView only replaces what it
|
|
25
|
+
// renders; it doesn't provide the injection context useRoute() reads from, so
|
|
26
|
+
// route.meta would throw on undefined without this. Installing the router is
|
|
27
|
+
// enough on its own — its route ref is already a real object (Vue Router's
|
|
28
|
+
// START_LOCATION_NORMALIZED, meta: {}) before any navigation resolves, so no
|
|
29
|
+
// router.isReady()/await is needed, and calling it here would hang: with no
|
|
30
|
+
// app mounted yet, no navigation has been triggered for it to wait on.
|
|
31
|
+
const router = createRouter({
|
|
32
|
+
history: createMemoryHistory(),
|
|
33
|
+
routes: [{ path: '/', component: { template: '<div />' } }],
|
|
34
|
+
});
|
|
35
|
+
|
|
21
36
|
describe('App shell header', () => {
|
|
22
37
|
it('shows Sign in when unauthenticated', () => {
|
|
23
|
-
const wrapper = mount(App, { global: { stubs: { RouterView: true } } });
|
|
38
|
+
const wrapper = mount(App, { global: { plugins: [router], stubs: { RouterView: true } } });
|
|
24
39
|
const group = wrapper.find('goa-button-group');
|
|
25
40
|
expect(group.exists()).toBe(true);
|
|
26
41
|
expect(group.html()).toContain('Sign in');
|
|
@@ -30,7 +45,7 @@ describe('App shell header', () => {
|
|
|
30
45
|
// The bug: destructuring useKeycloak() froze `keycloak` at undefined, so
|
|
31
46
|
// login() was a permanent no-op. Reactive access must reach the instance.
|
|
32
47
|
const kc = useKeycloak();
|
|
33
|
-
const wrapper = mount(App, { global: { stubs: { RouterView: true } } });
|
|
48
|
+
const wrapper = mount(App, { global: { plugins: [router], stubs: { RouterView: true } } });
|
|
34
49
|
const btn = wrapper.findAll('goa-button').find((b) => b.text().includes('Sign in'));
|
|
35
50
|
await btn?.trigger('_click');
|
|
36
51
|
expect(kc.keycloak?.login).toHaveBeenCalled();
|
|
@@ -6,6 +6,7 @@ exports.vueComponentsImportPath = vueComponentsImportPath;
|
|
|
6
6
|
exports.default = default_1;
|
|
7
7
|
const tslib_1 = require("tslib");
|
|
8
8
|
const devkit_1 = require("@nx/devkit");
|
|
9
|
+
const internal_1 = require("@nx/eslint/internal");
|
|
9
10
|
const path = require("path");
|
|
10
11
|
// Backfills package.json module-resolution fields for the library. In a TS-solution
|
|
11
12
|
// workspace @nx/vue's library resolves via package.json `exports`, but its
|
|
@@ -36,24 +37,32 @@ function ensurePackageExports(host, libRoot) {
|
|
|
36
37
|
// element usage, not the deprecated Vue 2 component-slot syntax the rule targets.
|
|
37
38
|
// The whole lib wraps web components, so it's scoped to the lib (consuming apps,
|
|
38
39
|
// which use `<template #actions>`, are unaffected).
|
|
40
|
+
//
|
|
41
|
+
// Uses @nx/eslint's own override helpers rather than hand-editing a specific
|
|
42
|
+
// file format: create-nx-workspace's current default is flat config
|
|
43
|
+
// (eslint.config.mjs), which is a JS module exporting an array, not JSON — an
|
|
44
|
+
// earlier version of this function only handled legacy .eslintrc.json, so it
|
|
45
|
+
// silently no-op'd (just a console warning) on flat-config workspaces, and
|
|
46
|
+
// `nx lint vue-components` failed for real on unmodified generator output.
|
|
47
|
+
// addOverrideToLintConfig/lintConfigHasOverride detect flat vs legacy
|
|
48
|
+
// internally (via @nx/eslint's own useFlatConfig check) and edit whichever is
|
|
49
|
+
// actually in effect — AST-aware for flat config, not string splicing.
|
|
39
50
|
function disableSlotAttributeRule(host, libRoot) {
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
console.warn(`\n⚠ ${eslintrc} not found — could not disable vue/no-deprecated-slot-attribute.\n` +
|
|
51
|
+
if (!(0, internal_1.isEslintConfigSupported)(host, libRoot)) {
|
|
52
|
+
console.warn(`\n⚠ No ESLint config found for ${libRoot} — could not disable vue/no-deprecated-slot-attribute.\n` +
|
|
43
53
|
` GoabModal uses goa-modal's native \`slot\` attribute; if lint flags it, turn\n` +
|
|
44
54
|
` that rule off for this library.\n`);
|
|
45
55
|
return;
|
|
46
56
|
}
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
return json;
|
|
57
|
+
// `files` is `string | string[]` per the Linter type — normalize before checking.
|
|
58
|
+
const isVueOverride = (o) => (Array.isArray(o.files) ? o.files : o.files ? [o.files] : []).some((f) => f.includes('vue'));
|
|
59
|
+
const alreadyDisabled = (0, internal_1.lintConfigHasOverride)(host, libRoot, (o) => { var _a; return isVueOverride(o) && ((_a = o.rules) === null || _a === void 0 ? void 0 : _a['vue/no-deprecated-slot-attribute']) === 'off'; });
|
|
60
|
+
if (alreadyDisabled) {
|
|
61
|
+
return;
|
|
62
|
+
}
|
|
63
|
+
(0, internal_1.addOverrideToLintConfig)(host, libRoot, {
|
|
64
|
+
files: ['*.vue'],
|
|
65
|
+
rules: { 'vue/no-deprecated-slot-attribute': 'off' },
|
|
57
66
|
});
|
|
58
67
|
}
|
|
59
68
|
exports.LIB_NAME = 'vue-components';
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"vue-components.js","sourceRoot":"","sources":["../../../../../../packages/nx-adsp/src/generators/vue-components/vue-components.ts"],"names":[],"mappings":";;;
|
|
1
|
+
{"version":3,"file":"vue-components.js","sourceRoot":"","sources":["../../../../../../packages/nx-adsp/src/generators/vue-components/vue-components.ts"],"names":[],"mappings":";;;AAkBA,oDAcC;AAoDD,0DASC;AAMD,4BAkCC;;AArID,uCAMoB;AACpB,kDAA8G;AAE9G,6BAA6B;AAE7B,oFAAoF;AACpF,2EAA2E;AAC3E,oFAAoF;AACpF,kFAAkF;AAClF,6EAA6E;AAC7E,kFAAkF;AAClF,4DAA4D;AAC5D,SAAgB,oBAAoB,CAAC,IAAU,EAAE,OAAe;IAC9D,MAAM,OAAO,GAAG,GAAG,OAAO,eAAe,CAAC;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E,EAAE,CAAC,CAAC;IAC5E,CAAC;CAAA"}
|
|
@@ -50,12 +50,34 @@ describe('Vue Components Generator', () => {
|
|
|
50
50
|
expect(agents).toContain('defineModel<boolean>');
|
|
51
51
|
}, 30000);
|
|
52
52
|
|
|
53
|
+
it('disables vue/no-deprecated-slot-attribute in flat config too, not just .eslintrc.json', async () => {
|
|
54
|
+
// useFlatConfig() (from @nx/eslint) treats a root flat-config file's
|
|
55
|
+
// presence as authoritative, regardless of the installed ESLint version —
|
|
56
|
+
// this is what create-nx-workspace's current default actually looks like.
|
|
57
|
+
host.write('eslint.config.mjs', 'export default [];\n');
|
|
58
|
+
await generator(host);
|
|
59
|
+
|
|
60
|
+
expect(host.exists('libs/vue-components/eslint.config.mjs')).toBeTruthy();
|
|
61
|
+
expect(host.exists('libs/vue-components/.eslintrc.json')).toBeFalsy();
|
|
62
|
+
const flatConfig = host.read('libs/vue-components/eslint.config.mjs').toString();
|
|
63
|
+
expect(flatConfig).toContain('"vue/no-deprecated-slot-attribute": "off"');
|
|
64
|
+
}, 30000);
|
|
65
|
+
|
|
53
66
|
it('is idempotent — a second run does not throw and keeps the wrappers', async () => {
|
|
54
67
|
await generator(host);
|
|
55
68
|
await expect(generator(host)).resolves.not.toThrow();
|
|
56
69
|
expect(host.exists('libs/vue-components/src/lib/GoabInput.vue')).toBeTruthy();
|
|
57
70
|
}, 30000);
|
|
58
71
|
|
|
72
|
+
it('does not duplicate the ESLint override on a second run (legacy or flat)', async () => {
|
|
73
|
+
host.write('eslint.config.mjs', 'export default [];\n');
|
|
74
|
+
await generator(host);
|
|
75
|
+
await generator(host);
|
|
76
|
+
|
|
77
|
+
const flatConfig = host.read('libs/vue-components/eslint.config.mjs').toString();
|
|
78
|
+
expect(flatConfig.split('vue/no-deprecated-slot-attribute').length - 1).toBe(1);
|
|
79
|
+
}, 30000);
|
|
80
|
+
|
|
59
81
|
it('derives the import path from the workspace scope', () => {
|
|
60
82
|
expect(vueComponentsImportPath(host)).toMatch(/\/vue-components$/);
|
|
61
83
|
});
|