@atls/code-schematics 2.1.0 → 2.2.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/dist/exceptions/index.d.ts +1 -0
- package/dist/exceptions/index.js +1 -0
- package/dist/exceptions/schematic-artifact.d.ts +3 -0
- package/dist/exceptions/schematic-artifact.js +9 -0
- package/dist/getters/stream-report-callback.js +4 -5
- package/dist/helpers/events-log.d.ts +1 -1
- package/dist/helpers/events-log.js +1 -1
- package/dist/helpers/index.d.ts +1 -1
- package/dist/helpers/index.js +1 -1
- package/dist/helpers/run-schematics.d.ts +1 -1
- package/dist/helpers/run-schematics.js +3 -3
- package/dist/helpers/schematic-artifact.d.ts +1 -0
- package/dist/helpers/schematic-artifact.js +38 -0
- package/dist/helpers/write-tmp-schematic.d.ts +1 -1
- package/dist/helpers/write-tmp-schematic.js +4 -10
- package/dist/index.d.ts +0 -2
- package/dist/index.js +0 -2
- package/dist/schematic/collection.json +11 -0
- package/dist/schematic/project/project.factory.cjs +34276 -0
- package/dist/schematic/project/schema.json +23 -0
- package/dist/schematic/templates/common/__dot__config/husky/__dot__gitignore +1 -0
- package/dist/schematic/templates/common/__dot__config/husky/commit-msg +4 -0
- package/dist/schematic/templates/common/__dot__config/husky/pre-commit +1 -0
- package/dist/schematic/templates/common/__dot__config/husky/prepare-commit-msg +4 -0
- package/dist/schematic/templates/common/__dot__eslintrc.js +10 -0
- package/dist/schematic/templates/common/__dot__github/workflows/checks__dot__yaml +44 -0
- package/dist/schematic/templates/common/__dot__gitignore +48 -0
- package/dist/schematic/templates/common/__dot__prettierrc.mjs +3 -0
- package/dist/schematic/templates/libraries/__dot__github/workflows/publish__dot__yaml +40 -0
- package/dist/schematic/templates/libraries/__dot__github/workflows/version__dot__yaml +43 -0
- package/dist/schematic/templates/project/__dot__github/workflows/preview__dot__yaml +47 -0
- package/dist/schematic/templates/project/__dot__github/workflows/release__dot__yaml +43 -0
- package/dist/scripts/build-steps/esbuild.build-step.d.ts +1 -1
- package/dist/scripts/build-steps/esbuild.build-step.js +8 -8
- package/dist/scripts/exceptions/undefined-build-result.d.ts +1 -1
- package/dist/scripts/exceptions/undefined-build-result.js +2 -2
- package/dist/scripts/getters/index.d.ts +0 -2
- package/dist/scripts/getters/index.js +0 -2
- package/dist/scripts/index.d.ts +1 -1
- package/dist/scripts/index.js +1 -1
- package/dist/scripts/schematic-factory-build.js +10 -7
- package/dist/scripts/schematic-smoke.js +6 -6
- package/package.json +3 -3
- package/dist/generated/index.d.ts +0 -2
- package/dist/generated/index.js +0 -2
- package/dist/generated/raijin-schematic-export.d.ts +0 -43
- package/dist/generated/raijin-schematic-export.js +0 -59
- package/dist/generated/schematic-factory-export.d.ts +0 -2
- package/dist/generated/schematic-factory-export.js +0 -6
- package/dist/helpers/raijin.d.ts +0 -2
- package/dist/helpers/raijin.js +0 -6
- package/dist/schematic/index.d.ts +0 -1
- package/dist/schematic/index.js +0 -1
- package/dist/schematic/project/factory.d.ts +0 -2
- package/dist/schematic/project/factory.js +0 -45
- package/dist/schematic/project/index.d.ts +0 -1
- package/dist/schematic/project/index.js +0 -1
- package/dist/schematic/rules/index.d.ts +0 -1
- package/dist/schematic/rules/index.js +0 -1
- package/dist/schematic/rules/tsconfig.update.d.ts +0 -6
- package/dist/schematic/rules/tsconfig.update.js +0 -3
- package/dist/schematic/sources/generate-common.source.d.ts +0 -2
- package/dist/schematic/sources/generate-common.source.js +0 -13
- package/dist/schematic/sources/generate-project-specific.source.d.ts +0 -2
- package/dist/schematic/sources/generate-project-specific.source.js +0 -19
- package/dist/schematic/sources/index.d.ts +0 -2
- package/dist/schematic/sources/index.js +0 -2
- package/dist/schematic/utils/file.utils.d.ts +0 -3
- package/dist/schematic/utils/file.utils.js +0 -6
- package/dist/schematic/utils/gitignore.utils.d.ts +0 -3
- package/dist/schematic/utils/gitignore.utils.js +0 -12
- package/dist/schematic/utils/index.d.ts +0 -6
- package/dist/schematic/utils/index.js +0 -6
- package/dist/schematic/utils/json.utils.d.ts +0 -6
- package/dist/schematic/utils/json.utils.js +0 -23
- package/dist/schematic/utils/merge-gitignore-content.utils.d.ts +0 -6
- package/dist/schematic/utils/merge-gitignore-content.utils.js +0 -40
- package/dist/schematic/utils/tsconfig.utils.d.ts +0 -1
- package/dist/schematic/utils/tsconfig.utils.js +0 -5
- package/dist/schematic/utils/yaml.utils.d.ts +0 -5
- package/dist/schematic/utils/yaml.utils.js +0 -18
- package/dist/scripts/getters/encoded-content.d.ts +0 -1
- package/dist/scripts/getters/encoded-content.js +0 -4
- package/dist/scripts/getters/generated-file-content.d.ts +0 -1
- package/dist/scripts/getters/generated-file-content.js +0 -16
- package/dist/scripts/schematic-build.d.ts +0 -1
- package/dist/scripts/schematic-build.js +0 -72
package/dist/helpers/raijin.d.ts
DELETED
package/dist/helpers/raijin.js
DELETED
|
@@ -1,6 +0,0 @@
|
|
|
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 +0,0 @@
|
|
|
1
|
-
export * from './project/index.js';
|
package/dist/schematic/index.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export * from "./project/index.js";
|
|
@@ -1,45 +0,0 @@
|
|
|
1
|
-
import { MergeStrategy } from '@angular-devkit/schematics';
|
|
2
|
-
import { chain } from '@angular-devkit/schematics';
|
|
3
|
-
import { mergeWith } from '@angular-devkit/schematics';
|
|
4
|
-
import { updateTsConfigRule } from '../rules/index.js';
|
|
5
|
-
import { generateCommonSource } from '../sources/index.js';
|
|
6
|
-
import { generateProjectSpecificSource } from '../sources/index.js';
|
|
7
|
-
import { mergeGitIgnoreContent } from '../utils/index.js';
|
|
8
|
-
const GITIGNORE_PATH = '.gitignore';
|
|
9
|
-
const captureGitIgnoreContentRule = (state) => (host) => {
|
|
10
|
-
const gitIgnoreBuffer = host.read(GITIGNORE_PATH);
|
|
11
|
-
if (!gitIgnoreBuffer) {
|
|
12
|
-
return host;
|
|
13
|
-
}
|
|
14
|
-
state.content = gitIgnoreBuffer.toString('utf-8');
|
|
15
|
-
return host;
|
|
16
|
-
};
|
|
17
|
-
const mergeGitIgnoreContentRule = (state) => (host, context) => {
|
|
18
|
-
if (state.content === undefined) {
|
|
19
|
-
return host;
|
|
20
|
-
}
|
|
21
|
-
const gitIgnoreBuffer = host.read(GITIGNORE_PATH);
|
|
22
|
-
if (!gitIgnoreBuffer) {
|
|
23
|
-
return host;
|
|
24
|
-
}
|
|
25
|
-
const templateContent = gitIgnoreBuffer.toString('utf-8');
|
|
26
|
-
const mergedContent = mergeGitIgnoreContent({
|
|
27
|
-
existingContent: state.content,
|
|
28
|
-
templateContent,
|
|
29
|
-
});
|
|
30
|
-
if (mergedContent !== templateContent) {
|
|
31
|
-
context.logger.info('Merging template .gitignore with project-specific entries');
|
|
32
|
-
host.overwrite(GITIGNORE_PATH, mergedContent);
|
|
33
|
-
}
|
|
34
|
-
return host;
|
|
35
|
-
};
|
|
36
|
-
export const main = (options) => {
|
|
37
|
-
const state = {};
|
|
38
|
-
return chain([
|
|
39
|
-
captureGitIgnoreContentRule(state),
|
|
40
|
-
updateTsConfigRule(options),
|
|
41
|
-
mergeWith(generateCommonSource(options), MergeStrategy.Overwrite),
|
|
42
|
-
mergeWith(generateProjectSpecificSource(options), MergeStrategy.Overwrite),
|
|
43
|
-
mergeGitIgnoreContentRule(state),
|
|
44
|
-
]);
|
|
45
|
-
};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export * from './factory.js';
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export * from "./factory.js";
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export * from './tsconfig.update.js';
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export * from "./tsconfig.update.js";
|
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
import { strings } from '@angular-devkit/core';
|
|
2
|
-
import { apply } from '@angular-devkit/schematics';
|
|
3
|
-
import { template } from '@angular-devkit/schematics';
|
|
4
|
-
import { move } from '@angular-devkit/schematics';
|
|
5
|
-
import { url } from '@angular-devkit/schematics';
|
|
6
|
-
export const generateCommonSource = (options) => apply(url('../templates/common'), [
|
|
7
|
-
template({
|
|
8
|
-
...strings,
|
|
9
|
-
...options,
|
|
10
|
-
dot: '.',
|
|
11
|
-
}),
|
|
12
|
-
move('./'),
|
|
13
|
-
]);
|
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
import { readFileSync } from 'node:fs';
|
|
2
|
-
import { join } from 'node:path';
|
|
3
|
-
import { strings } from '@angular-devkit/core';
|
|
4
|
-
import { apply } from '@angular-devkit/schematics';
|
|
5
|
-
import { url } from '@angular-devkit/schematics';
|
|
6
|
-
import { template } from '@angular-devkit/schematics';
|
|
7
|
-
import { move } from '@angular-devkit/schematics';
|
|
8
|
-
export const generateProjectSpecificSource = (options) => {
|
|
9
|
-
const { name: projectName } = JSON.parse(readFileSync(join(options.cwd, 'package.json'), 'utf-8'));
|
|
10
|
-
return apply(url(join('../templates', options.type)), [
|
|
11
|
-
template({
|
|
12
|
-
...strings,
|
|
13
|
-
...options,
|
|
14
|
-
projectName,
|
|
15
|
-
dot: '.',
|
|
16
|
-
}),
|
|
17
|
-
move('./'),
|
|
18
|
-
]);
|
|
19
|
-
};
|
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
const GITIGNORE_PATH = '.gitignore';
|
|
2
|
-
export const updateGitIgnoreInTree = (callback) => (host, context) => {
|
|
3
|
-
if (!host.exists(GITIGNORE_PATH)) {
|
|
4
|
-
host.create(GITIGNORE_PATH, '');
|
|
5
|
-
}
|
|
6
|
-
const gitignoreBuffer = host.read(GITIGNORE_PATH);
|
|
7
|
-
if (!gitignoreBuffer)
|
|
8
|
-
return host;
|
|
9
|
-
const content = gitignoreBuffer.toString('utf-8').split('\n');
|
|
10
|
-
host.overwrite(GITIGNORE_PATH, Array.from(callback(content, context)).join('\n'));
|
|
11
|
-
return host;
|
|
12
|
-
};
|
|
@@ -1,6 +0,0 @@
|
|
|
1
|
-
import type { Rule } from '@angular-devkit/schematics';
|
|
2
|
-
import type { SchematicContext } from '@angular-devkit/schematics';
|
|
3
|
-
import type { Tree } from '@angular-devkit/schematics';
|
|
4
|
-
export declare const serializeJson: (json: string) => string;
|
|
5
|
-
export declare const readJsonInTree: (host: Tree, path: string) => void;
|
|
6
|
-
export declare const updateJsonInTree: <T = any, O = T>(path: string, callback: (json: T, context: SchematicContext) => O) => Rule;
|
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
import stripJsonComments from 'strip-json-comments';
|
|
2
|
-
export const serializeJson = (json) => `${JSON.stringify(json, null, 2)}\n`;
|
|
3
|
-
export const readJsonInTree = (host, path) => {
|
|
4
|
-
if (!host.exists(path)) {
|
|
5
|
-
throw new Error(`Cannot find ${path}`);
|
|
6
|
-
}
|
|
7
|
-
const contents = stripJsonComments(host.read(path)?.toString('utf-8') || '');
|
|
8
|
-
try {
|
|
9
|
-
return JSON.parse(contents);
|
|
10
|
-
}
|
|
11
|
-
catch (e) {
|
|
12
|
-
const error = e;
|
|
13
|
-
throw new Error(`Cannot parse ${path}: ${error.message}`);
|
|
14
|
-
}
|
|
15
|
-
};
|
|
16
|
-
export const updateJsonInTree = (path, callback) => (host, context) => {
|
|
17
|
-
if (!host.exists(path)) {
|
|
18
|
-
host.create(path, serializeJson(callback({}, context)));
|
|
19
|
-
return host;
|
|
20
|
-
}
|
|
21
|
-
host.overwrite(path, serializeJson(callback(readJsonInTree(host, path), context)));
|
|
22
|
-
return host;
|
|
23
|
-
};
|
|
@@ -1,40 +0,0 @@
|
|
|
1
|
-
const PROJECT_SPECIFIC_START_MARKER = '# raijin:begin project-specific gitignore';
|
|
2
|
-
const PROJECT_SPECIFIC_END_MARKER = '# raijin:end project-specific gitignore';
|
|
3
|
-
const normalizeContent = (content) => content.replace(/\r\n/g, '\n');
|
|
4
|
-
const getNormalizedLines = (content) => normalizeContent(content).split('\n');
|
|
5
|
-
const trimTrailingEmptyLines = (lines) => {
|
|
6
|
-
const normalizedLines = [...lines];
|
|
7
|
-
while (normalizedLines.length > 0 && normalizedLines[normalizedLines.length - 1] === '') {
|
|
8
|
-
normalizedLines.pop();
|
|
9
|
-
}
|
|
10
|
-
return normalizedLines;
|
|
11
|
-
};
|
|
12
|
-
const isProjectSpecificLine = (line, templateLineSet) => line !== '' &&
|
|
13
|
-
!templateLineSet.has(line) &&
|
|
14
|
-
line !== PROJECT_SPECIFIC_START_MARKER &&
|
|
15
|
-
line !== PROJECT_SPECIFIC_END_MARKER;
|
|
16
|
-
const getProjectSpecificLines = (existingLines, templateLineSet) => {
|
|
17
|
-
const startIndex = existingLines.indexOf(PROJECT_SPECIFIC_START_MARKER);
|
|
18
|
-
const endIndex = existingLines.indexOf(PROJECT_SPECIFIC_END_MARKER);
|
|
19
|
-
if (startIndex !== -1 && endIndex > startIndex) {
|
|
20
|
-
return Array.from(new Set(existingLines.filter((line) => isProjectSpecificLine(line, templateLineSet))));
|
|
21
|
-
}
|
|
22
|
-
return existingLines.filter((line) => isProjectSpecificLine(line, templateLineSet));
|
|
23
|
-
};
|
|
24
|
-
export const mergeGitIgnoreContent = ({ existingContent, templateContent, }) => {
|
|
25
|
-
const templateLines = getNormalizedLines(templateContent);
|
|
26
|
-
const templateLineSet = new Set(templateLines);
|
|
27
|
-
const existingLines = getNormalizedLines(existingContent);
|
|
28
|
-
const projectSpecificLines = getProjectSpecificLines(existingLines, templateLineSet);
|
|
29
|
-
if (projectSpecificLines.length === 0) {
|
|
30
|
-
return trimTrailingEmptyLines(templateLines).join('\n');
|
|
31
|
-
}
|
|
32
|
-
const mergedLines = trimTrailingEmptyLines(templateLines);
|
|
33
|
-
if (mergedLines.length > 0) {
|
|
34
|
-
mergedLines.push('');
|
|
35
|
-
}
|
|
36
|
-
mergedLines.push(PROJECT_SPECIFIC_START_MARKER);
|
|
37
|
-
mergedLines.push(...projectSpecificLines);
|
|
38
|
-
mergedLines.push(PROJECT_SPECIFIC_END_MARKER);
|
|
39
|
-
return mergedLines.join('\n');
|
|
40
|
-
};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export declare const updateTsConfigInTree: (compilerOptions: object) => import("@angular-devkit/schematics").Rule;
|
|
@@ -1,5 +0,0 @@
|
|
|
1
|
-
import type { Rule } from '@angular-devkit/schematics';
|
|
2
|
-
import type { SchematicContext } from '@angular-devkit/schematics';
|
|
3
|
-
import type { Tree } from '@angular-devkit/schematics';
|
|
4
|
-
export declare const readYamlInTree: <T = any>(host: Tree, path: string) => T;
|
|
5
|
-
export declare const updateYamlInTree: <T = any, O = T>(path: string, callback: (yaml: T, context: SchematicContext) => O) => Rule;
|
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
import { load } from 'js-yaml';
|
|
2
|
-
import { dump } from 'js-yaml';
|
|
3
|
-
export const readYamlInTree = (host, path) => {
|
|
4
|
-
if (!host.exists(path)) {
|
|
5
|
-
throw new Error(`Cannot find ${path}`);
|
|
6
|
-
}
|
|
7
|
-
return load(host.read(path).toString('utf-8'));
|
|
8
|
-
};
|
|
9
|
-
export const updateYamlInTree = (path, callback) => (host, context) => {
|
|
10
|
-
if (!host.exists(path)) {
|
|
11
|
-
return host;
|
|
12
|
-
}
|
|
13
|
-
host.overwrite(path, dump(callback(readYamlInTree(host, path), context), {
|
|
14
|
-
noArrayIndent: true,
|
|
15
|
-
lineWidth: -1,
|
|
16
|
-
}));
|
|
17
|
-
return host;
|
|
18
|
-
};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export declare const getEncodedContent: (cjsContent: string) => string;
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export declare const getGeneratedFileContent: (encodedContent: string) => string;
|
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
const WRITE_SCHEMATIC_FACTORY_FUNCTION = `export const writeSchematicFactory = async (path: string) => {
|
|
2
|
-
const content = Buffer.from(schematicFactoryCjsBase64, 'base64').toString('utf-8')
|
|
3
|
-
const fs = await import('fs/promises')
|
|
4
|
-
await fs.writeFile(path, content)
|
|
5
|
-
}`;
|
|
6
|
-
export const getGeneratedFileContent = (encodedContent) => {
|
|
7
|
-
const generatedFileContent = `// Auto-generated file
|
|
8
|
-
/* eslint-disable */
|
|
9
|
-
|
|
10
|
-
export const schematicFactoryCjsBase64 =
|
|
11
|
-
'${encodedContent}'
|
|
12
|
-
|
|
13
|
-
${WRITE_SCHEMATIC_FACTORY_FUNCTION}
|
|
14
|
-
`;
|
|
15
|
-
return generatedFileContent;
|
|
16
|
-
};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export declare function generateSchematic(schematicDir: string, outputFile: string): Promise<void>;
|
|
@@ -1,72 +0,0 @@
|
|
|
1
|
-
import { readdir } from 'node:fs/promises';
|
|
2
|
-
import { mkdir } from 'node:fs/promises';
|
|
3
|
-
import { writeFile } from 'node:fs/promises';
|
|
4
|
-
import { readFile } from 'node:fs/promises';
|
|
5
|
-
import { join } from 'node:path';
|
|
6
|
-
import { dirname } from 'node:path';
|
|
7
|
-
async function buildFileStructure(dirPath) {
|
|
8
|
-
const result = {};
|
|
9
|
-
const entries = await readdir(dirPath, { withFileTypes: true });
|
|
10
|
-
for (const entry of entries) {
|
|
11
|
-
const fullPath = join(dirPath, entry.name);
|
|
12
|
-
if (entry.isDirectory()) {
|
|
13
|
-
result[entry.name] = await buildFileStructure(fullPath);
|
|
14
|
-
}
|
|
15
|
-
else {
|
|
16
|
-
const content = await readFile(fullPath, 'utf-8');
|
|
17
|
-
result[entry.name] = Buffer.from(content).toString('base64');
|
|
18
|
-
}
|
|
19
|
-
}
|
|
20
|
-
return result;
|
|
21
|
-
}
|
|
22
|
-
function generateModuleContent(structure) {
|
|
23
|
-
const createStructureCode = (obj, indent = '') => {
|
|
24
|
-
let code = '';
|
|
25
|
-
for (const [key, value] of Object.entries(obj)) {
|
|
26
|
-
if (typeof value === 'string') {
|
|
27
|
-
code += `${indent}'${key}': '${value}',\n`;
|
|
28
|
-
}
|
|
29
|
-
else {
|
|
30
|
-
code += `${indent}'${key}': {\n`;
|
|
31
|
-
code += createStructureCode(value, `${indent} `);
|
|
32
|
-
code += `${indent}},\n`;
|
|
33
|
-
}
|
|
34
|
-
}
|
|
35
|
-
return code;
|
|
36
|
-
};
|
|
37
|
-
return `// Auto-generated file
|
|
38
|
-
/* eslint-disable */
|
|
39
|
-
export const assetsStructure = {
|
|
40
|
-
${createStructureCode(structure, ' ')}
|
|
41
|
-
}
|
|
42
|
-
|
|
43
|
-
export async function writeFiles(baseDir: string) {
|
|
44
|
-
const { join } = await import('path')
|
|
45
|
-
const { mkdir, writeFile } = await import('fs/promises')
|
|
46
|
-
|
|
47
|
-
async function writeRecursive(obj: any, currentPath: string) {
|
|
48
|
-
for (const [key, value] of Object.entries(obj)) {
|
|
49
|
-
const fullPath = join(currentPath, key)
|
|
50
|
-
|
|
51
|
-
if (typeof value === 'string') {
|
|
52
|
-
await writeFile(
|
|
53
|
-
fullPath,
|
|
54
|
-
Buffer.from(value, 'base64').toString('utf-8')
|
|
55
|
-
)
|
|
56
|
-
} else {
|
|
57
|
-
await mkdir(fullPath, { recursive: true })
|
|
58
|
-
await writeRecursive(value, fullPath)
|
|
59
|
-
}
|
|
60
|
-
}
|
|
61
|
-
}
|
|
62
|
-
|
|
63
|
-
await writeRecursive(assetsStructure, baseDir)
|
|
64
|
-
}
|
|
65
|
-
`;
|
|
66
|
-
}
|
|
67
|
-
export async function generateSchematic(schematicDir, outputFile) {
|
|
68
|
-
const structure = await buildFileStructure(schematicDir);
|
|
69
|
-
const moduleContent = generateModuleContent(structure);
|
|
70
|
-
await mkdir(dirname(outputFile), { recursive: true });
|
|
71
|
-
await writeFile(outputFile, moduleContent);
|
|
72
|
-
}
|