@atls/code-schematics 2.0.28 → 2.0.30
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 +12 -0
- package/dist/exceptions/code-runtime-command.d.ts +3 -0
- package/dist/exceptions/code-runtime-command.js +5 -0
- package/dist/exceptions/index.d.ts +2 -0
- package/dist/exceptions/index.js +2 -0
- package/dist/exceptions/schematic-workflow.d.ts +3 -0
- package/dist/exceptions/schematic-workflow.js +5 -0
- package/dist/generated/schematic-factory-export.d.ts +1 -1
- package/dist/generated/schematic-factory-export.js +2 -2
- package/dist/getters/index.d.ts +2 -2
- package/dist/getters/index.js +2 -2
- package/dist/getters/{stream-report-callback.getter.js → stream-report-callback.js} +7 -10
- package/dist/helpers/code-runtime.d.ts +2 -0
- package/dist/helpers/code-runtime.js +47 -0
- package/dist/helpers/index.d.ts +5 -3
- package/dist/helpers/index.js +5 -3
- package/dist/helpers/{run-schematics.helper.js → run-schematics.js} +1 -1
- package/dist/helpers/schematic-result.d.ts +1 -0
- package/dist/helpers/schematic-result.js +6 -0
- package/dist/helpers/{write-tmp-schematic.helper.d.ts → write-tmp-schematic.d.ts} +1 -1
- package/dist/helpers/{write-tmp-schematic.helper.js → write-tmp-schematic.js} +3 -3
- package/dist/schematic/project/{project.factory.js → factory.js} +1 -1
- package/dist/schematic/project/index.d.ts +1 -1
- package/dist/schematic/project/index.js +1 -1
- package/dist/schematic/rules/index.d.ts +1 -1
- package/dist/schematic/rules/index.js +1 -1
- package/dist/schematic/rules/tsconfig.update.d.ts +7 -0
- package/dist/schematic/rules/tsconfig.update.js +6 -0
- package/dist/scripts/exceptions/index.d.ts +1 -1
- package/dist/scripts/exceptions/index.js +1 -1
- package/dist/scripts/getters/{generated-file-content.getter.js → generated-file-content.js} +5 -4
- package/dist/scripts/getters/index.d.ts +4 -4
- package/dist/scripts/getters/index.js +4 -4
- package/dist/scripts/index.d.ts +1 -1
- package/dist/scripts/index.js +1 -1
- package/dist/scripts/{schematic-smoke.script.js → schematic-smoke.js} +4 -2
- package/package.json +3 -3
- package/dist/schematic/rules/update-ts-config.rule.d.ts +0 -2
- package/dist/schematic/rules/update-ts-config.rule.js +0 -7
- /package/dist/getters/{stream-report-callback.getter.d.ts → stream-report-callback.d.ts} +0 -0
- /package/dist/getters/{stream-report-options.getter.d.ts → stream-report-options.d.ts} +0 -0
- /package/dist/getters/{stream-report-options.getter.js → stream-report-options.js} +0 -0
- /package/dist/helpers/{events-log.helper.d.ts → events-log.d.ts} +0 -0
- /package/dist/helpers/{events-log.helper.js → events-log.js} +0 -0
- /package/dist/helpers/{prepare-tmp-dir.helper.d.ts → prepare-tmp-dir.d.ts} +0 -0
- /package/dist/helpers/{prepare-tmp-dir.helper.js → prepare-tmp-dir.js} +0 -0
- /package/dist/helpers/{run-schematics.helper.d.ts → run-schematics.d.ts} +0 -0
- /package/dist/schematic/project/{project.factory.d.ts → factory.d.ts} +0 -0
- /package/dist/scripts/exceptions/{undefined-build-result.exception.d.ts → undefined-build-result.d.ts} +0 -0
- /package/dist/scripts/exceptions/{undefined-build-result.exception.js → undefined-build-result.js} +0 -0
- /package/dist/scripts/getters/{cjs-content.getter.d.ts → cjs-content.d.ts} +0 -0
- /package/dist/scripts/getters/{cjs-content.getter.js → cjs-content.js} +0 -0
- /package/dist/scripts/getters/{encoded-content.getter.d.ts → encoded-content.d.ts} +0 -0
- /package/dist/scripts/getters/{encoded-content.getter.js → encoded-content.js} +0 -0
- /package/dist/scripts/getters/{esbuild-config.getter.d.ts → esbuild-config.d.ts} +0 -0
- /package/dist/scripts/getters/{esbuild-config.getter.js → esbuild-config.js} +0 -0
- /package/dist/scripts/getters/{generated-file-content.getter.d.ts → generated-file-content.d.ts} +0 -0
- /package/dist/scripts/{schematic-build.script.d.ts → schematic-build.d.ts} +0 -0
- /package/dist/scripts/{schematic-build.script.js → schematic-build.js} +0 -0
- /package/dist/scripts/{schematic-factory-build.script.d.ts → schematic-factory-build.d.ts} +0 -0
- /package/dist/scripts/{schematic-factory-build.script.js → schematic-factory-build.js} +0 -0
- /package/dist/scripts/{schematic-smoke.script.d.ts → schematic-smoke.d.ts} +0 -0
package/dist/getters/index.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export * from './stream-report-options.
|
|
2
|
-
export * from './stream-report-callback.
|
|
1
|
+
export * from './stream-report-options.js';
|
|
2
|
+
export * from './stream-report-callback.js';
|
package/dist/getters/index.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export * from "./stream-report-options.
|
|
2
|
-
export * from "./stream-report-callback.
|
|
1
|
+
export * from "./stream-report-options.js";
|
|
2
|
+
export * from "./stream-report-callback.js";
|
|
@@ -3,18 +3,15 @@ import { xfs } from '@yarnpkg/fslib';
|
|
|
3
3
|
import { runSchematicHelper } from '../helpers/index.js';
|
|
4
4
|
import { writeTmpSchematicHelper } from '../helpers/index.js';
|
|
5
5
|
import { prepareTmpDir } from '../helpers/index.js';
|
|
6
|
+
import { ensureSchematicSucceeded } from '../helpers/index.js';
|
|
6
7
|
export const getStreamReportCallback = async (options) => {
|
|
7
8
|
const streamReportCallback = async (report) => {
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
}
|
|
15
|
-
catch (error) {
|
|
16
|
-
console.error(error);
|
|
17
|
-
}
|
|
9
|
+
const tmpDir = await xfs.mktempPromise();
|
|
10
|
+
const collectionPath = ppath.join(tmpDir, 'collection.json');
|
|
11
|
+
const { cwd } = options;
|
|
12
|
+
await writeTmpSchematicHelper(tmpDir, cwd);
|
|
13
|
+
await prepareTmpDir(tmpDir);
|
|
14
|
+
ensureSchematicSucceeded(await runSchematicHelper('project', options, collectionPath));
|
|
18
15
|
};
|
|
19
16
|
return streamReportCallback;
|
|
20
17
|
};
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
import { spawn } from 'node:child_process';
|
|
2
|
+
import { CodeRuntimeCommandException } from '../exceptions/index.js';
|
|
3
|
+
const YARN_EXECUTABLE = process.platform === 'win32' ? 'yarn.cmd' : 'yarn';
|
|
4
|
+
const CODE_RUNTIME_PACKAGE = '@atls/code-runtime';
|
|
5
|
+
const WRITE_FILES_SCRIPT = `
|
|
6
|
+
const { writeFiles } = await import('${CODE_RUNTIME_PACKAGE}')
|
|
7
|
+
const [baseDir] = process.argv.slice(1)
|
|
8
|
+
|
|
9
|
+
await writeFiles(baseDir)
|
|
10
|
+
`;
|
|
11
|
+
const COMPILER_OPTIONS_SCRIPT = `
|
|
12
|
+
const { tsConfig } = await import('${CODE_RUNTIME_PACKAGE}')
|
|
13
|
+
|
|
14
|
+
process.stdout.write(JSON.stringify(tsConfig.compilerOptions))
|
|
15
|
+
`;
|
|
16
|
+
const createProjectEnvironment = () => {
|
|
17
|
+
const environment = { ...process.env };
|
|
18
|
+
delete environment.NODE_OPTIONS;
|
|
19
|
+
delete environment.YARN_IGNORE_PATH;
|
|
20
|
+
return environment;
|
|
21
|
+
};
|
|
22
|
+
const runCodeRuntimeScript = async (cwd, script, args = []) => {
|
|
23
|
+
const child = spawn(YARN_EXECUTABLE, ['node', '--input-type=module', '-e', script, ...args], {
|
|
24
|
+
cwd,
|
|
25
|
+
env: createProjectEnvironment(),
|
|
26
|
+
shell: process.platform === 'win32',
|
|
27
|
+
stdio: ['ignore', 'pipe', 'pipe'],
|
|
28
|
+
});
|
|
29
|
+
const stdoutChunks = [];
|
|
30
|
+
const stderrChunks = [];
|
|
31
|
+
child.stdout.on('data', (chunk) => stdoutChunks.push(chunk));
|
|
32
|
+
child.stderr.on('data', (chunk) => stderrChunks.push(chunk));
|
|
33
|
+
const exitCode = await new Promise((resolve, reject) => {
|
|
34
|
+
child.once('error', reject);
|
|
35
|
+
child.once('exit', resolve);
|
|
36
|
+
});
|
|
37
|
+
const stdout = Buffer.concat(stdoutChunks).toString('utf-8');
|
|
38
|
+
const stderr = Buffer.concat(stderrChunks).toString('utf-8').trim();
|
|
39
|
+
if (exitCode !== 0) {
|
|
40
|
+
throw new CodeRuntimeCommandException(stderr || `exit code ${exitCode}`);
|
|
41
|
+
}
|
|
42
|
+
return stdout;
|
|
43
|
+
};
|
|
44
|
+
export const writeCodeRuntimeFiles = async (cwd, baseDir) => {
|
|
45
|
+
await runCodeRuntimeScript(cwd, WRITE_FILES_SCRIPT, [baseDir]);
|
|
46
|
+
};
|
|
47
|
+
export const getCodeRuntimeCompilerOptions = async (cwd) => JSON.parse(await runCodeRuntimeScript(cwd, COMPILER_OPTIONS_SCRIPT));
|
package/dist/helpers/index.d.ts
CHANGED
|
@@ -1,3 +1,5 @@
|
|
|
1
|
-
export * from './run-schematics.
|
|
2
|
-
export * from './write-tmp-schematic.
|
|
3
|
-
export * from './prepare-tmp-dir.
|
|
1
|
+
export * from './run-schematics.js';
|
|
2
|
+
export * from './write-tmp-schematic.js';
|
|
3
|
+
export * from './prepare-tmp-dir.js';
|
|
4
|
+
export * from './code-runtime.js';
|
|
5
|
+
export * from './schematic-result.js';
|
package/dist/helpers/index.js
CHANGED
|
@@ -1,3 +1,5 @@
|
|
|
1
|
-
export * from "./run-schematics.
|
|
2
|
-
export * from "./write-tmp-schematic.
|
|
3
|
-
export * from "./prepare-tmp-dir.
|
|
1
|
+
export * from "./run-schematics.js";
|
|
2
|
+
export * from "./write-tmp-schematic.js";
|
|
3
|
+
export * from "./prepare-tmp-dir.js";
|
|
4
|
+
export * from "./code-runtime.js";
|
|
5
|
+
export * from "./schematic-result.js";
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { UnsuccessfulWorkflowExecution } from '@angular-devkit/schematics';
|
|
2
2
|
import { NodeWorkflow } from '@angular-devkit/schematics/tools';
|
|
3
|
-
import { eventsLogHelper } from './events-log.
|
|
3
|
+
import { eventsLogHelper } from './events-log.js';
|
|
4
4
|
export const runSchematicHelper = async (schematicName, options, collectionPath) => {
|
|
5
5
|
const dryRun = false;
|
|
6
6
|
const debug = true;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const ensureSchematicSucceeded: (exitCode: 0 | 1) => void;
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
import type { PortablePath } from '@yarnpkg/fslib';
|
|
2
|
-
export declare const writeTmpSchematicHelper: (tmpDir: PortablePath) => Promise<void>;
|
|
2
|
+
export declare const writeTmpSchematicHelper: (tmpDir: PortablePath, cwd?: string) => Promise<void>;
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { mkdir } from 'node:fs/promises';
|
|
2
2
|
import { ppath } from '@yarnpkg/fslib';
|
|
3
3
|
import { writeSchematicFactory } from '../generated/index.js';
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
await
|
|
4
|
+
import { writeCodeRuntimeFiles } from './code-runtime.js';
|
|
5
|
+
export const writeTmpSchematicHelper = async (tmpDir, cwd = process.cwd()) => {
|
|
6
|
+
await writeCodeRuntimeFiles(cwd, tmpDir);
|
|
7
7
|
const projectDir = ppath.join(tmpDir, 'project');
|
|
8
8
|
await mkdir(projectDir, { recursive: true });
|
|
9
9
|
await writeSchematicFactory(ppath.join(projectDir, 'project.factory.cjs'));
|
|
@@ -37,7 +37,7 @@ export const main = (options) => {
|
|
|
37
37
|
const state = {};
|
|
38
38
|
return chain([
|
|
39
39
|
captureGitIgnoreContentRule(state),
|
|
40
|
-
updateTsConfigRule,
|
|
40
|
+
updateTsConfigRule(options),
|
|
41
41
|
mergeWith(generateCommonSource(options), MergeStrategy.Overwrite),
|
|
42
42
|
mergeWith(generateProjectSpecificSource(options), MergeStrategy.Overwrite),
|
|
43
43
|
mergeGitIgnoreContentRule(state),
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export * from './
|
|
1
|
+
export * from './factory.js';
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export * from "./
|
|
1
|
+
export * from "./factory.js";
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export * from './update
|
|
1
|
+
export * from './tsconfig.update.js';
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export * from "./update
|
|
1
|
+
export * from "./tsconfig.update.js";
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import type { Rule } from '@angular-devkit/schematics';
|
|
2
|
+
interface UpdateTsConfigRuleOptions extends Record<string, string | undefined> {
|
|
3
|
+
cwd?: string;
|
|
4
|
+
runtimeCwd?: string;
|
|
5
|
+
}
|
|
6
|
+
export declare const updateTsConfigRule: (options: UpdateTsConfigRuleOptions) => Rule;
|
|
7
|
+
export {};
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { getCodeRuntimeCompilerOptions } from '../../helpers/index.js';
|
|
2
|
+
import { updateTsConfigInTree } from '../utils/tsconfig.utils.js';
|
|
3
|
+
export const updateTsConfigRule = (options) => async () => {
|
|
4
|
+
const compilerOptions = await getCodeRuntimeCompilerOptions(options.runtimeCwd ?? options.cwd ?? process.cwd());
|
|
5
|
+
return updateTsConfigInTree(compilerOptions);
|
|
6
|
+
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export * from './undefined-build-result.
|
|
1
|
+
export * from './undefined-build-result.js';
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export * from "./undefined-build-result.
|
|
1
|
+
export * from "./undefined-build-result.js";
|
|
@@ -1,13 +1,14 @@
|
|
|
1
1
|
const WRITE_SCHEMATIC_FACTORY_FUNCTION = `export const writeSchematicFactory = async (path: string) => {
|
|
2
|
-
const content = Buffer.from(schematicFactoryCjsBase64,
|
|
2
|
+
const content = Buffer.from(schematicFactoryCjsBase64, 'base64').toString('utf-8')
|
|
3
3
|
const fs = await import('fs/promises')
|
|
4
|
-
await fs.writeFile(path, content)
|
|
5
|
-
}
|
|
4
|
+
await fs.writeFile(path, content)
|
|
5
|
+
}`;
|
|
6
6
|
export const getGeneratedFileContent = (encodedContent) => {
|
|
7
7
|
const generatedFileContent = `// Auto-generated file
|
|
8
8
|
/* eslint-disable */
|
|
9
9
|
|
|
10
|
-
export const schematicFactoryCjsBase64 =
|
|
10
|
+
export const schematicFactoryCjsBase64 =
|
|
11
|
+
'${encodedContent}'
|
|
11
12
|
|
|
12
13
|
${WRITE_SCHEMATIC_FACTORY_FUNCTION}
|
|
13
14
|
`;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export * from './esbuild-config.
|
|
2
|
-
export * from './cjs-content.
|
|
3
|
-
export * from './encoded-content.
|
|
4
|
-
export * from './generated-file-content.
|
|
1
|
+
export * from './esbuild-config.js';
|
|
2
|
+
export * from './cjs-content.js';
|
|
3
|
+
export * from './encoded-content.js';
|
|
4
|
+
export * from './generated-file-content.js';
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export * from "./esbuild-config.
|
|
2
|
-
export * from "./cjs-content.
|
|
3
|
-
export * from "./encoded-content.
|
|
4
|
-
export * from "./generated-file-content.
|
|
1
|
+
export * from "./esbuild-config.js";
|
|
2
|
+
export * from "./cjs-content.js";
|
|
3
|
+
export * from "./encoded-content.js";
|
|
4
|
+
export * from "./generated-file-content.js";
|
package/dist/scripts/index.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export * from './schematic-build.
|
|
1
|
+
export * from './schematic-build.js';
|
package/dist/scripts/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export * from "./schematic-build.
|
|
1
|
+
export * from "./schematic-build.js";
|
|
@@ -9,7 +9,7 @@ const helperScanRoots = [
|
|
|
9
9
|
'scripts/raijin',
|
|
10
10
|
'README.md',
|
|
11
11
|
'README_EN.md',
|
|
12
|
-
'code/code-schematics/src/scripts/schematic-smoke.
|
|
12
|
+
'code/code-schematics/src/scripts/schematic-smoke.ts',
|
|
13
13
|
'docs/README.md',
|
|
14
14
|
'docs/README.ru.md',
|
|
15
15
|
'docs/raijin/README.md',
|
|
@@ -100,13 +100,14 @@ const prepareCollectionDir = async (repoRoot, collectionDir) => {
|
|
|
100
100
|
process.chdir(previousCwd);
|
|
101
101
|
}
|
|
102
102
|
};
|
|
103
|
-
const runProjectSchematic = async ({ collectionPath, fixtureDir, }) => {
|
|
103
|
+
const runProjectSchematic = async ({ collectionPath, fixtureDir, runtimeCwd, }) => {
|
|
104
104
|
const previousCwd = process.cwd();
|
|
105
105
|
try {
|
|
106
106
|
process.chdir(fixtureDir);
|
|
107
107
|
const exitCode = await runSchematicHelper('project', {
|
|
108
108
|
type: 'project',
|
|
109
109
|
cwd: fixtureDir,
|
|
110
|
+
runtimeCwd,
|
|
110
111
|
}, collectionPath);
|
|
111
112
|
if (exitCode !== 0) {
|
|
112
113
|
throw new Error(`Schematic workflow failed with exit code ${exitCode}`);
|
|
@@ -154,6 +155,7 @@ const runSchematicSmoke = async () => {
|
|
|
154
155
|
await runProjectSchematic({
|
|
155
156
|
collectionPath: path.join(collectionDir, 'collection.json'),
|
|
156
157
|
fixtureDir,
|
|
158
|
+
runtimeCwd: repoRoot,
|
|
157
159
|
});
|
|
158
160
|
console.log('Schematic smoke: checking fixture');
|
|
159
161
|
await assertGeneratedFixture(fixtureDir);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@atls/code-schematics",
|
|
3
|
-
"version": "2.0.
|
|
3
|
+
"version": "2.0.30",
|
|
4
4
|
"license": "BSD-3-Clause",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"exports": {
|
|
@@ -17,10 +17,10 @@
|
|
|
17
17
|
"scripts": {
|
|
18
18
|
"build": "yarn run build:schematic-factory && yarn run build:library",
|
|
19
19
|
"build:library": "yarn library build",
|
|
20
|
-
"build:schematic-factory": "yarn node ./src/scripts/schematic-factory-build.
|
|
20
|
+
"build:schematic-factory": "yarn node ./src/scripts/schematic-factory-build.ts",
|
|
21
21
|
"prepack": "yarn run build",
|
|
22
22
|
"postpack": "rm -rf dist",
|
|
23
|
-
"smoke:schematic": "yarn node ./src/scripts/schematic-smoke.
|
|
23
|
+
"smoke:schematic": "yarn node ./src/scripts/schematic-smoke.ts"
|
|
24
24
|
},
|
|
25
25
|
"dependencies": {
|
|
26
26
|
"@angular-devkit/core": "19.1.5",
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
/package/dist/scripts/exceptions/{undefined-build-result.exception.js → undefined-build-result.js}
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
/package/dist/scripts/getters/{generated-file-content.getter.d.ts → generated-file-content.d.ts}
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|