@aerogel/cli 0.0.0-next.0be1479064cfd43fb6eafa2552cb7f8775554d93 → 0.0.0-next.0d1cf82f9dfbe1d3e7ec5644f85f97a43c8c2334

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 (83) hide show
  1. package/bin/gel +4 -0
  2. package/dist/aerogel-cli.d.ts +2 -2
  3. package/dist/aerogel-cli.js +847 -0
  4. package/dist/aerogel-cli.js.map +1 -0
  5. package/package.json +25 -32
  6. package/src/cli.ts +28 -8
  7. package/src/commands/Command.ts +14 -9
  8. package/src/commands/create.test.ts +12 -3
  9. package/src/commands/create.ts +15 -12
  10. package/src/commands/generate-component.test.ts +50 -3
  11. package/src/commands/generate-component.ts +69 -25
  12. package/src/commands/generate-model.test.ts +2 -2
  13. package/src/commands/generate-model.ts +14 -15
  14. package/src/commands/generate-overrides.ts +85 -0
  15. package/src/commands/generate-service.test.ts +2 -2
  16. package/src/commands/generate-service.ts +17 -18
  17. package/src/commands/info.ts +15 -0
  18. package/src/commands/install.test.ts +13 -4
  19. package/src/commands/install.ts +9 -9
  20. package/src/lib/App.ts +10 -7
  21. package/src/lib/Editor.ts +19 -12
  22. package/src/lib/File.mock.ts +7 -11
  23. package/src/lib/File.ts +3 -3
  24. package/src/lib/Log.mock.ts +4 -8
  25. package/src/lib/Log.test.ts +4 -4
  26. package/src/lib/Log.ts +7 -7
  27. package/src/lib/Shell.mock.ts +3 -3
  28. package/src/lib/Shell.ts +2 -2
  29. package/src/lib/Template.ts +24 -17
  30. package/src/lib/utils/app.ts +3 -3
  31. package/src/lib/utils/edit.ts +2 -2
  32. package/src/lib/utils/paths.ts +19 -11
  33. package/src/plugins/Plugin.ts +65 -12
  34. package/src/plugins/Solid.ts +55 -41
  35. package/src/plugins/Soukai.ts +5 -5
  36. package/src/testing/setup.ts +35 -36
  37. package/templates/app/.github/workflows/ci.yml +16 -4
  38. package/templates/app/.nvmrc +1 -1
  39. package/templates/app/.vscode/launch.json +1 -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 +3 -2
  45. package/templates/app/package.json +24 -12
  46. package/templates/app/postcss.config.js +1 -1
  47. package/templates/app/src/App.vue +2 -2
  48. package/templates/app/src/assets/public/robots.txt +2 -0
  49. package/templates/app/src/main.ts +4 -4
  50. package/templates/app/tsconfig.json +3 -9
  51. package/templates/app/vite.config.ts +15 -7
  52. package/templates/component-button/[component.name].vue +42 -0
  53. package/templates/component-button-story/[component.name].story.vue +77 -0
  54. package/templates/component-checkbox/[component.name].vue +34 -0
  55. package/templates/component-checkbox-story/[component.name].story.vue +63 -0
  56. package/templates/component-input/[component.name].vue +17 -0
  57. package/templates/component-input-story/[component.name].story.vue +63 -0
  58. package/templates/overrides/components/index.ts +15 -0
  59. package/templates/overrides/components/overrides/AlertModal.vue +11 -0
  60. package/templates/overrides/components/overrides/ConfirmModal.vue +20 -0
  61. package/templates/overrides/components/overrides/ErrorReportModal.vue +35 -0
  62. package/templates/overrides/components/overrides/LoadingModal.vue +12 -0
  63. package/templates/overrides/components/overrides/ModalWrapper.vue +22 -0
  64. package/templates/overrides/components/overrides/SnackbarNotification.vue +34 -0
  65. package/templates/overrides-story/Overrides.story.vue +86 -0
  66. package/templates/postcss-pseudo-classes/postcss.config.js +15 -0
  67. package/templates/service/[service.name].ts +1 -1
  68. package/.eslintrc.js +0 -7
  69. package/bin/ag +0 -4
  70. package/dist/aerogel-cli.cjs.js +0 -2
  71. package/dist/aerogel-cli.cjs.js.map +0 -1
  72. package/dist/aerogel-cli.esm.js +0 -2
  73. package/dist/aerogel-cli.esm.js.map +0 -1
  74. package/noeldemartin.config.js +0 -14
  75. package/src/lib/utils/format.test.ts +0 -33
  76. package/src/lib/utils/format.ts +0 -38
  77. package/templates/app/.eslintrc.js +0 -3
  78. package/templates/app/cypress.config.ts +0 -12
  79. package/templates/app/prettier.config.js +0 -5
  80. package/tsconfig.json +0 -11
  81. package/vite.config.ts +0 -14
  82. /package/src/{main.ts → index.ts} +0 -0
  83. /package/templates/app/src/assets/{styles.css → css/main.css} +0 -0
@@ -15,23 +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
22
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
23
- public fail<T = any>(message: string): T {
23
+ public override fail<T = any>(message: string): T {
24
24
  throw new Error(`Fail: ${message}`);
25
25
  }
26
26
 
27
- public reset(): void {
28
- this.logs = [];
29
- }
30
-
31
- protected stdout(): void {
27
+ protected override stdout(): void {
32
28
  //
33
29
  }
34
30
 
35
31
  }
36
32
 
37
- 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,12 +1,12 @@
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
12
  const updateStdout = (end: string = '', done: boolean = false) => {
@@ -52,7 +52,7 @@ export class LogService {
52
52
  const matches = stringMatchAll<2>(message, /\*\*(.*)\*\*/g);
53
53
 
54
54
  for (const match of matches) {
55
- message = message.replace(match[0], bold(match[1]));
55
+ message = message.replace(match[0], chalk.bold(match[1]));
56
56
  }
57
57
 
58
58
  return message;
@@ -92,4 +92,4 @@ export class LogService {
92
92
 
93
93
  }
94
94
 
95
- 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
  }
@@ -1,5 +1,5 @@
1
- import App from '@/lib/App';
2
- import File from '@/lib/File';
1
+ import App from '@aerogel/cli/lib/App';
2
+ import File from '@aerogel/cli/lib/File';
3
3
 
4
4
  export function app(): App {
5
5
  // TODO parse app name
@@ -7,7 +7,7 @@ export function app(): App {
7
7
  }
8
8
 
9
9
  export function isLocalApp(): boolean {
10
- return File.contains('package.json', 'file');
10
+ return File.contains('package.json', '"@aerogel/core": "file:');
11
11
  }
12
12
 
13
13
  export function isLinkedLocalApp(): boolean {
@@ -23,8 +23,8 @@ export function findDescendant<T extends Node>(
23
23
  const skipKinds = arrayFrom(options.skip ?? []);
24
24
 
25
25
  return node.forEachDescendant((descendant, traversal) => {
26
- if (guard(descendant) && validate(descendant)) {
27
- return descendant;
26
+ if (guard(descendant) && validate(descendant as T)) {
27
+ return descendant as T;
28
28
  }
29
29
 
30
30
  const descendantKind = descendant.getKind();
@@ -1,25 +1,29 @@
1
- import { resolve } from 'path';
1
+ import { URL, fileURLToPath } from 'node:url';
2
2
  import { stringMatch } from '@noeldemartin/utils';
3
+ import { resolve } from 'node:path';
3
4
 
4
- import File from '@/lib/File';
5
- import Log from '@/lib/Log';
5
+ import File from '@aerogel/cli/lib/File';
6
+ import Log from '@aerogel/cli/lib/Log';
6
7
 
7
8
  export function basePath(path: string = ''): string {
8
- if (File.contains(resolve(__dirname, '../../../package.json'), '"name": "aerogel"')) {
9
- return cliBasePath(path);
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);
10
16
  }
11
17
 
12
- const packageJson = File.read(resolve(__dirname, '../../../../package.json'));
13
- const matches = stringMatch<2>(packageJson ?? '', /"@aerogel\/cli": "file:(.*)\/aerogel-cli-[\d.]*\.tgz"/);
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"/);
14
22
  const cliPath = matches?.[1] ?? Log.fail<string>('Could not determine base path');
15
23
 
16
24
  return resolve(cliPath, path);
17
25
  }
18
26
 
19
- export function cliBasePath(path: string = ''): string {
20
- return resolve(__dirname, '../', path);
21
- }
22
-
23
27
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
24
28
  export function packNotFound(packageName: string): any {
25
29
  return Log.fail(`Could not find ${packageName} pack file, did you run 'npm pack'?`);
@@ -32,3 +36,7 @@ export function packagePackPath(packageName: string): string | null {
32
36
  export function packagePath(packageName: string): string {
33
37
  return basePath(`../${packageName}`);
34
38
  }
39
+
40
+ export function templatePath(name: string): string {
41
+ return fileURLToPath(new URL(/* @vite-ignore */ `../templates/${name}`, import.meta.url));
42
+ }
@@ -1,13 +1,13 @@
1
1
  import { Node, SyntaxKind } from 'ts-morph';
2
2
  import type { ArrayLiteralExpression, ImportDeclarationStructure, OptionalKind, SourceFile } from 'ts-morph';
3
3
 
4
- import Log from '@/lib/Log';
5
- import Shell from '@/lib/Shell';
6
- import File from '@/lib/File';
7
- import { app, isLinkedLocalApp, isLocalApp } from '@/lib/utils/app';
8
- import { editFiles, findDescendant, when } from '@/lib/utils/edit';
9
- import { packNotFound, packagePackPath, packagePath } from '@/lib/utils/paths';
10
- import type { Editor } from '@/lib/Editor';
4
+ import Log from '@aerogel/cli/lib/Log';
5
+ import Shell from '@aerogel/cli/lib/Shell';
6
+ import File from '@aerogel/cli/lib/File';
7
+ import { app, isLinkedLocalApp, isLocalApp } from '@aerogel/cli/lib/utils/app';
8
+ import { editFiles, findDescendant, when } from '@aerogel/cli/lib/utils/edit';
9
+ import { packNotFound, packagePackPath, packagePath } from '@aerogel/cli/lib/utils/paths';
10
+ import type { Editor } from '@aerogel/cli/lib/Editor';
11
11
 
12
12
  export default abstract class Plugin {
13
13
 
@@ -20,6 +20,7 @@ export default abstract class Plugin {
20
20
  public async install(): Promise<void> {
21
21
  this.assertNotInstalled();
22
22
 
23
+ await this.beforeInstall();
23
24
  await this.installDependencies();
24
25
 
25
26
  if (editFiles()) {
@@ -29,6 +30,8 @@ export default abstract class Plugin {
29
30
  await editor.format();
30
31
  }
31
32
 
33
+ await this.afterInstall();
34
+
32
35
  Log.info(`Plugin ${this.name} installed!`);
33
36
  }
34
37
 
@@ -38,6 +41,14 @@ export default abstract class Plugin {
38
41
  }
39
42
  }
40
43
 
44
+ protected async beforeInstall(): Promise<void> {
45
+ // Placeholder for overrides, don't place any functionality here.
46
+ }
47
+
48
+ protected async afterInstall(): Promise<void> {
49
+ // Placeholder for overrides, don't place any functionality here.
50
+ }
51
+
41
52
  protected async installDependencies(): Promise<void> {
42
53
  await Log.animate('Installing plugin dependencies', async () => {
43
54
  await this.installNpmDependencies();
@@ -45,12 +56,16 @@ export default abstract class Plugin {
45
56
  }
46
57
 
47
58
  protected async updateFiles(editor: Editor): Promise<void> {
48
- await this.updateBootstrapConfig(editor);
59
+ if (!this.isForDevelopment()) {
60
+ await this.updateBootstrapConfig(editor);
61
+ }
49
62
  }
50
63
 
51
64
  protected async installNpmDependencies(): Promise<void> {
65
+ const flags = this.isForDevelopment() ? '--save-dev' : '';
66
+
52
67
  if (isLinkedLocalApp()) {
53
- await Shell.run(`npm install file:${packagePath(this.getLocalPackageName())}`);
68
+ await Shell.run(`npm install file:${packagePath(this.getLocalPackageName())} ${flags}`);
54
69
 
55
70
  return;
56
71
  }
@@ -58,12 +73,12 @@ export default abstract class Plugin {
58
73
  if (isLocalApp()) {
59
74
  const packPath = packagePackPath(this.getLocalPackageName()) ?? packNotFound(this.getLocalPackageName());
60
75
 
61
- await Shell.run(`npm install file:${packPath}`);
76
+ await Shell.run(`npm install file:${packPath} ${flags}`);
62
77
 
63
78
  return;
64
79
  }
65
80
 
66
- await Shell.run(`npm install ${this.getNpmPackageName()}@next`);
81
+ await Shell.run(`npm install ${this.getNpmPackageName()}@next --save-exact ${flags}`);
67
82
  }
68
83
 
69
84
  protected async updateBootstrapConfig(editor: Editor): Promise<void> {
@@ -86,10 +101,29 @@ export default abstract class Plugin {
86
101
  });
87
102
  }
88
103
 
104
+ protected async updateTailwindConfig(editor: Editor, options: { content: string }): Promise<void> {
105
+ await Log.animate('Updating tailwind configuration', async () => {
106
+ const tailwindConfig = editor.requireSourceFile('tailwind.config.js');
107
+ const contentArray = this.getTailwindContentArray(tailwindConfig);
108
+
109
+ if (!contentArray) {
110
+ return Log.fail(`
111
+ Could not find content array in tailwind config, please add the following manually:
112
+
113
+ ${options.content}
114
+ `);
115
+ }
116
+
117
+ contentArray.addElement(options.content);
118
+
119
+ await editor.save(tailwindConfig);
120
+ });
121
+ }
122
+
89
123
  protected getBootstrapPluginsDeclaration(mainConfig: SourceFile): ArrayLiteralExpression | null {
90
124
  const bootstrapAppCall = findDescendant(mainConfig, {
91
125
  guard: Node.isCallExpression,
92
- validate: (callExpression) => callExpression.getExpression().getText() === 'bootstrapApplication',
126
+ validate: (callExpression) => callExpression.getExpression().getText() === 'bootstrap',
93
127
  skip: SyntaxKind.ImportDeclaration,
94
128
  });
95
129
  const bootstrapOptions = bootstrapAppCall?.getArguments()[1];
@@ -103,6 +137,21 @@ export default abstract class Plugin {
103
137
  return pluginsArray;
104
138
  }
105
139
 
140
+ protected getTailwindContentArray(tailwindConfig: SourceFile): ArrayLiteralExpression | null {
141
+ const contentAssignment = findDescendant(tailwindConfig, {
142
+ guard: Node.isPropertyAssignment,
143
+ validate: (propertyAssignment) => propertyAssignment.getName() === 'content',
144
+ skip: SyntaxKind.JSDoc,
145
+ });
146
+ const contentArray = contentAssignment?.getInitializer();
147
+
148
+ if (!Node.isArrayLiteralExpression(contentArray)) {
149
+ return null;
150
+ }
151
+
152
+ return contentArray;
153
+ }
154
+
106
155
  protected getBootstrapImport(): OptionalKind<ImportDeclarationStructure> {
107
156
  return {
108
157
  defaultImport: this.name,
@@ -118,6 +167,10 @@ export default abstract class Plugin {
118
167
  return `plugin-${this.name}`;
119
168
  }
120
169
 
170
+ protected isForDevelopment(): boolean {
171
+ return false;
172
+ }
173
+
121
174
  protected getBootstrapConfig(): string {
122
175
  return `${this.name}()`;
123
176
  }
@@ -1,13 +1,10 @@
1
- import { Node, SyntaxKind } from 'ts-morph';
2
- import type { ArrayLiteralExpression, SourceFile } from 'ts-morph';
3
-
4
- import Plugin from '@/plugins/Plugin';
5
- import Shell from '@/lib/Shell';
6
- import Log from '@/lib/Log';
7
- import { findDescendant } from '@/lib/utils/edit';
8
- import { isLinkedLocalApp } from '@/lib/utils/app';
9
- import { packagePath } from '@/lib/utils/paths';
10
- import type { Editor } from '@/lib/Editor';
1
+ import File from '@aerogel/cli/lib/File';
2
+ import Log from '@aerogel/cli/lib/Log';
3
+ import Plugin from '@aerogel/cli/plugins/Plugin';
4
+ import Shell from '@aerogel/cli/lib/Shell';
5
+ import { isLinkedLocalApp } from '@aerogel/cli/lib/utils/app';
6
+ import { packagePath } from '@aerogel/cli/lib/utils/paths';
7
+ import type { Editor } from '@aerogel/cli/lib/Editor';
11
8
 
12
9
  export class Solid extends Plugin {
13
10
 
@@ -15,51 +12,68 @@ export class Solid extends Plugin {
15
12
  super('solid');
16
13
  }
17
14
 
18
- protected async updateFiles(editor: Editor): Promise<void> {
19
- await this.updateTailwindConfig(editor);
15
+ protected override async updateFiles(editor: Editor): Promise<void> {
16
+ await this.updateTailwindConfig(editor, {
17
+ content: isLinkedLocalApp()
18
+ ? `'${packagePath('plugin-solid')}/dist/**/*.js'`
19
+ : '\'./node_modules/@aerogel/plugin-solid/dist/**/*.js\'',
20
+ });
21
+
22
+ await this.updateNpmScripts(editor);
23
+ await this.updateGitIgnore();
20
24
  await super.updateFiles(editor);
21
25
  }
22
26
 
23
- protected async installNpmDependencies(): Promise<void> {
24
- await Shell.run('npm install soukai-solid@next');
27
+ protected override async installNpmDependencies(): Promise<void> {
28
+ await Shell.run('npm install soukai-solid@next --save-exact');
29
+ await Shell.run('npm install @noeldemartin/solid-utils@next --save-exact');
30
+ await Shell.run('npm install @solid/community-server@7.1.6 --save-dev -E');
25
31
  await super.installNpmDependencies();
26
32
  }
27
33
 
28
- protected async updateTailwindConfig(editor: Editor): Promise<void> {
29
- await Log.animate('Updating tailwind configuration', async () => {
30
- const tailwindConfig = editor.requireSourceFile('tailwind.config.js');
31
- const contentArray = this.getTailwindContentArray(tailwindConfig);
32
- const contentValue = isLinkedLocalApp()
33
- ? `'${packagePath('plugin-solid')}/dist/**/*.js'`
34
- : '\'./node_modules/@aerogel/plugin-solid/dist/**/*.js\'';
34
+ protected async updateNpmScripts(editor: Editor): Promise<void> {
35
+ Log.info('Updating npm scripts...');
35
36
 
36
- if (!contentArray) {
37
- return Log.fail(`
38
- Could not find content array in tailwind config, please add the following manually:
37
+ const packageJson = File.read('package.json');
39
38
 
40
- ${contentValue}
41
- `);
42
- }
39
+ if (!packageJson) {
40
+ return Log.fail('Could not find package.json file');
41
+ }
43
42
 
44
- contentArray.addElement(contentValue);
43
+ File.write(
44
+ 'package.json',
45
+ packageJson
46
+ .replace(
47
+ '"cy:dev": "concurrently --kill-others \\"npm run test:serve-app\\" \\"npm run cy:open\\"",',
48
+ '"cy:dev": "concurrently --kill-others ' +
49
+ '\\"npm run test:serve-app\\" \\"npm run test:serve-pod\\" \\"npm run cy:open\\"",',
50
+ )
51
+ .replace(
52
+ '"cy:test": "start-server-and-test test:serve-app http-get://localhost:5001 cy:run",',
53
+ '"cy:test": "start-server-and-test ' +
54
+ 'test:serve-app http-get://localhost:5001 test:serve-pod http-get://localhost:3000 cy:run",',
55
+ )
56
+ .replace(
57
+ '"dev": "vite",',
58
+ '"dev": "vite",\n' +
59
+ '"dev:serve-pod": "community-solid-server -c @css:config/file.json -f ./solid",',
60
+ )
61
+ .replace(
62
+ '"test:serve-app": "vite --port 5001 --mode testing"',
63
+ '"test:serve-app": "vite --port 5001 --mode testing",\n' +
64
+ '"test:serve-pod": "community-solid-server -l warn"',
65
+ ),
66
+ );
45
67
 
46
- await editor.save(tailwindConfig);
47
- });
68
+ editor.addModifiedFile('package.json');
48
69
  }
49
70
 
50
- protected getTailwindContentArray(tailwindConfig: SourceFile): ArrayLiteralExpression | null {
51
- const contentAssignment = findDescendant(tailwindConfig, {
52
- guard: Node.isPropertyAssignment,
53
- validate: (propertyAssignment) => propertyAssignment.getName() === 'content',
54
- skip: SyntaxKind.JSDoc,
55
- });
56
- const contentArray = contentAssignment?.getInitializer();
71
+ protected async updateGitIgnore(): Promise<void> {
72
+ Log.info('Updating .gitignore');
57
73
 
58
- if (!Node.isArrayLiteralExpression(contentArray)) {
59
- return null;
60
- }
74
+ const gitignore = File.read('.gitignore') ?? '';
61
75
 
62
- return contentArray;
76
+ File.write('.gitignore', `${gitignore}/solid\n`);
63
77
  }
64
78
 
65
79
  }
@@ -1,5 +1,5 @@
1
- import Plugin from '@/plugins/Plugin';
2
- import Shell from '@/lib/Shell';
1
+ import Plugin from '@aerogel/cli/plugins/Plugin';
2
+ import Shell from '@aerogel/cli/lib/Shell';
3
3
 
4
4
  export class Soukai extends Plugin {
5
5
 
@@ -7,12 +7,12 @@ export class Soukai extends Plugin {
7
7
  super('soukai');
8
8
  }
9
9
 
10
- protected async installNpmDependencies(): Promise<void> {
11
- await Shell.run('npm install soukai@next');
10
+ protected override async installNpmDependencies(): Promise<void> {
11
+ await Shell.run('npm install soukai@next --save-exact');
12
12
  await super.installNpmDependencies();
13
13
  }
14
14
 
15
- protected getBootstrapConfig(): string {
15
+ protected override getBootstrapConfig(): string {
16
16
  return 'soukai({ models: import.meta.glob(\'@/models/*\', { eager: true }) })';
17
17
  }
18
18
 
@@ -1,31 +1,36 @@
1
- import { beforeEach, vi } from 'vitest';
2
- import { resolve } from 'path';
3
- import { setTestingNamespace } from '@noeldemartin/utils';
4
-
5
- import File from '@/lib/File';
6
- import FileMock from '@/lib/File.mock';
7
- import Log from '@/lib/Log';
8
- import LogMock from '@/lib/Log.mock';
9
- import Shell from '@/lib/Shell';
10
- import ShellMock from '@/lib/Shell.mock';
11
-
12
- setTestingNamespace(vi);
13
-
14
- File.setMockInstance(FileMock);
15
- Log.setMockInstance(LogMock);
16
- Shell.setMockInstance(ShellMock);
1
+ import { beforeAll, beforeEach, vi } from 'vitest';
2
+ import { resolve } from 'node:path';
3
+ import { setupFacadeMocks } from '@noeldemartin/testing';
4
+
5
+ import ShellMock from '@aerogel/cli/lib/Shell.mock';
6
+ import File from '@aerogel/cli/lib/File';
7
+ import FileMock from '@aerogel/cli/lib/File.mock';
8
+ import Log from '@aerogel/cli/lib/Log';
9
+ import LogMock from '@aerogel/cli/lib/Log.mock';
10
+ import Shell from '@aerogel/cli/lib/Shell';
11
+
12
+ beforeAll(() => {
13
+ File.setMockFacade(FileMock);
14
+ Log.setMockFacade(LogMock);
15
+ Shell.setMockFacade(ShellMock);
16
+ });
17
17
 
18
18
  beforeEach(() => {
19
- FileMock.reset();
20
- LogMock.reset();
21
-
22
19
  File.mock();
23
20
  Log.mock();
24
21
  Shell.mock();
25
22
  });
26
23
 
27
- vi.mock('@/lib/utils/app', async () => {
28
- const original = (await vi.importActual('@/lib/utils/app')) as object;
24
+ vi.mock('@noeldemartin/utils', async () => {
25
+ const original = (await vi.importActual('@noeldemartin/utils')) as object;
26
+
27
+ setupFacadeMocks();
28
+
29
+ return original;
30
+ });
31
+
32
+ vi.mock('@aerogel/cli/lib/utils/app', async () => {
33
+ const original = (await vi.importActual('@aerogel/cli/lib/utils/app')) as object;
29
34
 
30
35
  return {
31
36
  ...original,
@@ -34,8 +39,8 @@ vi.mock('@/lib/utils/app', async () => {
34
39
  };
35
40
  });
36
41
 
37
- vi.mock('@/lib/utils/edit', async () => {
38
- const original = (await vi.importActual('@/lib/utils/edit')) as object;
42
+ vi.mock('@aerogel/cli/lib/utils/edit', async () => {
43
+ const original = (await vi.importActual('@aerogel/cli/lib/utils/edit')) as object;
39
44
 
40
45
  return {
41
46
  ...original,
@@ -44,12 +49,8 @@ vi.mock('@/lib/utils/edit', async () => {
44
49
  });
45
50
 
46
51
  // TODO find out why these need to be mocked
47
- vi.mock('@/lib/utils/paths', async () => {
48
- const original = (await vi.importActual('@/lib/utils/paths')) as object;
49
-
50
- function cliBasePath(path: string = '') {
51
- return resolve(__dirname, '../../', path);
52
- }
52
+ vi.mock('@aerogel/cli/lib/utils/paths', async () => {
53
+ const original = (await vi.importActual('@aerogel/cli/lib/utils/paths')) as object;
53
54
 
54
55
  function basePath(path: string = '') {
55
56
  return resolve(__dirname, '../../', path);
@@ -59,16 +60,14 @@ vi.mock('@/lib/utils/paths', async () => {
59
60
  return basePath(`../${packageName}`);
60
61
  }
61
62
 
63
+ function templatePath(name: string = '') {
64
+ return resolve(__dirname, `../../templates/${name}`);
65
+ }
66
+
62
67
  return {
63
68
  ...original,
64
69
  basePath,
65
- cliBasePath,
66
70
  packagePath,
71
+ templatePath,
67
72
  };
68
73
  });
69
-
70
- vi.mock('mustache', async () => {
71
- const mustache = (await vi.importActual('mustache')) as { default: unknown };
72
-
73
- return mustache.default;
74
- });