@atls/code-schematics 2.0.30 → 2.2.0
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/dist/exceptions/index.d.ts +0 -1
- package/dist/exceptions/index.js +0 -1
- package/dist/generated/index.d.ts +1 -0
- package/dist/generated/index.js +1 -0
- package/dist/generated/raijin-schematic-export.d.ts +43 -0
- package/dist/generated/raijin-schematic-export.js +59 -0
- package/dist/generated/schematic-factory-export.d.ts +1 -1
- package/dist/generated/schematic-factory-export.js +1 -1
- package/dist/helpers/index.d.ts +1 -1
- package/dist/helpers/index.js +1 -1
- package/dist/helpers/raijin.d.ts +2 -0
- package/dist/helpers/raijin.js +6 -0
- package/dist/helpers/write-tmp-schematic.js +2 -2
- package/dist/schematic/rules/tsconfig.update.d.ts +1 -2
- package/dist/schematic/rules/tsconfig.update.js +2 -5
- package/dist/schematic/sources/generate-project-specific.source.js +6 -1
- package/dist/scripts/getters/esbuild-config.js +1 -1
- package/dist/scripts/schematic-factory-build.js +5 -0
- package/dist/scripts/schematic-smoke.js +1 -3
- package/package.json +2 -2
- package/dist/exceptions/code-runtime-command.d.ts +0 -3
- package/dist/exceptions/code-runtime-command.js +0 -5
- package/dist/helpers/code-runtime.d.ts +0 -2
- package/dist/helpers/code-runtime.js +0 -47
package/dist/helpers/index.d.ts
CHANGED
package/dist/helpers/index.js
CHANGED
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import tsconfig from '@atls/config-typescript';
|
|
2
|
+
import { writeFiles as writeGeneratedRaijinFiles } from '../generated/raijin-schematic-export.js';
|
|
3
|
+
export const writeRaijinFiles = async (_cwd, baseDir) => {
|
|
4
|
+
await writeGeneratedRaijinFiles(baseDir);
|
|
5
|
+
};
|
|
6
|
+
export const getRaijinCompilerOptions = async (_cwd) => tsconfig.compilerOptions;
|
|
@@ -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
|
-
import {
|
|
4
|
+
import { writeRaijinFiles } from './raijin.js';
|
|
5
5
|
export const writeTmpSchematicHelper = async (tmpDir, cwd = process.cwd()) => {
|
|
6
|
-
await
|
|
6
|
+
await writeRaijinFiles(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'));
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import type { Rule } from '@angular-devkit/schematics';
|
|
2
2
|
interface UpdateTsConfigRuleOptions extends Record<string, string | undefined> {
|
|
3
3
|
cwd?: string;
|
|
4
|
-
runtimeCwd?: string;
|
|
5
4
|
}
|
|
6
|
-
export declare const updateTsConfigRule: (
|
|
5
|
+
export declare const updateTsConfigRule: (_options: UpdateTsConfigRuleOptions) => Rule;
|
|
7
6
|
export {};
|
|
@@ -1,6 +1,3 @@
|
|
|
1
|
-
import
|
|
1
|
+
import tsconfig from '@atls/config-typescript';
|
|
2
2
|
import { updateTsConfigInTree } from '../utils/tsconfig.utils.js';
|
|
3
|
-
export const updateTsConfigRule = (
|
|
4
|
-
const compilerOptions = await getCodeRuntimeCompilerOptions(options.runtimeCwd ?? options.cwd ?? process.cwd());
|
|
5
|
-
return updateTsConfigInTree(compilerOptions);
|
|
6
|
-
};
|
|
3
|
+
export const updateTsConfigRule = (_options) => async () => updateTsConfigInTree(tsconfig.compilerOptions);
|
|
@@ -5,9 +5,14 @@ import { apply } from '@angular-devkit/schematics';
|
|
|
5
5
|
import { url } from '@angular-devkit/schematics';
|
|
6
6
|
import { template } from '@angular-devkit/schematics';
|
|
7
7
|
import { move } from '@angular-devkit/schematics';
|
|
8
|
+
const templateTypes = {
|
|
9
|
+
library: 'libraries',
|
|
10
|
+
project: 'project',
|
|
11
|
+
};
|
|
8
12
|
export const generateProjectSpecificSource = (options) => {
|
|
9
13
|
const { name: projectName } = JSON.parse(readFileSync(join(options.cwd, 'package.json'), 'utf-8'));
|
|
10
|
-
|
|
14
|
+
const templateType = templateTypes[options.type] ?? options.type;
|
|
15
|
+
return apply(url(join('../templates', templateType)), [
|
|
11
16
|
template({
|
|
12
17
|
...strings,
|
|
13
18
|
...options,
|
|
@@ -1,6 +1,11 @@
|
|
|
1
|
+
import { join } from 'node:path';
|
|
1
2
|
import { esbuildBuildStep } from './build-steps/index.js';
|
|
3
|
+
import { generateSchematic } from './schematic-build.js';
|
|
4
|
+
const raijinSchematicDir = join(import.meta.dirname, '../../../../yarn/raijin/src/runtime/schematic');
|
|
5
|
+
const raijinSchematicOutputFile = join(import.meta.dirname, '../generated/raijin-schematic-export.ts');
|
|
2
6
|
try {
|
|
3
7
|
await esbuildBuildStep();
|
|
8
|
+
await generateSchematic(raijinSchematicDir, raijinSchematicOutputFile);
|
|
4
9
|
}
|
|
5
10
|
catch (e) {
|
|
6
11
|
const error = e;
|
|
@@ -100,14 +100,13 @@ 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, }) => {
|
|
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,
|
|
111
110
|
}, collectionPath);
|
|
112
111
|
if (exitCode !== 0) {
|
|
113
112
|
throw new Error(`Schematic workflow failed with exit code ${exitCode}`);
|
|
@@ -155,7 +154,6 @@ const runSchematicSmoke = async () => {
|
|
|
155
154
|
await runProjectSchematic({
|
|
156
155
|
collectionPath: path.join(collectionDir, 'collection.json'),
|
|
157
156
|
fixtureDir,
|
|
158
|
-
runtimeCwd: repoRoot,
|
|
159
157
|
});
|
|
160
158
|
console.log('Schematic smoke: checking fixture');
|
|
161
159
|
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.2.0",
|
|
4
4
|
"license": "BSD-3-Clause",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"exports": {
|
|
@@ -25,11 +25,11 @@
|
|
|
25
25
|
"dependencies": {
|
|
26
26
|
"@angular-devkit/core": "19.1.5",
|
|
27
27
|
"@angular-devkit/schematics": "19.1.5",
|
|
28
|
+
"@atls/config-typescript": "2.0.3",
|
|
28
29
|
"js-yaml": "4.1.0",
|
|
29
30
|
"strip-json-comments": "3.1.1"
|
|
30
31
|
},
|
|
31
32
|
"devDependencies": {
|
|
32
|
-
"@atls/code-runtime": "2.1.34",
|
|
33
33
|
"@types/node": "24.12.2",
|
|
34
34
|
"@yarnpkg/cli": "4.14.1",
|
|
35
35
|
"@yarnpkg/core": "4.7.0",
|
|
@@ -1,47 +0,0 @@
|
|
|
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));
|