@abgov/nx-adsp 13.6.0 → 13.6.1

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@abgov/nx-adsp",
3
- "version": "13.6.0",
3
+ "version": "13.6.1",
4
4
  "license": "Apache-2.0",
5
5
  "main": "src/index.js",
6
6
  "description": "Government of Alberta - Nx plugin for ADSP apps.",
@@ -25,6 +25,7 @@ function onClose() {
25
25
  <template>
26
26
  <goa-modal :open="open" @_close="onClose">
27
27
  <slot />
28
+ <!-- `slot="actions"` is goa-modal's native web-component slot, not the Vue 2 slot syntax. The vue/no-deprecated-slot-attribute rule is turned off for this lib (see .eslintrc.json). -->
28
29
  <div v-if="slots.actions" slot="actions">
29
30
  <slot name="actions" />
30
31
  </div>
@@ -0,0 +1,21 @@
1
+ import { describe, it, expect } from 'vitest';
2
+ import * as lib from './index';
3
+
4
+ // Smoke test: the barrel resolves and every wrapper SFC compiles under the test
5
+ // runner. It also gives the library a test target with real content, so
6
+ // `nx test vue-components` doesn't fail on "no test files found".
7
+ describe('vue-components', () => {
8
+ it('exports every GoA wrapper', () => {
9
+ for (const name of [
10
+ 'GoabInput',
11
+ 'GoabTextarea',
12
+ 'GoabDropdown',
13
+ 'GoabCheckbox',
14
+ 'GoabRadioGroup',
15
+ 'GoabButton',
16
+ 'GoabModal',
17
+ ]) {
18
+ expect(lib[name as keyof typeof lib]).toBeTruthy();
19
+ }
20
+ });
21
+ });
@@ -1,4 +1,5 @@
1
1
  import { Tree } from '@nx/devkit';
2
+ export declare function ensurePackageExports(host: Tree, libRoot: string): void;
2
3
  export declare const LIB_NAME = "vue-components";
3
4
  export declare function vueComponentsImportPath(host: Tree): string;
4
5
  export default function (host: Tree): Promise<void>;
@@ -1,11 +1,61 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.LIB_NAME = void 0;
4
+ exports.ensurePackageExports = ensurePackageExports;
4
5
  exports.vueComponentsImportPath = vueComponentsImportPath;
5
6
  exports.default = default_1;
6
7
  const tslib_1 = require("tslib");
7
8
  const devkit_1 = require("@nx/devkit");
8
9
  const path = require("path");
10
+ // Backfills package.json module-resolution fields for the library. In a TS-solution
11
+ // workspace @nx/vue's library resolves via package.json `exports`, but its
12
+ // programmatic default (useProjectJson skips writing them here) leaves them off, so
13
+ // the import path fails to resolve and the build breaks. Point them at the source
14
+ // entry (the lib is non-buildable — consumers compile it). A no-op in legacy
15
+ // path-alias workspaces (no lib package.json — resolution is via tsconfig paths),
16
+ // and idempotent (never clobbers fields @nx/vue did write).
17
+ function ensurePackageExports(host, libRoot) {
18
+ const pkgPath = `${libRoot}/package.json`;
19
+ if (!host.exists(pkgPath))
20
+ return;
21
+ const SRC = './src/index.ts';
22
+ (0, devkit_1.updateJson)(host, pkgPath, (pkg) => {
23
+ var _a, _b, _c, _d;
24
+ (_a = pkg.main) !== null && _a !== void 0 ? _a : (pkg.main = SRC);
25
+ (_b = pkg.module) !== null && _b !== void 0 ? _b : (pkg.module = SRC);
26
+ (_c = pkg.types) !== null && _c !== void 0 ? _c : (pkg.types = SRC);
27
+ (_d = pkg.exports) !== null && _d !== void 0 ? _d : (pkg.exports = {
28
+ './package.json': './package.json',
29
+ '.': { types: SRC, import: SRC, default: SRC },
30
+ });
31
+ return pkg;
32
+ });
33
+ }
34
+ // Turns off vue/no-deprecated-slot-attribute for the lib. GoabModal projects into
35
+ // goa-modal's native web-component slot via `slot="actions"` — legitimate custom-
36
+ // element usage, not the deprecated Vue 2 component-slot syntax the rule targets.
37
+ // The whole lib wraps web components, so it's scoped to the lib (consuming apps,
38
+ // which use `<template #actions>`, are unaffected).
39
+ function disableSlotAttributeRule(host, libRoot) {
40
+ const eslintrc = `${libRoot}/.eslintrc.json`;
41
+ if (!host.exists(eslintrc)) {
42
+ console.warn(`\n⚠ ${eslintrc} not found — could not disable vue/no-deprecated-slot-attribute.\n` +
43
+ ` GoabModal uses goa-modal's native \`slot\` attribute; if lint flags it, turn\n` +
44
+ ` that rule off for this library.\n`);
45
+ return;
46
+ }
47
+ (0, devkit_1.updateJson)(host, eslintrc, (json) => {
48
+ var _a, _b;
49
+ const overrides = ((_a = json.overrides) !== null && _a !== void 0 ? _a : (json.overrides = []));
50
+ let vueOverride = overrides.find((o) => { var _a; return (_a = o.files) === null || _a === void 0 ? void 0 : _a.some((f) => f.includes('vue')); });
51
+ if (!vueOverride) {
52
+ vueOverride = { files: ['*.vue'], rules: {} };
53
+ overrides.push(vueOverride);
54
+ }
55
+ ((_b = vueOverride.rules) !== null && _b !== void 0 ? _b : (vueOverride.rules = {}))['vue/no-deprecated-slot-attribute'] = 'off';
56
+ return json;
57
+ });
58
+ }
9
59
  exports.LIB_NAME = 'vue-components';
10
60
  // Import specifier for the shared wrapper lib, derived from the workspace npm
11
61
  // scope so it mirrors the eventual official `@abgov/vue-components` (same tail —
@@ -54,6 +104,8 @@ function default_1(host) {
54
104
  importPath: vueComponentsImportPath(host),
55
105
  skipFormat: true,
56
106
  });
107
+ disableSlotAttributeRule(host, libRoot);
108
+ ensurePackageExports(host, libRoot);
57
109
  }
58
110
  (0, devkit_1.generateFiles)(host, path.join(__dirname, 'files'), libRoot, { tmpl: '' });
59
111
  });
@@ -1 +1 @@
1
- {"version":3,"file":"vue-components.js","sourceRoot":"","sources":["../../../../../../packages/nx-adsp/src/generators/vue-components/vue-components.ts"],"names":[],"mappings":";;;AAcA,0DASC;AAMD,4BAgCC;;AA7DD,uCAKoB;AACpB,6BAA6B;AAEhB,QAAA,QAAQ,GAAG,gBAAgB,CAAC;AAEzC,8EAA8E;AAC9E,iFAAiF;AACjF,+EAA+E;AAC/E,gDAAgD;AAChD,SAAgB,uBAAuB,CAAC,IAAU;;IAChD,IAAI,IAAI,GAAG,WAAW,CAAC;IACvB,IAAI,CAAC;QACH,IAAI,GAAG,IAAI,CAAC,KAAK,CAAC,MAAA,MAAA,IAAI,CAAC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,CAAC;gBACzC,UAAU,EAAE,IAAI;aACjB,CAAC,CAAC;QACL,CAAC;QAED,IAAA,sBAAa,EAAC,IAAI,EAAE,IAAI,CAAC,IAAI,CAAC,SAAS,EAAE,OAAO,CAAC,EAAE,OAAO,EAAE,EAAE,IAAI,EAAE,EAAE,EAAE,CAAC,CAAC;IAC5E,CAAC;CAAA"}
1
+ {"version":3,"file":"vue-components.js","sourceRoot":"","sources":["../../../../../../packages/nx-adsp/src/generators/vue-components/vue-components.ts"],"names":[],"mappings":";;;AAoBA,oDAcC;AAmCD,0DASC;AAMD,4BAkCC;;AAtHD,uCAMoB;AACpB,6BAA6B;AAM7B,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;IAC1C,IAAI,CAAC,IAAI,CAAC,MAAM,CAAC,OAAO,CAAC;QAAE,OAAO;IAClC,MAAM,GAAG,GAAG,gBAAgB,CAAC;IAC7B,IAAA,mBAAU,EAAmD,IAAI,EAAE,OAAO,EAAE,CAAC,GAAG,EAAE,EAAE;;QAClF,MAAA,GAAG,CAAC,IAAI,oCAAR,GAAG,CAAC,IAAI,GAAK,GAAG,EAAC;QACjB,MAAA,GAAG,CAAC,MAAM,oCAAV,GAAG,CAAC,MAAM,GAAK,GAAG,EAAC;QACnB,MAAA,GAAG,CAAC,KAAK,oCAAT,GAAG,CAAC,KAAK,GAAK,GAAG,EAAC;QAClB,MAAA,GAAG,CAAC,OAAO,oCAAX,GAAG,CAAC,OAAO,GAAK;YACd,gBAAgB,EAAE,gBAAgB;YAClC,GAAG,EAAE,EAAE,KAAK,EAAE,GAAG,EAAE,MAAM,EAAE,GAAG,EAAE,OAAO,EAAE,GAAG,EAAE;SAC/C,EAAC;QACF,OAAO,GAAG,CAAC;IACb,CA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,cAAc,EAAE,QAAQ;gBACxB,0EAA0E;gBAC1E,2EAA2E;gBAC3E,8DAA8D;gBAC9D,SAAS,EAAE,KAAK;gBAChB,OAAO,EAAE,MAAM;gBACf,UAAU,EAAE,uBAAuB,CAAC,IAAI,CAAC;gBACzC,UAAU,EAAE,IAAI;aACjB,CAAC,CAAC;YACH,wBAAwB,CAAC,IAAI,EAAE,OAAO,CAAC,CAAC;YACxC,oBAAoB,CAAC,IAAI,EAAE,OAAO,CAAC,CAAC;QACtC,CAAC;QAED,IAAA,sBAAa,EAAC,IAAI,EAAE,IAAI,CAAC,IAAI,CAAC,SAAS,EAAE,OAAO,CAAC,EAAE,OAAO,EAAE,EAAE,IAAI,EAAE,EAAE,EAAE,CAAC,CAAC;IAC5E,CAAC;CAAA"}
@@ -1,6 +1,6 @@
1
1
  import { readProjectConfiguration, Tree } from '@nx/devkit';
2
2
  import { createTreeWithEmptyWorkspace } from '@nx/devkit/testing';
3
- import generator, { vueComponentsImportPath } from './vue-components';
3
+ import generator, { ensurePackageExports, vueComponentsImportPath } from './vue-components';
4
4
 
5
5
  jest.mock('@nx/devkit', () => ({
6
6
  ...jest.requireActual('@nx/devkit'),
@@ -31,6 +31,15 @@ describe('Vue Components Generator', () => {
31
31
  expect(index).toContain("export { default as GoabInput }");
32
32
  expect(index).toContain('@abgov/vue-components'); // interim marker
33
33
 
34
+ // Ships a spec so the vitest test target isn't empty (vitest exits non-zero
35
+ // on "no test files found").
36
+ expect(host.exists('libs/vue-components/src/vue-components.spec.ts')).toBeTruthy();
37
+
38
+ // GoabModal uses goa-modal's native `slot` attribute (web component, not the
39
+ // deprecated Vue 2 slot syntax) — the rule is turned off for this lib.
40
+ const eslintrc = host.read('libs/vue-components/.eslintrc.json').toString();
41
+ expect(eslintrc).toContain('"vue/no-deprecated-slot-attribute": "off"');
42
+
34
43
  // Ships agent direction for maintaining the (interim) lib, incl. a recipe
35
44
  // for wrapping additional components.
36
45
  expect(host.exists('libs/vue-components/AGENTS.md')).toBeTruthy();
@@ -50,4 +59,32 @@ describe('Vue Components Generator', () => {
50
59
  it('derives the import path from the workspace scope', () => {
51
60
  expect(vueComponentsImportPath(host)).toMatch(/\/vue-components$/);
52
61
  });
62
+
63
+ describe('ensurePackageExports (TS-solution resolution fix)', () => {
64
+ it('backfills exports/main/types when a lib package.json exists', () => {
65
+ host.write('libs/vue-components/package.json', JSON.stringify({ name: '@proj/vue-components' }));
66
+ ensurePackageExports(host, 'libs/vue-components');
67
+
68
+ const pkg = JSON.parse(host.read('libs/vue-components/package.json').toString());
69
+ expect(pkg.main).toBe('./src/index.ts');
70
+ expect(pkg.types).toBe('./src/index.ts');
71
+ expect(pkg.exports['.'].import).toBe('./src/index.ts');
72
+ });
73
+
74
+ it('does not clobber exports @nx/vue already wrote', () => {
75
+ host.write(
76
+ 'libs/vue-components/package.json',
77
+ JSON.stringify({ name: '@proj/vue-components', exports: { '.': './dist/index.js' } })
78
+ );
79
+ ensurePackageExports(host, 'libs/vue-components');
80
+
81
+ const pkg = JSON.parse(host.read('libs/vue-components/package.json').toString());
82
+ expect(pkg.exports['.']).toBe('./dist/index.js');
83
+ });
84
+
85
+ it('is a no-op for a legacy lib with no package.json', () => {
86
+ ensurePackageExports(host, 'libs/vue-components');
87
+ expect(host.exists('libs/vue-components/package.json')).toBeFalsy();
88
+ });
89
+ });
53
90
  });