@aerogel/cli 0.0.0-next.59bf5f7cc06e728d0cf6c00de28f1da48d7d6b8e → 0.0.0-next.60462e474474f4e52d52d457f9150df63c117214

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 (75) hide show
  1. package/bin/gel +4 -0
  2. package/dist/aerogel-cli.d.ts +2 -2
  3. package/dist/aerogel-cli.js +793 -0
  4. package/dist/aerogel-cli.js.map +1 -0
  5. package/package.json +27 -33
  6. package/src/cli.ts +28 -6
  7. package/src/commands/Command.ts +14 -9
  8. package/src/commands/create.test.ts +14 -6
  9. package/src/commands/create.ts +25 -14
  10. package/src/commands/generate-component.test.ts +51 -4
  11. package/src/commands/generate-component.ts +167 -26
  12. package/src/commands/generate-model.test.ts +3 -3
  13. package/src/commands/generate-model.ts +24 -27
  14. package/src/commands/generate-service.test.ts +21 -0
  15. package/src/commands/generate-service.ts +151 -0
  16. package/src/commands/info.ts +15 -0
  17. package/src/commands/install.test.ts +27 -0
  18. package/src/commands/install.ts +32 -0
  19. package/src/lib/App.ts +67 -9
  20. package/src/lib/Editor.ts +57 -0
  21. package/src/lib/File.mock.ts +7 -11
  22. package/src/lib/File.ts +9 -3
  23. package/src/lib/Log.mock.ts +5 -8
  24. package/src/lib/Log.test.ts +4 -4
  25. package/src/lib/Log.ts +13 -11
  26. package/src/lib/Shell.mock.ts +3 -3
  27. package/src/lib/Shell.ts +2 -2
  28. package/src/lib/Template.ts +24 -17
  29. package/src/lib/utils/app.ts +15 -0
  30. package/src/lib/utils/edit.ts +44 -0
  31. package/src/lib/utils/paths.ts +42 -0
  32. package/src/plugins/Plugin.ts +159 -0
  33. package/src/plugins/Solid.ts +71 -0
  34. package/src/plugins/Soukai.ts +19 -0
  35. package/src/testing/setup.ts +56 -27
  36. package/templates/app/.github/workflows/ci.yml +16 -4
  37. package/templates/app/.nvmrc +1 -1
  38. package/templates/app/.vscode/launch.json +17 -0
  39. package/templates/app/.vscode/settings.json +10 -0
  40. package/templates/app/README.md +3 -0
  41. package/templates/app/cypress/cypress.config.ts +14 -0
  42. package/templates/app/cypress/support/e2e.ts +1 -3
  43. package/templates/app/cypress/tsconfig.json +7 -8
  44. package/templates/app/index.html +5 -4
  45. package/templates/app/package.json +42 -19
  46. package/templates/app/src/App.vue +6 -4
  47. package/templates/app/src/assets/css/main.css +4 -0
  48. package/templates/app/src/assets/public/robots.txt +2 -0
  49. package/templates/app/src/main.ts +4 -4
  50. package/templates/app/src/types/globals.d.ts +0 -1
  51. package/templates/app/tsconfig.json +3 -9
  52. package/templates/app/vite.config.ts +15 -8
  53. package/templates/component-button/[component.name].vue +42 -0
  54. package/templates/component-button-story/[component.name].story.vue +77 -0
  55. package/templates/component-checkbox/[component.name].vue +34 -0
  56. package/templates/component-checkbox-story/[component.name].story.vue +63 -0
  57. package/templates/component-input/[component.name].vue +17 -0
  58. package/templates/component-input-story/[component.name].story.vue +63 -0
  59. package/templates/service/[service.name].ts +8 -0
  60. package/.eslintrc.js +0 -7
  61. package/bin/ag +0 -4
  62. package/dist/aerogel-cli.cjs.js +0 -2
  63. package/dist/aerogel-cli.cjs.js.map +0 -1
  64. package/dist/aerogel-cli.esm.js +0 -2
  65. package/dist/aerogel-cli.esm.js.map +0 -1
  66. package/noeldemartin.config.js +0 -4
  67. package/src/lib/utils.test.ts +0 -33
  68. package/src/lib/utils.ts +0 -44
  69. package/templates/app/cypress.config.ts +0 -8
  70. package/templates/app/postcss.config.js +0 -6
  71. package/templates/app/src/assets/styles.css +0 -3
  72. package/templates/app/tailwind.config.js +0 -5
  73. package/tsconfig.json +0 -11
  74. package/vite.config.ts +0 -14
  75. /package/src/{main.ts → index.ts} +0 -0
package/src/lib/App.ts CHANGED
@@ -1,32 +1,90 @@
1
1
  import { stringToSlug } from '@noeldemartin/utils';
2
2
 
3
- import File from '@/lib/File';
4
- import Log from '@/lib/Log';
5
- import Template from '@/lib/Template';
6
- import { basePath } from '@/lib/utils';
3
+ import File from '@aerogel/cli/lib/File';
4
+ import Log from '@aerogel/cli/lib/Log';
5
+ import Template from '@aerogel/cli/lib/Template';
6
+ import { packNotFound, packagePackPath, packagePath, templatePath } from '@aerogel/cli/lib/utils/paths';
7
+ import { Editor } from '@aerogel/cli/lib/Editor';
8
+
9
+ interface Dependencies {
10
+ aerogelCli: string;
11
+ aerogelCore: string;
12
+ aerogelCypress: string;
13
+ aerogelPluginI18n: string;
14
+ aerogelPluginSoukai: string;
15
+ aerogelVite: string;
16
+ }
7
17
 
8
18
  export interface Options {
9
19
  local?: boolean;
20
+ linkedLocal?: boolean;
10
21
  }
11
22
 
12
23
  export default class App {
13
24
 
14
- constructor(protected name: string, protected options: Options = {}) {}
25
+ constructor(
26
+ protected name: string,
27
+ protected options: Options = {},
28
+ ) {}
15
29
 
16
30
  public create(path: string): void {
17
31
  if (File.exists(path) && (!File.isDirectory(path) || !File.isEmptyDirectory(path))) {
18
32
  Log.fail(`Folder at '${path}' already exists!`);
19
33
  }
20
34
 
21
- Template.instantiate(basePath('templates/app'), path, {
35
+ Template.instantiate(templatePath('app'), path, {
22
36
  app: {
23
37
  name: this.name,
24
38
  slug: stringToSlug(this.name),
25
39
  },
26
- local: this.options.local && {
27
- aerogelPath: basePath('../'),
28
- },
40
+ dependencies: this.getDependencies(),
41
+ contentPath: this.options.linkedLocal
42
+ ? `${packagePath('core')}/dist/**/*.js`
43
+ : './node_modules/@aerogel/core/dist/**/*.js',
29
44
  });
30
45
  }
31
46
 
47
+ public edit(): Editor {
48
+ return new Editor();
49
+ }
50
+
51
+ protected getDependencies(): Dependencies {
52
+ const withFilePrefix = <T extends Record<string, string>>(paths: T) =>
53
+ Object.entries(paths).reduce(
54
+ (pathsWithFile, [name, path]) => Object.assign(pathsWithFile, { [name]: `file:${path}` }) as T,
55
+ {} as T,
56
+ );
57
+
58
+ if (this.options.linkedLocal) {
59
+ return withFilePrefix({
60
+ aerogelCli: packagePath('cli'),
61
+ aerogelCore: packagePath('core'),
62
+ aerogelCypress: packagePath('cypress'),
63
+ aerogelPluginI18n: packagePath('plugin-i18n'),
64
+ aerogelPluginSoukai: packagePath('plugin-soukai'),
65
+ aerogelVite: packagePath('vite'),
66
+ });
67
+ }
68
+
69
+ if (this.options.local) {
70
+ return withFilePrefix({
71
+ aerogelCli: packagePackPath('cli') ?? packNotFound('cli'),
72
+ aerogelCore: packagePackPath('core') ?? packNotFound('core'),
73
+ aerogelCypress: packagePackPath('cypress') ?? packNotFound('cypress'),
74
+ aerogelPluginI18n: packagePackPath('plugin-i18n') ?? packNotFound('plugin-i18n'),
75
+ aerogelPluginSoukai: packagePackPath('plugin-soukai') ?? packNotFound('plugin-soukai'),
76
+ aerogelVite: packagePackPath('vite') ?? packNotFound('vite'),
77
+ });
78
+ }
79
+
80
+ return {
81
+ aerogelCli: 'next',
82
+ aerogelCore: 'next',
83
+ aerogelCypress: 'next',
84
+ aerogelPluginI18n: 'next',
85
+ aerogelPluginSoukai: 'next',
86
+ aerogelVite: 'next',
87
+ };
88
+ }
89
+
32
90
  }
@@ -0,0 +1,57 @@
1
+ import { arrayFrom } from '@noeldemartin/utils';
2
+ import { Project } from 'ts-morph';
3
+ import type { SourceFile } from 'ts-morph';
4
+
5
+ import File from '@aerogel/cli/lib/File';
6
+ import Log from '@aerogel/cli/lib/Log';
7
+ import Shell from '@aerogel/cli/lib/Shell';
8
+
9
+ export class Editor {
10
+
11
+ private project: Project;
12
+ private modifiedFiles: Set<string>;
13
+
14
+ constructor() {
15
+ this.project = new Project({ tsConfigFilePath: 'tsconfig.json' });
16
+ this.modifiedFiles = new Set();
17
+
18
+ this.project.addSourceFilesAtPaths('src/**/*.ts');
19
+ this.project.addSourceFilesAtPaths('vite.config.ts');
20
+ this.project.addSourceFilesAtPaths('package.json');
21
+ }
22
+
23
+ public addSourceFile(path: string): void {
24
+ this.project.addSourceFilesAtPaths(path);
25
+ }
26
+
27
+ public requireSourceFile(path: string): SourceFile {
28
+ return this.project.getSourceFileOrThrow(path);
29
+ }
30
+
31
+ public async format(): Promise<void> {
32
+ await Log.animate('Formatting modified files', async () => {
33
+ const usingPrettier = File.exists('prettier.config.js') || File.contains('package.json', '"prettier": {');
34
+ const usingESLint = File.exists('.eslintrc.js') || File.contains('package.json', '"eslintConfig"');
35
+ const usingPrettierESLint = File.contains('package.json', '"prettier-eslint-cli"');
36
+ const formatFile = usingPrettierESLint
37
+ ? (file: string) => Shell.run(`npx prettier-eslint ${file} --write`)
38
+ : async (file: string) => {
39
+ usingPrettier && (await Shell.run(`npx prettier ${file} --write`));
40
+ file.match(/\.(ts|js|vue)$/) && usingESLint && (await Shell.run(`npx eslint ${file} --fix`));
41
+ };
42
+
43
+ await Promise.all(arrayFrom(this.modifiedFiles).map(async (file) => formatFile(file)));
44
+ });
45
+ }
46
+
47
+ public async save(file: SourceFile): Promise<void> {
48
+ await file.save();
49
+
50
+ this.addModifiedFile(file.getFilePath());
51
+ }
52
+
53
+ public addModifiedFile(path: string): void {
54
+ this.modifiedFiles.add(path);
55
+ }
56
+
57
+ }
@@ -8,28 +8,28 @@ export class FileMockService extends FileService {
8
8
 
9
9
  private virtualFilesystem: Record<string, string | { directory: true }> = {};
10
10
 
11
- public exists(path: string): boolean {
11
+ public override exists(path: string): boolean {
12
12
  return super.exists(path) || path in this.virtualFilesystem;
13
13
  }
14
14
 
15
- public isDirectory(path: string): boolean {
15
+ public override isDirectory(path: string): boolean {
16
16
  return (
17
17
  super.isDirectory(path) ||
18
18
  (path in this.virtualFilesystem && typeof this.virtualFilesystem[path] === 'object')
19
19
  );
20
20
  }
21
21
 
22
- public isFile(path: string): boolean {
22
+ public override isFile(path: string): boolean {
23
23
  return (
24
24
  super.isFile(path) || (path in this.virtualFilesystem && typeof this.virtualFilesystem[path] === 'string')
25
25
  );
26
26
  }
27
27
 
28
- public makeDirectory(path: string): void {
28
+ public override makeDirectory(path: string): void {
29
29
  this.virtualFilesystem[path] = { directory: true };
30
30
  }
31
31
 
32
- public read(path: string): string | null {
32
+ public override read(path: string): string | null {
33
33
  if (path in this.virtualFilesystem && typeof this.virtualFilesystem[path] === 'string') {
34
34
  return this.virtualFilesystem[path] as string;
35
35
  }
@@ -37,14 +37,10 @@ export class FileMockService extends FileService {
37
37
  return super.read(path);
38
38
  }
39
39
 
40
- public write(path: string, contents: string): void {
40
+ public override write(path: string, contents: string): void {
41
41
  this.virtualFilesystem[path] = contents;
42
42
  }
43
43
 
44
- public reset(): void {
45
- this.virtualFilesystem = {};
46
- }
47
-
48
44
  public expectCreated(path: string, expectContent?: (contents: string) => void): Assertion<string> {
49
45
  expect(typeof this.virtualFilesystem[path] === 'string', `expected '${path}' file to have been created`).toBe(
50
46
  true,
@@ -63,4 +59,4 @@ export class FileMockService extends FileService {
63
59
 
64
60
  }
65
61
 
66
- export default facade(new FileMockService());
62
+ export default facade(FileMockService);
package/src/lib/File.ts CHANGED
@@ -1,6 +1,6 @@
1
- import { existsSync, lstatSync, mkdirSync, readFileSync, readdirSync, writeFileSync } from 'fs';
1
+ import { existsSync, lstatSync, mkdirSync, readFileSync, readdirSync, writeFileSync } from 'node:fs';
2
2
  import { facade } from '@noeldemartin/utils';
3
- import { dirname, resolve } from 'path';
3
+ import { dirname, resolve } from 'node:path';
4
4
 
5
5
  export class FileService {
6
6
 
@@ -12,6 +12,12 @@ export class FileService {
12
12
  return existsSync(path);
13
13
  }
14
14
 
15
+ public isSymlink(path: string): boolean {
16
+ const stats = lstatSync(path);
17
+
18
+ return stats.isSymbolicLink();
19
+ }
20
+
15
21
  public read(path: string): string | null {
16
22
  if (!this.isFile(path)) {
17
23
  return null;
@@ -67,4 +73,4 @@ export class FileService {
67
73
 
68
74
  }
69
75
 
70
- export default facade(new FileService());
76
+ export default facade(FileService);
@@ -15,22 +15,19 @@ export class LogServiceMock extends LogService {
15
15
  expect(this.logs, `Expected log to have length ${count}`).toHaveLength(count);
16
16
  }
17
17
 
18
- protected logLine(message: string): void {
18
+ protected override logLine(message: string): void {
19
19
  this.logs.push(message);
20
20
  }
21
21
 
22
- public fail(message: string): void {
22
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
23
+ public override fail<T = any>(message: string): T {
23
24
  throw new Error(`Fail: ${message}`);
24
25
  }
25
26
 
26
- public reset(): void {
27
- this.logs = [];
28
- }
29
-
30
- protected stdout(): void {
27
+ protected override stdout(): void {
31
28
  //
32
29
  }
33
30
 
34
31
  }
35
32
 
36
- export default facade(new LogServiceMock());
33
+ export default facade(LogServiceMock);
@@ -1,11 +1,11 @@
1
- import { bold, hex } from 'chalk';
1
+ import chalk from 'chalk';
2
2
  import { describe, it } from 'vitest';
3
3
 
4
- import LogMock from '@/lib/Log.mock';
4
+ import LogMock from '@aerogel/cli/lib/Log.mock';
5
5
 
6
6
  import Log from './Log';
7
7
 
8
- const info = hex('#00ffff');
8
+ const info = chalk.hex('#00ffff');
9
9
 
10
10
  describe('Log', () => {
11
11
 
@@ -14,7 +14,7 @@ describe('Log', () => {
14
14
  Log.info('Foo **bar**');
15
15
 
16
16
  // Assert
17
- LogMock.expectLogged(info(`Foo ${bold('bar')}`));
17
+ LogMock.expectLogged(info(`Foo ${chalk.bold('bar')}`));
18
18
  });
19
19
 
20
20
  it('renders multiline messages', () => {
package/src/lib/Log.ts CHANGED
@@ -1,16 +1,17 @@
1
+ import chalk from 'chalk';
2
+ import { clearLine, cursorTo } from 'node:readline';
1
3
  import { facade, stringMatchAll } from '@noeldemartin/utils';
2
- import { bold, hex } from 'chalk';
3
- import { clearLine, cursorTo } from 'readline';
4
4
 
5
5
  export class LogService {
6
6
 
7
- protected renderInfo = hex('#00ffff');
8
- protected renderSuccess = hex('#00ff00');
9
- protected renderError = hex('#ff0000');
7
+ protected renderInfo = chalk.hex('#00ffff');
8
+ protected renderSuccess = chalk.hex('#00ff00');
9
+ protected renderError = chalk.hex('#ff0000');
10
10
 
11
11
  public async animate<T>(message: string, operation: () => Promise<T>): Promise<T> {
12
- const updateStdout = (end: string = '') => {
13
- const progress = this.renderInfo(this.renderMarkdown(message) + '.'.repeat(frame % 4)) + end;
12
+ const updateStdout = (end: string = '', done: boolean = false) => {
13
+ const progress =
14
+ this.renderInfo(this.renderMarkdown(message) + (done ? '...' : '.'.repeat(frame % 4))) + end;
14
15
 
15
16
  this.stdout(progress);
16
17
  };
@@ -23,7 +24,7 @@ export class LogService {
23
24
  const result = await operation();
24
25
 
25
26
  clearInterval(interval);
26
- updateStdout('\n');
27
+ updateStdout('\n', true);
27
28
 
28
29
  return result;
29
30
  }
@@ -36,7 +37,8 @@ export class LogService {
36
37
  this.log(this.renderMarkdown(message), this.renderError);
37
38
  }
38
39
 
39
- public fail(message: string): void {
40
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
41
+ public fail<T = any>(message: string): T {
40
42
  this.error(message);
41
43
 
42
44
  process.exit(1);
@@ -50,7 +52,7 @@ export class LogService {
50
52
  const matches = stringMatchAll<2>(message, /\*\*(.*)\*\*/g);
51
53
 
52
54
  for (const match of matches) {
53
- message = message.replace(match[0], bold(match[1]));
55
+ message = message.replace(match[0], chalk.bold(match[1]));
54
56
  }
55
57
 
56
58
  return message;
@@ -90,4 +92,4 @@ export class LogService {
90
92
 
91
93
  }
92
94
 
93
- export default facade(new LogService());
95
+ export default facade(LogService);
@@ -7,8 +7,8 @@ export class ShellServiceMock extends ShellService {
7
7
 
8
8
  private history: string[] = [];
9
9
 
10
- public async run(command: string): Promise<void> {
11
- this.history.push(command);
10
+ public override async run(command: string): Promise<void> {
11
+ this.history.push(command.trim());
12
12
  }
13
13
 
14
14
  public expectRan(command: string): void {
@@ -17,4 +17,4 @@ export class ShellServiceMock extends ShellService {
17
17
 
18
18
  }
19
19
 
20
- export default facade(new ShellServiceMock());
20
+ export default facade(ShellServiceMock);
package/src/lib/Shell.ts CHANGED
@@ -1,4 +1,4 @@
1
- import { exec } from 'child_process';
1
+ import { exec } from 'node:child_process';
2
2
  import { facade } from '@noeldemartin/utils';
3
3
 
4
4
  export class ShellService {
@@ -25,4 +25,4 @@ export class ShellService {
25
25
 
26
26
  }
27
27
 
28
- export default facade(new ShellService());
28
+ export default facade(ShellService);
@@ -1,12 +1,16 @@
1
- import { readFileSync } from 'fs';
2
- import { render } from 'mustache';
1
+ import Mustache from 'mustache';
2
+ import { readFileSync } from 'node:fs';
3
3
  import { toString } from '@noeldemartin/utils';
4
4
 
5
- import File from '@/lib/File';
5
+ import File from '@aerogel/cli/lib/File';
6
6
 
7
7
  export default class Template {
8
8
 
9
- public static instantiate(path: string, destination: string, replacements: Record<string, unknown>): string[] {
9
+ public static instantiate(
10
+ path: string,
11
+ destination: string = './',
12
+ replacements: Record<string, unknown> = {},
13
+ ): string[] {
10
14
  const template = new Template(path);
11
15
 
12
16
  return template.instantiate(destination, replacements);
@@ -28,7 +32,7 @@ export default class Template {
28
32
  const filePath =
29
33
  destination + (relativePath.endsWith('.template') ? relativePath.slice(0, -9) : relativePath);
30
34
 
31
- File.write(filePath, render(fileContents, replacements, undefined, ['<%', '%>']));
35
+ File.write(filePath, Mustache.render(fileContents, replacements, undefined, ['<%', '%>']));
32
36
  files.push(filePath);
33
37
  }
34
38
 
@@ -39,18 +43,21 @@ export default class Template {
39
43
  replacements: Record<string, unknown>,
40
44
  prefix: string = '',
41
45
  ): Record<string, string> {
42
- return Object.entries(replacements).reduce((filenameReplacements, [key, value]) => {
43
- if (typeof value === 'object') {
44
- Object.assign(
45
- filenameReplacements,
46
- this.getFilenameReplacements(value as Record<string, unknown>, `${key}.`),
47
- );
48
- } else {
49
- filenameReplacements[`[${prefix}${key}]`] = toString(value);
50
- }
51
-
52
- return filenameReplacements;
53
- }, {} as Record<string, string>);
46
+ return Object.entries(replacements).reduce(
47
+ (filenameReplacements, [key, value]) => {
48
+ if (typeof value === 'object') {
49
+ Object.assign(
50
+ filenameReplacements,
51
+ this.getFilenameReplacements(value as Record<string, unknown>, `${key}.`),
52
+ );
53
+ } else {
54
+ filenameReplacements[`[${prefix}${key}]`] = toString(value);
55
+ }
56
+
57
+ return filenameReplacements;
58
+ },
59
+ {} as Record<string, string>,
60
+ );
54
61
  }
55
62
 
56
63
  }
@@ -0,0 +1,15 @@
1
+ import App from '@aerogel/cli/lib/App';
2
+ import File from '@aerogel/cli/lib/File';
3
+
4
+ export function app(): App {
5
+ // TODO parse app name
6
+ return new App('');
7
+ }
8
+
9
+ export function isLocalApp(): boolean {
10
+ return File.contains('package.json', '"@aerogel/core": "file:');
11
+ }
12
+
13
+ export function isLinkedLocalApp(): boolean {
14
+ return File.isSymlink('node_modules/@aerogel/core');
15
+ }
@@ -0,0 +1,44 @@
1
+ import { arrayFrom } from '@noeldemartin/utils';
2
+ import type { Node, SyntaxKind } from 'ts-morph';
3
+
4
+ export function editFiles(): boolean {
5
+ // TODO mock editor instead of relying on this for unit tests
6
+ return true;
7
+ }
8
+
9
+ export function findDescendant<T extends Node>(
10
+ node: Node | undefined,
11
+ options: {
12
+ guard?: (node: Node | undefined) => node is T;
13
+ validate?: (node: T) => boolean;
14
+ skip?: SyntaxKind | SyntaxKind[];
15
+ } = {},
16
+ ): T | undefined {
17
+ if (!node) {
18
+ return;
19
+ }
20
+
21
+ const guard = options.guard ?? (() => true);
22
+ const validate = options.validate ?? (() => true);
23
+ const skipKinds = arrayFrom(options.skip ?? []);
24
+
25
+ return node.forEachDescendant((descendant, traversal) => {
26
+ if (guard(descendant) && validate(descendant as T)) {
27
+ return descendant as T;
28
+ }
29
+
30
+ const descendantKind = descendant.getKind();
31
+
32
+ if (skipKinds.includes(descendantKind)) {
33
+ traversal.skip();
34
+ }
35
+ });
36
+ }
37
+
38
+ export function when<T extends Node>(node: Node | undefined, assertion: (node: Node) => node is T): T | undefined {
39
+ if (!node || !assertion(node)) {
40
+ return;
41
+ }
42
+
43
+ return node as T;
44
+ }
@@ -0,0 +1,42 @@
1
+ import { URL, fileURLToPath } from 'node:url';
2
+ import { stringMatch } from '@noeldemartin/utils';
3
+ import { resolve } from 'node:path';
4
+
5
+ import File from '@aerogel/cli/lib/File';
6
+ import Log from '@aerogel/cli/lib/Log';
7
+
8
+ export function basePath(path: string = ''): string {
9
+ if (
10
+ File.contains(
11
+ fileURLToPath(new URL(/* @vite-ignore */ '../../../package.json', import.meta.url)),
12
+ '"packages/create-aerogel"',
13
+ )
14
+ ) {
15
+ return resolve(fileURLToPath(new URL(/* @vite-ignore */ '../', import.meta.url)), path);
16
+ }
17
+
18
+ const packageJson = File.read(
19
+ fileURLToPath(new URL(/* @vite-ignore */ '../../../../package.json', import.meta.url)),
20
+ );
21
+ const matches = stringMatch<2>(packageJson ?? '', /"@aerogel\/core": "file:(.*)\/aerogel-core-[\d.]*\.tgz"/);
22
+ const cliPath = matches?.[1] ?? Log.fail<string>('Could not determine base path');
23
+
24
+ return resolve(cliPath, path);
25
+ }
26
+
27
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
28
+ export function packNotFound(packageName: string): any {
29
+ return Log.fail(`Could not find ${packageName} pack file, did you run 'npm pack'?`);
30
+ }
31
+
32
+ export function packagePackPath(packageName: string): string | null {
33
+ return File.getFiles(packagePath(packageName)).find((file) => file.endsWith('.tgz')) ?? null;
34
+ }
35
+
36
+ export function packagePath(packageName: string): string {
37
+ return basePath(`../${packageName}`);
38
+ }
39
+
40
+ export function templatePath(name: string): string {
41
+ return fileURLToPath(new URL(/* @vite-ignore */ `../templates/${name}`, import.meta.url));
42
+ }