create-o2s-app 4.1.9 → 4.1.11
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/CHANGELOG.md +30 -0
- package/dist/scaffold/clone.js +2 -2
- package/dist/scaffold/get-aliases-to-remove.d.ts +9 -0
- package/dist/scaffold/get-aliases-to-remove.d.ts.map +1 -0
- package/dist/scaffold/get-aliases-to-remove.js +21 -0
- package/dist/scaffold/get-aliases-to-remove.spec.d.ts +2 -0
- package/dist/scaffold/get-aliases-to-remove.spec.d.ts.map +1 -0
- package/dist/scaffold/get-aliases-to-remove.spec.js +26 -0
- package/dist/scaffold/index.d.ts.map +1 -1
- package/dist/scaffold/index.js +2 -0
- package/dist/scaffold/transform-app-module.d.ts.map +1 -1
- package/dist/scaffold/transform-app-module.js +4 -15
- package/dist/scaffold/transform-blocks-config.d.ts +7 -0
- package/dist/scaffold/transform-blocks-config.d.ts.map +1 -0
- package/dist/scaffold/transform-blocks-config.js +134 -0
- package/dist/scaffold/transform-blocks-config.spec.d.ts +2 -0
- package/dist/scaffold/transform-blocks-config.spec.d.ts.map +1 -0
- package/dist/scaffold/transform-blocks-config.spec.js +190 -0
- package/dist/scaffold/transform-legacy-block-files.spec.d.ts +2 -0
- package/dist/scaffold/transform-legacy-block-files.spec.d.ts.map +1 -0
- package/dist/scaffold/transform-legacy-block-files.spec.js +89 -0
- package/dist/scaffold/transform-page-model.d.ts.map +1 -1
- package/dist/scaffold/transform-page-model.js +4 -15
- package/dist/scaffold/transform-real-files.spec.d.ts +2 -0
- package/dist/scaffold/transform-real-files.spec.d.ts.map +1 -0
- package/dist/scaffold/transform-real-files.spec.js +154 -0
- package/dist/scaffold/transform-render-blocks.d.ts.map +1 -1
- package/dist/scaffold/transform-render-blocks.js +63 -17
- package/dist/scaffold/transform-render-blocks.spec.d.ts +2 -0
- package/dist/scaffold/transform-render-blocks.spec.d.ts.map +1 -0
- package/dist/scaffold/transform-render-blocks.spec.js +126 -0
- package/package.json +8 -6
- package/src/scaffold/clone.ts +1 -1
- package/src/scaffold/get-aliases-to-remove.spec.ts +30 -0
- package/src/scaffold/get-aliases-to-remove.ts +19 -0
- package/src/scaffold/index.ts +2 -0
- package/src/scaffold/transform-app-module.ts +4 -16
- package/src/scaffold/transform-blocks-config.spec.ts +215 -0
- package/src/scaffold/transform-blocks-config.ts +113 -0
- package/src/scaffold/transform-legacy-block-files.spec.ts +68 -0
- package/src/scaffold/transform-page-model.ts +4 -16
- package/src/scaffold/transform-real-files.spec.ts +153 -0
- package/src/scaffold/transform-render-blocks.spec.ts +129 -0
- package/src/scaffold/transform-render-blocks.ts +73 -18
- package/vitest.config.mjs +3 -0
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,35 @@
|
|
|
1
1
|
# create-o2s-app
|
|
2
2
|
|
|
3
|
+
## 4.1.11
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- 53bcb98: fix(cli): drop the `onSignOut` import from `renderBlocks.tsx` when the user-account block is not selected
|
|
8
|
+
|
|
9
|
+
Without the user-account block the import was left unused, so `npm run lint` failed in generated projects (e.g. the `dxp` template or a custom block selection).
|
|
10
|
+
|
|
11
|
+
- 53bcb98: fix(cli): remove unselected blocks from `blocks.config.ts` during scaffolding
|
|
12
|
+
|
|
13
|
+
Block registration moved to `apps/api-harmonization/src/blocks.config.ts`, but the scaffolder only cleaned `app.module.ts` and `page.model.ts`. Projects generated without the full set of blocks (e.g. the `o2s` template) failed to build because `blocks.config.ts` still imported the removed block packages.
|
|
14
|
+
|
|
15
|
+
## 4.1.10
|
|
16
|
+
|
|
17
|
+
### Patch Changes
|
|
18
|
+
|
|
19
|
+
- 5905e9d: chore(deps): update dependencies
|
|
20
|
+
- 5905e9d: chore(deps): update dependencies
|
|
21
|
+
- 78f7a66: chore(deps): update storybook to 10.6.7, vite to 8.3.8, turbo to 2.11.13, @vitejs/plugin-react to 6.3.0, commander to 15.1.0, simple-git to 4.1.0, fs-extra to 11.4.1
|
|
22
|
+
- 5905e9d: chore(deps): update dependencies
|
|
23
|
+
- 78f7a66: chore(deps): update prettier to 3.10.1
|
|
24
|
+
- 5905e9d: chore(deps): update dependencies
|
|
25
|
+
- 5905e9d: chore(deps): update dependencies
|
|
26
|
+
- 5905e9d: chore(deps): update dependencies
|
|
27
|
+
- 5905e9d: chore(deps): update dependencies
|
|
28
|
+
- 5905e9d: chore(deps): update dependencies
|
|
29
|
+
- Updated dependencies [78f7a66]
|
|
30
|
+
- Updated dependencies [78f7a66]
|
|
31
|
+
- @o2s/telemetry@1.2.4
|
|
32
|
+
|
|
3
33
|
## 4.1.9
|
|
4
34
|
|
|
5
35
|
### Patch Changes
|
package/dist/scaffold/clone.js
CHANGED
|
@@ -42,7 +42,7 @@ const cli_progress_1 = __importDefault(require("cli-progress"));
|
|
|
42
42
|
const fs = __importStar(require("fs-extra"));
|
|
43
43
|
const os = __importStar(require("os"));
|
|
44
44
|
const path = __importStar(require("path"));
|
|
45
|
-
const simple_git_1 =
|
|
45
|
+
const simple_git_1 = require("simple-git");
|
|
46
46
|
const cloneRepository = async () => {
|
|
47
47
|
const tempDir = path.join(os.tmpdir(), `openselfservice-${Date.now()}`);
|
|
48
48
|
await fs.ensureDir(tempDir);
|
|
@@ -51,7 +51,7 @@ const cloneRepository = async () => {
|
|
|
51
51
|
const bar = new cli_progress_1.default.SingleBar({}, cli_progress_1.default.Presets.shades_classic);
|
|
52
52
|
bar.start(100, 0);
|
|
53
53
|
try {
|
|
54
|
-
const git = (0, simple_git_1.
|
|
54
|
+
const git = (0, simple_git_1.simpleGit)({
|
|
55
55
|
progress({ progress }) {
|
|
56
56
|
bar.update(Math.round(progress));
|
|
57
57
|
},
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Finds the import aliases of the blocks the user did NOT select.
|
|
3
|
+
*
|
|
4
|
+
* Aliases are discovered from the file itself (handles special aliases), using `importRegex`,
|
|
5
|
+
* which must capture the alias in group 1 and the block name in group 2, e.g.
|
|
6
|
+
* `import * as Alias from '@o2s/blocks.<name>/api-harmonization';`.
|
|
7
|
+
*/
|
|
8
|
+
export declare const getAliasesToRemove: (lines: string[], importRegex: RegExp, selectedBlockNames: string[]) => Set<string>;
|
|
9
|
+
//# sourceMappingURL=get-aliases-to-remove.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"get-aliases-to-remove.d.ts","sourceRoot":"","sources":["../../src/scaffold/get-aliases-to-remove.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AACH,eAAO,MAAM,kBAAkB,UAAW,MAAM,EAAE,eAAe,MAAM,sBAAsB,MAAM,EAAE,KAAG,GAAG,CAAC,MAAM,CAWjH,CAAC"}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.getAliasesToRemove = void 0;
|
|
4
|
+
/**
|
|
5
|
+
* Finds the import aliases of the blocks the user did NOT select.
|
|
6
|
+
*
|
|
7
|
+
* Aliases are discovered from the file itself (handles special aliases), using `importRegex`,
|
|
8
|
+
* which must capture the alias in group 1 and the block name in group 2, e.g.
|
|
9
|
+
* `import * as Alias from '@o2s/blocks.<name>/api-harmonization';`.
|
|
10
|
+
*/
|
|
11
|
+
const getAliasesToRemove = (lines, importRegex, selectedBlockNames) => {
|
|
12
|
+
const aliasesToRemove = new Set();
|
|
13
|
+
for (const line of lines) {
|
|
14
|
+
const match = line.match(importRegex);
|
|
15
|
+
if (match && match[1] && match[2] && !selectedBlockNames.includes(match[2])) {
|
|
16
|
+
aliasesToRemove.add(match[1]);
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
return aliasesToRemove;
|
|
20
|
+
};
|
|
21
|
+
exports.getAliasesToRemove = getAliasesToRemove;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"get-aliases-to-remove.spec.d.ts","sourceRoot":"","sources":["../../src/scaffold/get-aliases-to-remove.spec.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const get_aliases_to_remove_1 = require("./get-aliases-to-remove");
|
|
4
|
+
const vitest_1 = require("vitest");
|
|
5
|
+
const IMPORT_REGEX = /^import \* as (\w+) from '@o2s\/blocks\.([^/]+)\/api-harmonization';$/;
|
|
6
|
+
const LINES = [
|
|
7
|
+
"import * as ArticleList from '@o2s/blocks.article-list/api-harmonization';",
|
|
8
|
+
"import * as Article from '@o2s/blocks.article/api-harmonization';",
|
|
9
|
+
"import * as CustomFaq from '@o2s/blocks.faq/api-harmonization';",
|
|
10
|
+
"import { Something } from '@o2s/framework/modules';",
|
|
11
|
+
' Article,',
|
|
12
|
+
];
|
|
13
|
+
(0, vitest_1.describe)('getAliasesToRemove', () => {
|
|
14
|
+
(0, vitest_1.it)('returns the aliases of unselected blocks', () => {
|
|
15
|
+
(0, vitest_1.expect)((0, get_aliases_to_remove_1.getAliasesToRemove)(LINES, IMPORT_REGEX, ['article'])).toEqual(new Set(['ArticleList', 'CustomFaq']));
|
|
16
|
+
});
|
|
17
|
+
(0, vitest_1.it)('uses the alias from the file, not one derived from the block name', () => {
|
|
18
|
+
(0, vitest_1.expect)((0, get_aliases_to_remove_1.getAliasesToRemove)(LINES, IMPORT_REGEX, ['article', 'article-list'])).toEqual(new Set(['CustomFaq']));
|
|
19
|
+
});
|
|
20
|
+
(0, vitest_1.it)('returns an empty set when every block is selected', () => {
|
|
21
|
+
(0, vitest_1.expect)((0, get_aliases_to_remove_1.getAliasesToRemove)(LINES, IMPORT_REGEX, ['article', 'article-list', 'faq']).size).toBe(0);
|
|
22
|
+
});
|
|
23
|
+
(0, vitest_1.it)('ignores lines that do not match the import regex', () => {
|
|
24
|
+
(0, vitest_1.expect)((0, get_aliases_to_remove_1.getAliasesToRemove)(LINES, IMPORT_REGEX, [])).toEqual(new Set(['ArticleList', 'Article', 'CustomFaq']));
|
|
25
|
+
});
|
|
26
|
+
});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/scaffold/index.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,aAAa,EAAE,MAAM,UAAU,CAAC;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/scaffold/index.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,aAAa,EAAE,MAAM,UAAU,CAAC;AA2CzC,eAAO,MAAM,QAAQ,YACR,MAAM,WACN,aAAa,qCAEV,MAAM,KACnB,OAAO,CAAC;IAAE,SAAS,EAAE,MAAM,CAAC;IAAC,gBAAgB,EAAE,MAAM,EAAE,CAAA;CAAE,CAuD3D,CAAC"}
|
package/dist/scaffold/index.js
CHANGED
|
@@ -41,6 +41,7 @@ const install_1 = require("./install");
|
|
|
41
41
|
const transform_app_config_1 = require("./transform-app-config");
|
|
42
42
|
const transform_app_module_1 = require("./transform-app-module");
|
|
43
43
|
const transform_apps_package_json_1 = require("./transform-apps-package-json");
|
|
44
|
+
const transform_blocks_config_1 = require("./transform-blocks-config");
|
|
44
45
|
const transform_integration_configs_1 = require("./transform-integration-configs");
|
|
45
46
|
const transform_package_json_1 = require("./transform-package-json");
|
|
46
47
|
const transform_page_model_1 = require("./transform-page-model");
|
|
@@ -81,6 +82,7 @@ const scaffold = async (tempDir, answers, skipInstall = false, directory) => {
|
|
|
81
82
|
console.log('Configuring project for selected blocks...');
|
|
82
83
|
await Promise.all([
|
|
83
84
|
(0, transform_app_module_1.transformAppModule)(targetDir, selectedBlocks),
|
|
85
|
+
(0, transform_blocks_config_1.transformBlocksConfig)(targetDir, selectedBlocks),
|
|
84
86
|
(0, transform_render_blocks_1.transformRenderBlocks)(targetDir, selectedBlocks),
|
|
85
87
|
(0, transform_page_model_1.transformPageModel)(targetDir, selectedBlocks),
|
|
86
88
|
(0, transform_apps_package_json_1.transformAppsPackageJson)(targetDir, selectedBlocks, selectedIntegrations),
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"transform-app-module.d.ts","sourceRoot":"","sources":["../../src/scaffold/transform-app-module.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"transform-app-module.d.ts","sourceRoot":"","sources":["../../src/scaffold/transform-app-module.ts"],"names":[],"mappings":"AAcA,eAAO,MAAM,kBAAkB,eAAsB,MAAM,sBAAsB,MAAM,EAAE,KAAG,OAAO,CAAC,IAAI,CAuBvG,CAAC"}
|
|
@@ -34,6 +34,7 @@ var __importStar = (this && this.__importStar) || (function () {
|
|
|
34
34
|
})();
|
|
35
35
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
36
36
|
exports.transformAppModule = void 0;
|
|
37
|
+
const get_aliases_to_remove_1 = require("./get-aliases-to-remove");
|
|
37
38
|
const fs = __importStar(require("fs-extra"));
|
|
38
39
|
const path = __importStar(require("path"));
|
|
39
40
|
const FILE_PATH = 'apps/api-harmonization/src/app.module.ts';
|
|
@@ -41,27 +42,15 @@ const FILE_PATH = 'apps/api-harmonization/src/app.module.ts';
|
|
|
41
42
|
const BLOCK_IMPORT_REGEX = /^import \* as (\w+) from '@o2s\/blocks\.([^/]+)\/api-harmonization';$/;
|
|
42
43
|
// Regex matches: Alias.Module.register(AppConfig),
|
|
43
44
|
const BLOCK_REGISTRATION_REGEX = /^\s+(\w+)\.Module\.register\(AppConfig\),\s*$/;
|
|
45
|
+
// TODO: remove this transform once `create-o2s-app/base` registers blocks in
|
|
46
|
+
// `apps/api-harmonization/src/blocks.config.ts` (handled by `transform-blocks-config.ts`).
|
|
44
47
|
const transformAppModule = async (projectDir, selectedBlockNames) => {
|
|
45
48
|
const filePath = path.join(projectDir, FILE_PATH);
|
|
46
49
|
if (!(await fs.pathExists(filePath)))
|
|
47
50
|
return;
|
|
48
51
|
const content = await fs.readFile(filePath, 'utf-8');
|
|
49
52
|
const lines = content.split('\n');
|
|
50
|
-
|
|
51
|
-
const aliasToBlock = new Map();
|
|
52
|
-
for (const line of lines) {
|
|
53
|
-
const match = line.match(BLOCK_IMPORT_REGEX);
|
|
54
|
-
if (match && match[1] && match[2]) {
|
|
55
|
-
aliasToBlock.set(match[1], match[2]); // alias → blockName
|
|
56
|
-
}
|
|
57
|
-
}
|
|
58
|
-
// Build set of aliases for blocks the user did NOT select
|
|
59
|
-
const aliasesToRemove = new Set();
|
|
60
|
-
for (const [alias, blockName] of aliasToBlock.entries()) {
|
|
61
|
-
if (!selectedBlockNames.includes(blockName)) {
|
|
62
|
-
aliasesToRemove.add(alias);
|
|
63
|
-
}
|
|
64
|
-
}
|
|
53
|
+
const aliasesToRemove = (0, get_aliases_to_remove_1.getAliasesToRemove)(lines, BLOCK_IMPORT_REGEX, selectedBlockNames);
|
|
65
54
|
if (aliasesToRemove.size === 0)
|
|
66
55
|
return;
|
|
67
56
|
const filteredLines = lines.filter((line) => {
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Removes unselected blocks from `blocks.config.ts`, the single place where the API harmonization
|
|
3
|
+
* app registers its blocks: the `import`, the entry in the `blocks` array and the member of the
|
|
4
|
+
* `Blocks` union.
|
|
5
|
+
*/
|
|
6
|
+
export declare const transformBlocksConfig: (projectDir: string, selectedBlockNames: string[]) => Promise<void>;
|
|
7
|
+
//# sourceMappingURL=transform-blocks-config.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"transform-blocks-config.d.ts","sourceRoot":"","sources":["../../src/scaffold/transform-blocks-config.ts"],"names":[],"mappings":"AA0BA;;;;GAIG;AACH,eAAO,MAAM,qBAAqB,eAAsB,MAAM,sBAAsB,MAAM,EAAE,KAAG,OAAO,CAAC,IAAI,CAiF1G,CAAC"}
|
|
@@ -0,0 +1,134 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
19
|
+
var ownKeys = function(o) {
|
|
20
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
21
|
+
var ar = [];
|
|
22
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
23
|
+
return ar;
|
|
24
|
+
};
|
|
25
|
+
return ownKeys(o);
|
|
26
|
+
};
|
|
27
|
+
return function (mod) {
|
|
28
|
+
if (mod && mod.__esModule) return mod;
|
|
29
|
+
var result = {};
|
|
30
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
31
|
+
__setModuleDefault(result, mod);
|
|
32
|
+
return result;
|
|
33
|
+
};
|
|
34
|
+
})();
|
|
35
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
36
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
37
|
+
};
|
|
38
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
39
|
+
exports.transformBlocksConfig = void 0;
|
|
40
|
+
const get_aliases_to_remove_1 = require("./get-aliases-to-remove");
|
|
41
|
+
const fs = __importStar(require("fs-extra"));
|
|
42
|
+
const kleur_1 = __importDefault(require("kleur"));
|
|
43
|
+
const path = __importStar(require("path"));
|
|
44
|
+
const FILE_PATH = 'apps/api-harmonization/src/blocks.config.ts';
|
|
45
|
+
// Regex matches: import * as Alias from '@o2s/blocks.<name>/api-harmonization';
|
|
46
|
+
const BLOCK_IMPORT_REGEX = /^import \* as (\w+) from '@o2s\/blocks\.([^/]+)\/api-harmonization';$/;
|
|
47
|
+
// Regex matches the start of the block registry, with an optional type annotation:
|
|
48
|
+
// export const blocks = [ / export const blocks: BlockModule[] = [
|
|
49
|
+
const BLOCKS_ARRAY_START_REGEX = /^export const blocks\s*(?::[^=]+)?=\s*\[\s*$/;
|
|
50
|
+
// Regex matches the end of the block registry: ]; / ] as const;
|
|
51
|
+
const BLOCKS_ARRAY_END_REGEX = /^\](?:\s+as\s+const)?;?\s*$/;
|
|
52
|
+
// Regex matches an entry of the block registry: Alias,
|
|
53
|
+
const BLOCK_ENTRY_REGEX = /^\s+(\w+),\s*$/;
|
|
54
|
+
// Regex matches: | Alias.Model.SomeTypenameBlock['__typename']
|
|
55
|
+
const UNION_TYPE_REGEX = /^\s+\| (\w+)\.Model\.\w+\['__typename'\]/;
|
|
56
|
+
// Regex matches the start of the union: export type Blocks =
|
|
57
|
+
const BLOCKS_TYPE_REGEX = /^export type Blocks\s*=\s*$/;
|
|
58
|
+
/**
|
|
59
|
+
* Removes unselected blocks from `blocks.config.ts`, the single place where the API harmonization
|
|
60
|
+
* app registers its blocks: the `import`, the entry in the `blocks` array and the member of the
|
|
61
|
+
* `Blocks` union.
|
|
62
|
+
*/
|
|
63
|
+
const transformBlocksConfig = async (projectDir, selectedBlockNames) => {
|
|
64
|
+
const filePath = path.join(projectDir, FILE_PATH);
|
|
65
|
+
if (!(await fs.pathExists(filePath)))
|
|
66
|
+
return;
|
|
67
|
+
const content = await fs.readFile(filePath, 'utf-8');
|
|
68
|
+
const lines = content.split('\n');
|
|
69
|
+
const aliasesToRemove = (0, get_aliases_to_remove_1.getAliasesToRemove)(lines, BLOCK_IMPORT_REGEX, selectedBlockNames);
|
|
70
|
+
if (aliasesToRemove.size === 0)
|
|
71
|
+
return;
|
|
72
|
+
const result = [];
|
|
73
|
+
let insideBlocksArray = false;
|
|
74
|
+
let lastKeptUnionIndex = -1;
|
|
75
|
+
let removedUnionTerminator = false;
|
|
76
|
+
let unionMemberCount = 0;
|
|
77
|
+
let typeMarkerIndex = -1;
|
|
78
|
+
let blocksTypeIndex = -1;
|
|
79
|
+
for (const line of lines) {
|
|
80
|
+
if (BLOCKS_ARRAY_START_REGEX.test(line)) {
|
|
81
|
+
insideBlocksArray = true;
|
|
82
|
+
result.push(line);
|
|
83
|
+
continue;
|
|
84
|
+
}
|
|
85
|
+
if (insideBlocksArray) {
|
|
86
|
+
if (BLOCKS_ARRAY_END_REGEX.test(line)) {
|
|
87
|
+
insideBlocksArray = false;
|
|
88
|
+
}
|
|
89
|
+
else {
|
|
90
|
+
const entryMatch = line.match(BLOCK_ENTRY_REGEX);
|
|
91
|
+
if (entryMatch && entryMatch[1] && aliasesToRemove.has(entryMatch[1]))
|
|
92
|
+
continue;
|
|
93
|
+
}
|
|
94
|
+
result.push(line);
|
|
95
|
+
continue;
|
|
96
|
+
}
|
|
97
|
+
const importMatch = line.match(BLOCK_IMPORT_REGEX);
|
|
98
|
+
if (importMatch && importMatch[1] && aliasesToRemove.has(importMatch[1]))
|
|
99
|
+
continue;
|
|
100
|
+
const unionMatch = line.match(UNION_TYPE_REGEX);
|
|
101
|
+
if (unionMatch && unionMatch[1]) {
|
|
102
|
+
unionMemberCount++;
|
|
103
|
+
if (aliasesToRemove.has(unionMatch[1])) {
|
|
104
|
+
// The removed member may carry the `;` that terminates the `Blocks` union.
|
|
105
|
+
if (line.trimEnd().endsWith(';'))
|
|
106
|
+
removedUnionTerminator = true;
|
|
107
|
+
continue;
|
|
108
|
+
}
|
|
109
|
+
lastKeptUnionIndex = result.length;
|
|
110
|
+
}
|
|
111
|
+
if (line.includes('// BLOCK TYPE'))
|
|
112
|
+
typeMarkerIndex = result.length;
|
|
113
|
+
if (BLOCKS_TYPE_REGEX.test(line))
|
|
114
|
+
blocksTypeIndex = result.length;
|
|
115
|
+
result.push(line);
|
|
116
|
+
}
|
|
117
|
+
if (unionMemberCount > 0 && lastKeptUnionIndex < 0) {
|
|
118
|
+
// Every block was removed: keep the union valid so the generator can still add blocks.
|
|
119
|
+
// Insert after the generator marker, or right after `export type Blocks =` without it.
|
|
120
|
+
const insertAfter = typeMarkerIndex >= 0 ? typeMarkerIndex : blocksTypeIndex;
|
|
121
|
+
if (insertAfter >= 0) {
|
|
122
|
+
result.splice(insertAfter + 1, 0, ` | never${removedUnionTerminator ? ';' : ''}`);
|
|
123
|
+
}
|
|
124
|
+
else {
|
|
125
|
+
console.warn(kleur_1.default.yellow(`Warning: could not find the \`Blocks\` union in ${FILE_PATH}; it is left without members and the project will not build until you fix it.`));
|
|
126
|
+
}
|
|
127
|
+
}
|
|
128
|
+
else if (removedUnionTerminator && lastKeptUnionIndex >= 0) {
|
|
129
|
+
// Move the terminating `;` to the last remaining member of the union.
|
|
130
|
+
result[lastKeptUnionIndex] = `${result[lastKeptUnionIndex]?.trimEnd()};`;
|
|
131
|
+
}
|
|
132
|
+
await fs.writeFile(filePath, result.join('\n'), 'utf-8');
|
|
133
|
+
};
|
|
134
|
+
exports.transformBlocksConfig = transformBlocksConfig;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"transform-blocks-config.spec.d.ts","sourceRoot":"","sources":["../../src/scaffold/transform-blocks-config.spec.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,190 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
19
|
+
var ownKeys = function(o) {
|
|
20
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
21
|
+
var ar = [];
|
|
22
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
23
|
+
return ar;
|
|
24
|
+
};
|
|
25
|
+
return ownKeys(o);
|
|
26
|
+
};
|
|
27
|
+
return function (mod) {
|
|
28
|
+
if (mod && mod.__esModule) return mod;
|
|
29
|
+
var result = {};
|
|
30
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
31
|
+
__setModuleDefault(result, mod);
|
|
32
|
+
return result;
|
|
33
|
+
};
|
|
34
|
+
})();
|
|
35
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
36
|
+
const transform_blocks_config_1 = require("./transform-blocks-config");
|
|
37
|
+
const fs = __importStar(require("fs-extra"));
|
|
38
|
+
const os = __importStar(require("os"));
|
|
39
|
+
const path = __importStar(require("path"));
|
|
40
|
+
const vitest_1 = require("vitest");
|
|
41
|
+
const FILE_PATH = 'apps/api-harmonization/src/blocks.config.ts';
|
|
42
|
+
const BLOCKS_CONFIG = `import * as ArticleList from '@o2s/blocks.article-list/api-harmonization';
|
|
43
|
+
import * as Article from '@o2s/blocks.article/api-harmonization';
|
|
44
|
+
import * as Faq from '@o2s/blocks.faq/api-harmonization';
|
|
45
|
+
import * as HeroSection from '@o2s/blocks.hero-section/api-harmonization';
|
|
46
|
+
|
|
47
|
+
// BLOCK IMPORT
|
|
48
|
+
|
|
49
|
+
/**
|
|
50
|
+
* Central registry of the blocks used by this app.
|
|
51
|
+
*/
|
|
52
|
+
export const blocks = [
|
|
53
|
+
Article,
|
|
54
|
+
ArticleList,
|
|
55
|
+
Faq,
|
|
56
|
+
HeroSection,
|
|
57
|
+
// BLOCK REGISTER
|
|
58
|
+
];
|
|
59
|
+
|
|
60
|
+
export type Blocks =
|
|
61
|
+
// BLOCK TYPE
|
|
62
|
+
| Article.Model.ArticleBlock['__typename']
|
|
63
|
+
| ArticleList.Model.ArticleListBlock['__typename']
|
|
64
|
+
| Faq.Model.FaqBlock['__typename']
|
|
65
|
+
| HeroSection.Model.HeroSectionBlock['__typename'];
|
|
66
|
+
`;
|
|
67
|
+
(0, vitest_1.describe)('transformBlocksConfig', () => {
|
|
68
|
+
let projectDir;
|
|
69
|
+
const writeConfig = async (content) => {
|
|
70
|
+
await fs.outputFile(path.join(projectDir, FILE_PATH), content, 'utf-8');
|
|
71
|
+
};
|
|
72
|
+
const readConfig = () => fs.readFile(path.join(projectDir, FILE_PATH), 'utf-8');
|
|
73
|
+
(0, vitest_1.beforeEach)(async () => {
|
|
74
|
+
projectDir = await fs.mkdtemp(path.join(os.tmpdir(), 'create-o2s-app-blocks-config-'));
|
|
75
|
+
});
|
|
76
|
+
(0, vitest_1.afterEach)(async () => {
|
|
77
|
+
await fs.remove(projectDir);
|
|
78
|
+
});
|
|
79
|
+
(0, vitest_1.it)('removes the import, registry entry and union member of unselected blocks', async () => {
|
|
80
|
+
await writeConfig(BLOCKS_CONFIG);
|
|
81
|
+
await (0, transform_blocks_config_1.transformBlocksConfig)(projectDir, ['article', 'faq']);
|
|
82
|
+
(0, vitest_1.expect)(await readConfig()).toBe(`import * as Article from '@o2s/blocks.article/api-harmonization';
|
|
83
|
+
import * as Faq from '@o2s/blocks.faq/api-harmonization';
|
|
84
|
+
|
|
85
|
+
// BLOCK IMPORT
|
|
86
|
+
|
|
87
|
+
/**
|
|
88
|
+
* Central registry of the blocks used by this app.
|
|
89
|
+
*/
|
|
90
|
+
export const blocks = [
|
|
91
|
+
Article,
|
|
92
|
+
Faq,
|
|
93
|
+
// BLOCK REGISTER
|
|
94
|
+
];
|
|
95
|
+
|
|
96
|
+
export type Blocks =
|
|
97
|
+
// BLOCK TYPE
|
|
98
|
+
| Article.Model.ArticleBlock['__typename']
|
|
99
|
+
| Faq.Model.FaqBlock['__typename'];
|
|
100
|
+
`);
|
|
101
|
+
});
|
|
102
|
+
(0, vitest_1.it)('does not treat a block name as a prefix of another block name', async () => {
|
|
103
|
+
await writeConfig(BLOCKS_CONFIG);
|
|
104
|
+
await (0, transform_blocks_config_1.transformBlocksConfig)(projectDir, ['article-list']);
|
|
105
|
+
const result = await readConfig();
|
|
106
|
+
(0, vitest_1.expect)(result).toContain("import * as ArticleList from '@o2s/blocks.article-list/api-harmonization';");
|
|
107
|
+
(0, vitest_1.expect)(result).not.toContain("from '@o2s/blocks.article/api-harmonization'");
|
|
108
|
+
(0, vitest_1.expect)(result).not.toMatch(/^\s+Article,$/m);
|
|
109
|
+
(0, vitest_1.expect)(result).toMatch(/^\s+ArticleList,$/m);
|
|
110
|
+
(0, vitest_1.expect)(result).not.toContain('Article.Model.ArticleBlock');
|
|
111
|
+
});
|
|
112
|
+
(0, vitest_1.it)('keeps the union terminated when its last member is removed', async () => {
|
|
113
|
+
await writeConfig(BLOCKS_CONFIG);
|
|
114
|
+
await (0, transform_blocks_config_1.transformBlocksConfig)(projectDir, ['article', 'faq']);
|
|
115
|
+
(0, vitest_1.expect)(await readConfig()).toContain(" | Faq.Model.FaqBlock['__typename'];\n");
|
|
116
|
+
});
|
|
117
|
+
(0, vitest_1.it)('keeps the generator markers and a valid union when all blocks are removed', async () => {
|
|
118
|
+
await writeConfig(BLOCKS_CONFIG);
|
|
119
|
+
await (0, transform_blocks_config_1.transformBlocksConfig)(projectDir, []);
|
|
120
|
+
const result = await readConfig();
|
|
121
|
+
(0, vitest_1.expect)(result).not.toContain('@o2s/blocks.');
|
|
122
|
+
(0, vitest_1.expect)(result).toContain('// BLOCK IMPORT');
|
|
123
|
+
(0, vitest_1.expect)(result).toContain('export const blocks = [\n // BLOCK REGISTER\n];');
|
|
124
|
+
(0, vitest_1.expect)(result).toContain('export type Blocks =\n // BLOCK TYPE\n | never;\n');
|
|
125
|
+
});
|
|
126
|
+
(0, vitest_1.it)('keeps the union terminated when it is defined in a different order than the imports', async () => {
|
|
127
|
+
await writeConfig(BLOCKS_CONFIG.replace(" | Faq.Model.FaqBlock['__typename']\n | HeroSection.Model.HeroSectionBlock['__typename'];", " | HeroSection.Model.HeroSectionBlock['__typename']\n | Faq.Model.FaqBlock['__typename'];"));
|
|
128
|
+
await (0, transform_blocks_config_1.transformBlocksConfig)(projectDir, ['faq', 'hero-section']);
|
|
129
|
+
const result = await readConfig();
|
|
130
|
+
(0, vitest_1.expect)(result).toContain(" | HeroSection.Model.HeroSectionBlock['__typename']\n | Faq.Model.FaqBlock['__typename'];\n");
|
|
131
|
+
});
|
|
132
|
+
(0, vitest_1.it)('leaves the file untouched when every block is selected', async () => {
|
|
133
|
+
await writeConfig(BLOCKS_CONFIG);
|
|
134
|
+
await (0, transform_blocks_config_1.transformBlocksConfig)(projectDir, ['article', 'article-list', 'faq', 'hero-section']);
|
|
135
|
+
(0, vitest_1.expect)(await readConfig()).toBe(BLOCKS_CONFIG);
|
|
136
|
+
});
|
|
137
|
+
(0, vitest_1.it)('does not remove non-block identifiers outside the blocks array', async () => {
|
|
138
|
+
const content = `import * as Faq from '@o2s/blocks.faq/api-harmonization';
|
|
139
|
+
import * as HeroSection from '@o2s/blocks.hero-section/api-harmonization';
|
|
140
|
+
|
|
141
|
+
const unrelated = {
|
|
142
|
+
HeroSection,
|
|
143
|
+
};
|
|
144
|
+
|
|
145
|
+
export const blocks = [
|
|
146
|
+
Faq,
|
|
147
|
+
HeroSection,
|
|
148
|
+
];
|
|
149
|
+
`;
|
|
150
|
+
await writeConfig(content);
|
|
151
|
+
await (0, transform_blocks_config_1.transformBlocksConfig)(projectDir, ['faq']);
|
|
152
|
+
const result = await readConfig();
|
|
153
|
+
(0, vitest_1.expect)(result).toContain('const unrelated = {\n HeroSection,\n};');
|
|
154
|
+
(0, vitest_1.expect)(result).toContain('export const blocks = [\n Faq,\n];');
|
|
155
|
+
});
|
|
156
|
+
(0, vitest_1.it)('keeps the union valid without the `// BLOCK TYPE` marker when all blocks are removed', async () => {
|
|
157
|
+
await writeConfig(BLOCKS_CONFIG.replace(' // BLOCK TYPE\n', ''));
|
|
158
|
+
await (0, transform_blocks_config_1.transformBlocksConfig)(projectDir, []);
|
|
159
|
+
(0, vitest_1.expect)(await readConfig()).toContain('export type Blocks =\n | never;\n');
|
|
160
|
+
});
|
|
161
|
+
(0, vitest_1.it)('does not add a semicolon to an empty union that had none', async () => {
|
|
162
|
+
await writeConfig(BLOCKS_CONFIG.replace(" | HeroSection.Model.HeroSectionBlock['__typename'];", " | HeroSection.Model.HeroSectionBlock['__typename']"));
|
|
163
|
+
await (0, transform_blocks_config_1.transformBlocksConfig)(projectDir, []);
|
|
164
|
+
(0, vitest_1.expect)(await readConfig()).toContain(' // BLOCK TYPE\n | never\n');
|
|
165
|
+
});
|
|
166
|
+
(0, vitest_1.it)('warns when the `Blocks` union cannot be found after removing all its members', async () => {
|
|
167
|
+
const warn = vitest_1.vi.spyOn(console, 'warn').mockImplementation(() => undefined);
|
|
168
|
+
await writeConfig(BLOCKS_CONFIG.replace('export type Blocks =\n // BLOCK TYPE\n', 'export type Blocks = // union\n'));
|
|
169
|
+
await (0, transform_blocks_config_1.transformBlocksConfig)(projectDir, []);
|
|
170
|
+
(0, vitest_1.expect)(warn).toHaveBeenCalledWith(vitest_1.expect.stringContaining('apps/api-harmonization/src/blocks.config.ts'));
|
|
171
|
+
warn.mockRestore();
|
|
172
|
+
});
|
|
173
|
+
(0, vitest_1.it)('handles a type-annotated blocks array', async () => {
|
|
174
|
+
await writeConfig(BLOCKS_CONFIG.replace('export const blocks = [', 'export const blocks: BlockModule[] = ['));
|
|
175
|
+
await (0, transform_blocks_config_1.transformBlocksConfig)(projectDir, ['faq']);
|
|
176
|
+
(0, vitest_1.expect)(await readConfig()).toContain('export const blocks: BlockModule[] = [\n Faq,\n // BLOCK REGISTER\n];');
|
|
177
|
+
});
|
|
178
|
+
(0, vitest_1.it)('handles a blocks array declared `as const`', async () => {
|
|
179
|
+
await writeConfig(BLOCKS_CONFIG.replace(' // BLOCK REGISTER\n];', ' // BLOCK REGISTER\n] as const;'));
|
|
180
|
+
await (0, transform_blocks_config_1.transformBlocksConfig)(projectDir, ['faq']);
|
|
181
|
+
const result = await readConfig();
|
|
182
|
+
(0, vitest_1.expect)(result).toContain('export const blocks = [\n Faq,\n // BLOCK REGISTER\n] as const;');
|
|
183
|
+
// the union after the array is still processed
|
|
184
|
+
(0, vitest_1.expect)(result).toContain(" | Faq.Model.FaqBlock['__typename'];\n");
|
|
185
|
+
});
|
|
186
|
+
(0, vitest_1.it)('does nothing when blocks.config.ts does not exist', async () => {
|
|
187
|
+
await (0, vitest_1.expect)((0, transform_blocks_config_1.transformBlocksConfig)(projectDir, ['faq'])).resolves.toBeUndefined();
|
|
188
|
+
(0, vitest_1.expect)(await fs.pathExists(path.join(projectDir, FILE_PATH))).toBe(false);
|
|
189
|
+
});
|
|
190
|
+
});
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"transform-legacy-block-files.spec.d.ts","sourceRoot":"","sources":["../../src/scaffold/transform-legacy-block-files.spec.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
19
|
+
var ownKeys = function(o) {
|
|
20
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
21
|
+
var ar = [];
|
|
22
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
23
|
+
return ar;
|
|
24
|
+
};
|
|
25
|
+
return ownKeys(o);
|
|
26
|
+
};
|
|
27
|
+
return function (mod) {
|
|
28
|
+
if (mod && mod.__esModule) return mod;
|
|
29
|
+
var result = {};
|
|
30
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
31
|
+
__setModuleDefault(result, mod);
|
|
32
|
+
return result;
|
|
33
|
+
};
|
|
34
|
+
})();
|
|
35
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
36
|
+
const transform_app_module_1 = require("./transform-app-module");
|
|
37
|
+
const transform_page_model_1 = require("./transform-page-model");
|
|
38
|
+
const fs = __importStar(require("fs-extra"));
|
|
39
|
+
const os = __importStar(require("os"));
|
|
40
|
+
const path = __importStar(require("path"));
|
|
41
|
+
const vitest_1 = require("vitest");
|
|
42
|
+
// Block registration used by templates that predate `blocks.config.ts`.
|
|
43
|
+
const APP_MODULE_PATH = 'apps/api-harmonization/src/app.module.ts';
|
|
44
|
+
const PAGE_MODEL_PATH = 'apps/api-harmonization/src/modules/page/page.model.ts';
|
|
45
|
+
const APP_MODULE = `import * as Faq from '@o2s/blocks.faq/api-harmonization';
|
|
46
|
+
import * as TicketList from '@o2s/blocks.ticket-list/api-harmonization';
|
|
47
|
+
|
|
48
|
+
@Module({
|
|
49
|
+
imports: [
|
|
50
|
+
Faq.Module.register(AppConfig),
|
|
51
|
+
TicketList.Module.register(AppConfig),
|
|
52
|
+
],
|
|
53
|
+
})
|
|
54
|
+
export class AppModule {}
|
|
55
|
+
`;
|
|
56
|
+
const PAGE_MODEL = `import * as Faq from '@o2s/blocks.faq/api-harmonization';
|
|
57
|
+
import * as TicketList from '@o2s/blocks.ticket-list/api-harmonization';
|
|
58
|
+
|
|
59
|
+
export type Blocks =
|
|
60
|
+
| Faq.Model.FaqBlock['__typename']
|
|
61
|
+
| TicketList.Model.TicketListBlock['__typename'];
|
|
62
|
+
`;
|
|
63
|
+
(0, vitest_1.describe)('legacy block registration transforms', () => {
|
|
64
|
+
let projectDir;
|
|
65
|
+
(0, vitest_1.beforeEach)(async () => {
|
|
66
|
+
projectDir = await fs.mkdtemp(path.join(os.tmpdir(), 'create-o2s-app-legacy-'));
|
|
67
|
+
});
|
|
68
|
+
(0, vitest_1.afterEach)(async () => {
|
|
69
|
+
await fs.remove(projectDir);
|
|
70
|
+
});
|
|
71
|
+
(0, vitest_1.it)('transformAppModule removes the import and module registration of unselected blocks', async () => {
|
|
72
|
+
await fs.outputFile(path.join(projectDir, APP_MODULE_PATH), APP_MODULE, 'utf-8');
|
|
73
|
+
await (0, transform_app_module_1.transformAppModule)(projectDir, ['faq']);
|
|
74
|
+
const result = await fs.readFile(path.join(projectDir, APP_MODULE_PATH), 'utf-8');
|
|
75
|
+
(0, vitest_1.expect)(result).not.toContain('TicketList');
|
|
76
|
+
(0, vitest_1.expect)(result).toContain('Faq.Module.register(AppConfig),');
|
|
77
|
+
});
|
|
78
|
+
(0, vitest_1.it)('transformPageModel removes the import and union member of unselected blocks', async () => {
|
|
79
|
+
await fs.outputFile(path.join(projectDir, PAGE_MODEL_PATH), PAGE_MODEL, 'utf-8');
|
|
80
|
+
await (0, transform_page_model_1.transformPageModel)(projectDir, ['ticket-list']);
|
|
81
|
+
const result = await fs.readFile(path.join(projectDir, PAGE_MODEL_PATH), 'utf-8');
|
|
82
|
+
(0, vitest_1.expect)(result).not.toContain('Faq');
|
|
83
|
+
(0, vitest_1.expect)(result).toContain("| TicketList.Model.TicketListBlock['__typename'];");
|
|
84
|
+
});
|
|
85
|
+
(0, vitest_1.it)('both transforms skip files that do not exist', async () => {
|
|
86
|
+
await (0, vitest_1.expect)((0, transform_app_module_1.transformAppModule)(projectDir, ['faq'])).resolves.toBeUndefined();
|
|
87
|
+
await (0, vitest_1.expect)((0, transform_page_model_1.transformPageModel)(projectDir, ['faq'])).resolves.toBeUndefined();
|
|
88
|
+
});
|
|
89
|
+
});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"transform-page-model.d.ts","sourceRoot":"","sources":["../../src/scaffold/transform-page-model.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"transform-page-model.d.ts","sourceRoot":"","sources":["../../src/scaffold/transform-page-model.ts"],"names":[],"mappings":"AAcA,eAAO,MAAM,kBAAkB,eAAsB,MAAM,sBAAsB,MAAM,EAAE,KAAG,OAAO,CAAC,IAAI,CAuBvG,CAAC"}
|