@atls/code-schematics 2.2.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.
Files changed (87) hide show
  1. package/dist/exceptions/index.d.ts +1 -0
  2. package/dist/exceptions/index.js +1 -0
  3. package/dist/exceptions/schematic-artifact.d.ts +3 -0
  4. package/dist/exceptions/schematic-artifact.js +9 -0
  5. package/dist/getters/stream-report-callback.js +4 -5
  6. package/dist/helpers/events-log.d.ts +1 -1
  7. package/dist/helpers/events-log.js +1 -1
  8. package/dist/helpers/index.d.ts +1 -1
  9. package/dist/helpers/index.js +1 -1
  10. package/dist/helpers/run-schematics.d.ts +1 -1
  11. package/dist/helpers/run-schematics.js +3 -3
  12. package/dist/helpers/schematic-artifact.d.ts +1 -0
  13. package/dist/helpers/schematic-artifact.js +38 -0
  14. package/dist/helpers/write-tmp-schematic.d.ts +1 -1
  15. package/dist/helpers/write-tmp-schematic.js +4 -10
  16. package/dist/index.d.ts +0 -2
  17. package/dist/index.js +0 -2
  18. package/dist/schematic/collection.json +11 -0
  19. package/dist/schematic/project/project.factory.cjs +34276 -0
  20. package/dist/schematic/project/schema.json +23 -0
  21. package/dist/schematic/templates/common/__dot__config/husky/__dot__gitignore +1 -0
  22. package/dist/schematic/templates/common/__dot__config/husky/commit-msg +4 -0
  23. package/dist/schematic/templates/common/__dot__config/husky/pre-commit +1 -0
  24. package/dist/schematic/templates/common/__dot__config/husky/prepare-commit-msg +4 -0
  25. package/dist/schematic/templates/common/__dot__eslintrc.js +10 -0
  26. package/dist/schematic/templates/common/__dot__github/workflows/checks__dot__yaml +44 -0
  27. package/dist/schematic/templates/common/__dot__gitignore +48 -0
  28. package/dist/schematic/templates/common/__dot__prettierrc.mjs +3 -0
  29. package/dist/schematic/templates/libraries/__dot__github/workflows/publish__dot__yaml +40 -0
  30. package/dist/schematic/templates/libraries/__dot__github/workflows/version__dot__yaml +43 -0
  31. package/dist/schematic/templates/project/__dot__github/workflows/preview__dot__yaml +47 -0
  32. package/dist/schematic/templates/project/__dot__github/workflows/release__dot__yaml +43 -0
  33. package/dist/scripts/build-steps/esbuild.build-step.d.ts +1 -1
  34. package/dist/scripts/build-steps/esbuild.build-step.js +8 -8
  35. package/dist/scripts/exceptions/undefined-build-result.d.ts +1 -1
  36. package/dist/scripts/exceptions/undefined-build-result.js +2 -2
  37. package/dist/scripts/getters/index.d.ts +0 -2
  38. package/dist/scripts/getters/index.js +0 -2
  39. package/dist/scripts/index.d.ts +1 -1
  40. package/dist/scripts/index.js +1 -1
  41. package/dist/scripts/schematic-factory-build.js +10 -7
  42. package/dist/scripts/schematic-smoke.js +6 -6
  43. package/package.json +3 -3
  44. package/dist/generated/index.d.ts +0 -2
  45. package/dist/generated/index.js +0 -2
  46. package/dist/generated/raijin-schematic-export.d.ts +0 -43
  47. package/dist/generated/raijin-schematic-export.js +0 -59
  48. package/dist/generated/schematic-factory-export.d.ts +0 -2
  49. package/dist/generated/schematic-factory-export.js +0 -6
  50. package/dist/helpers/raijin.d.ts +0 -2
  51. package/dist/helpers/raijin.js +0 -6
  52. package/dist/schematic/index.d.ts +0 -1
  53. package/dist/schematic/index.js +0 -1
  54. package/dist/schematic/project/factory.d.ts +0 -2
  55. package/dist/schematic/project/factory.js +0 -45
  56. package/dist/schematic/project/index.d.ts +0 -1
  57. package/dist/schematic/project/index.js +0 -1
  58. package/dist/schematic/rules/index.d.ts +0 -1
  59. package/dist/schematic/rules/index.js +0 -1
  60. package/dist/schematic/rules/tsconfig.update.d.ts +0 -6
  61. package/dist/schematic/rules/tsconfig.update.js +0 -3
  62. package/dist/schematic/sources/generate-common.source.d.ts +0 -2
  63. package/dist/schematic/sources/generate-common.source.js +0 -13
  64. package/dist/schematic/sources/generate-project-specific.source.d.ts +0 -2
  65. package/dist/schematic/sources/generate-project-specific.source.js +0 -24
  66. package/dist/schematic/sources/index.d.ts +0 -2
  67. package/dist/schematic/sources/index.js +0 -2
  68. package/dist/schematic/utils/file.utils.d.ts +0 -3
  69. package/dist/schematic/utils/file.utils.js +0 -6
  70. package/dist/schematic/utils/gitignore.utils.d.ts +0 -3
  71. package/dist/schematic/utils/gitignore.utils.js +0 -12
  72. package/dist/schematic/utils/index.d.ts +0 -6
  73. package/dist/schematic/utils/index.js +0 -6
  74. package/dist/schematic/utils/json.utils.d.ts +0 -6
  75. package/dist/schematic/utils/json.utils.js +0 -23
  76. package/dist/schematic/utils/merge-gitignore-content.utils.d.ts +0 -6
  77. package/dist/schematic/utils/merge-gitignore-content.utils.js +0 -40
  78. package/dist/schematic/utils/tsconfig.utils.d.ts +0 -1
  79. package/dist/schematic/utils/tsconfig.utils.js +0 -5
  80. package/dist/schematic/utils/yaml.utils.d.ts +0 -5
  81. package/dist/schematic/utils/yaml.utils.js +0 -18
  82. package/dist/scripts/getters/encoded-content.d.ts +0 -1
  83. package/dist/scripts/getters/encoded-content.js +0 -4
  84. package/dist/scripts/getters/generated-file-content.d.ts +0 -1
  85. package/dist/scripts/getters/generated-file-content.js +0 -16
  86. package/dist/scripts/schematic-build.d.ts +0 -1
  87. package/dist/scripts/schematic-build.js +0 -72
@@ -1 +1,2 @@
1
1
  export * from './schematic-workflow.js';
2
+ export * from './schematic-artifact.js';
@@ -1 +1,2 @@
1
1
  export * from "./schematic-workflow.js";
2
+ export * from "./schematic-artifact.js";
@@ -0,0 +1,3 @@
1
+ export declare class SchematicArtifactException extends Error {
2
+ constructor(candidates: Array<string>);
3
+ }
@@ -0,0 +1,9 @@
1
+ export class SchematicArtifactException extends Error {
2
+ constructor(candidates) {
3
+ super([
4
+ '@atls/code-schematics schematic artifact is missing or incomplete.',
5
+ 'Run `yarn workspace @atls/code-schematics build` before executing schematics.',
6
+ `Checked paths: ${candidates.join(', ')}`,
7
+ ].join(' '));
8
+ }
9
+ }
@@ -1,17 +1,16 @@
1
1
  import { ppath } from '@yarnpkg/fslib';
2
2
  import { xfs } from '@yarnpkg/fslib';
3
- import { runSchematicHelper } from '../helpers/index.js';
4
- import { writeTmpSchematicHelper } from '../helpers/index.js';
3
+ import { runSchematic } from '../helpers/index.js';
4
+ import { writeTmpSchematic } from '../helpers/index.js';
5
5
  import { prepareTmpDir } from '../helpers/index.js';
6
6
  import { ensureSchematicSucceeded } from '../helpers/index.js';
7
7
  export const getStreamReportCallback = async (options) => {
8
8
  const streamReportCallback = async (report) => {
9
9
  const tmpDir = await xfs.mktempPromise();
10
10
  const collectionPath = ppath.join(tmpDir, 'collection.json');
11
- const { cwd } = options;
12
- await writeTmpSchematicHelper(tmpDir, cwd);
11
+ await writeTmpSchematic(tmpDir);
13
12
  await prepareTmpDir(tmpDir);
14
- ensureSchematicSucceeded(await runSchematicHelper('project', options, collectionPath));
13
+ ensureSchematicSucceeded(await runSchematic('project', options, collectionPath));
15
14
  };
16
15
  return streamReportCallback;
17
16
  };
@@ -1,2 +1,2 @@
1
1
  import type { DryRunEvent } from '@angular-devkit/schematics';
2
- export declare const eventsLogHelper: (event: DryRunEvent) => void;
2
+ export declare const logSchematicEvent: (event: DryRunEvent) => void;
@@ -1,4 +1,4 @@
1
- export const eventsLogHelper = (event) => {
1
+ export const logSchematicEvent = (event) => {
2
2
  const eventPath = event.path;
3
3
  switch (event.kind) {
4
4
  case 'error':
@@ -1,5 +1,5 @@
1
1
  export * from './run-schematics.js';
2
2
  export * from './write-tmp-schematic.js';
3
3
  export * from './prepare-tmp-dir.js';
4
- export * from './raijin.js';
4
+ export * from './schematic-artifact.js';
5
5
  export * from './schematic-result.js';
@@ -1,5 +1,5 @@
1
1
  export * from "./run-schematics.js";
2
2
  export * from "./write-tmp-schematic.js";
3
3
  export * from "./prepare-tmp-dir.js";
4
- export * from "./raijin.js";
4
+ export * from "./schematic-artifact.js";
5
5
  export * from "./schematic-result.js";
@@ -1 +1 @@
1
- export declare const runSchematicHelper: (schematicName: string, options: Record<string, string>, collectionPath: string) => Promise<0 | 1>;
1
+ export declare const runSchematic: (schematicName: string, options: Record<string, string>, collectionPath: string) => Promise<0 | 1>;
@@ -1,7 +1,7 @@
1
1
  import { UnsuccessfulWorkflowExecution } from '@angular-devkit/schematics';
2
2
  import { NodeWorkflow } from '@angular-devkit/schematics/tools';
3
- import { eventsLogHelper } from './events-log.js';
4
- export const runSchematicHelper = async (schematicName, options, collectionPath) => {
3
+ import { logSchematicEvent } from './events-log.js';
4
+ export const runSchematic = async (schematicName, options, collectionPath) => {
5
5
  const dryRun = false;
6
6
  const debug = true;
7
7
  let nothingDone = true;
@@ -13,7 +13,7 @@ export const runSchematicHelper = async (schematicName, options, collectionPath)
13
13
  });
14
14
  workflow.reporter.subscribe((event) => {
15
15
  nothingDone = false;
16
- eventsLogHelper(event);
16
+ logSchematicEvent(event);
17
17
  });
18
18
  try {
19
19
  await workflow
@@ -0,0 +1 @@
1
+ export declare const writeSchematicArtifact: (baseDir: string) => Promise<void>;
@@ -0,0 +1,38 @@
1
+ import { access } from 'node:fs/promises';
2
+ import { cp } from 'node:fs/promises';
3
+ import { join } from 'node:path';
4
+ import { SchematicArtifactException } from '../exceptions/index.js';
5
+ const REQUIRED_ARTIFACT_FILES = ['collection.json', 'project/project.factory.cjs'];
6
+ const pathExists = async (path) => {
7
+ try {
8
+ await access(path);
9
+ return true;
10
+ }
11
+ catch {
12
+ return false;
13
+ }
14
+ };
15
+ const getSchematicArtifactCandidates = () => [
16
+ join(import.meta.dirname, '../schematic'),
17
+ join(import.meta.dirname, '../../dist/schematic'),
18
+ ];
19
+ const isSchematicArtifact = async (candidate) => {
20
+ const checks = await Promise.all(REQUIRED_ARTIFACT_FILES.map(async (requiredFile) => pathExists(join(candidate, requiredFile))));
21
+ return checks.every(Boolean);
22
+ };
23
+ const resolveSchematicArtifactDir = async () => {
24
+ const candidates = getSchematicArtifactCandidates();
25
+ const existingArtifacts = await Promise.all(candidates.map(async (candidate) => ({
26
+ candidate,
27
+ exists: await isSchematicArtifact(candidate),
28
+ })));
29
+ const artifact = existingArtifacts.find(({ exists }) => exists);
30
+ if (artifact) {
31
+ return artifact.candidate;
32
+ }
33
+ throw new SchematicArtifactException(candidates);
34
+ };
35
+ export const writeSchematicArtifact = async (baseDir) => {
36
+ const schematicArtifactDir = await resolveSchematicArtifactDir();
37
+ await cp(schematicArtifactDir, baseDir, { recursive: true });
38
+ };
@@ -1,2 +1,2 @@
1
1
  import type { PortablePath } from '@yarnpkg/fslib';
2
- export declare const writeTmpSchematicHelper: (tmpDir: PortablePath, cwd?: string) => Promise<void>;
2
+ export declare const writeTmpSchematic: (tmpDir: PortablePath) => Promise<void>;
@@ -1,11 +1,5 @@
1
- import { mkdir } from 'node:fs/promises';
2
- import { ppath } from '@yarnpkg/fslib';
3
- import { writeSchematicFactory } from '../generated/index.js';
4
- import { writeRaijinFiles } from './raijin.js';
5
- export const writeTmpSchematicHelper = async (tmpDir, cwd = process.cwd()) => {
6
- await writeRaijinFiles(cwd, tmpDir);
7
- const projectDir = ppath.join(tmpDir, 'project');
8
- await mkdir(projectDir, { recursive: true });
9
- await writeSchematicFactory(ppath.join(projectDir, 'project.factory.cjs'));
10
- console.info('All Schematic files writed to the tmp!');
1
+ import { writeSchematicArtifact } from './schematic-artifact.js';
2
+ export const writeTmpSchematic = async (tmpDir) => {
3
+ await writeSchematicArtifact(tmpDir);
4
+ console.info('Schematic collection written to temporary directory.');
11
5
  };
package/dist/index.d.ts CHANGED
@@ -1,4 +1,2 @@
1
1
  export * from './getters/index.js';
2
2
  export * from './helpers/index.js';
3
- export * from './generated/index.js';
4
- export * from './scripts/index.js';
package/dist/index.js CHANGED
@@ -1,4 +1,2 @@
1
1
  export * from "./getters/index.js";
2
2
  export * from "./helpers/index.js";
3
- export * from "./generated/index.js";
4
- export * from "./scripts/index.js";
@@ -0,0 +1,11 @@
1
+ {
2
+ "name": "@atls/schematics",
3
+ "version": "0.1",
4
+ "schematics": {
5
+ "project": {
6
+ "factory": "./project/project.factory.cjs#main",
7
+ "schema": "./project/schema.json",
8
+ "description": "Project schematic"
9
+ }
10
+ }
11
+ }