@aerogel/cli 0.0.0-next.a56c0f4966eb71571173f8502f3f36d357ceebc7 → 0.0.0-next.a68f133e2c9a1ae9ba84b4e2e42df909289e5fba

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 (56) hide show
  1. package/.prettierignore +1 -0
  2. package/dist/aerogel-cli.cjs.js +1 -1
  3. package/dist/aerogel-cli.cjs.js.map +1 -1
  4. package/dist/aerogel-cli.d.ts +2 -2
  5. package/dist/aerogel-cli.esm.js +1 -1
  6. package/dist/aerogel-cli.esm.js.map +1 -1
  7. package/package.json +3 -3
  8. package/src/cli.ts +23 -3
  9. package/src/commands/Command.ts +11 -6
  10. package/src/commands/create.ts +5 -5
  11. package/src/commands/generate-component.test.ts +49 -2
  12. package/src/commands/generate-component.ts +49 -14
  13. package/src/commands/generate-model.ts +6 -6
  14. package/src/commands/generate-overrides.ts +85 -0
  15. package/src/commands/generate-service.test.ts +1 -1
  16. package/src/commands/generate-service.ts +5 -5
  17. package/src/commands/info.ts +14 -0
  18. package/src/commands/install.test.ts +24 -1
  19. package/src/commands/install.ts +6 -5
  20. package/src/lib/Editor.ts +7 -5
  21. package/src/lib/File.mock.ts +1 -5
  22. package/src/lib/File.ts +1 -1
  23. package/src/lib/Log.mock.ts +1 -5
  24. package/src/lib/Log.ts +1 -1
  25. package/src/lib/Shell.mock.ts +2 -2
  26. package/src/lib/Shell.ts +1 -1
  27. package/src/lib/Template.ts +5 -1
  28. package/src/lib/utils/app.ts +1 -1
  29. package/src/lib/utils/paths.ts +1 -1
  30. package/src/plugins/Histoire.ts +105 -0
  31. package/src/plugins/Plugin.ts +58 -5
  32. package/src/plugins/Solid.ts +10 -46
  33. package/src/testing/setup.ts +3 -6
  34. package/templates/app/.github/workflows/ci.yml +4 -4
  35. package/templates/app/cypress/cypress.config.ts +2 -4
  36. package/templates/app/cypress/support/e2e.ts +1 -3
  37. package/templates/app/package.json +1 -1
  38. package/templates/app/src/main.ts +3 -3
  39. package/templates/component-button/[component.name].vue +42 -0
  40. package/templates/component-button-story/[component.name].story.vue +77 -0
  41. package/templates/component-input/[component.name].vue +16 -0
  42. package/templates/component-input-story/[component.name].story.vue +63 -0
  43. package/templates/histoire/histoire.config.ts +7 -0
  44. package/templates/histoire/patches/histoire+0.17.6.patch +13 -0
  45. package/templates/histoire/src/main.histoire.ts +8 -0
  46. package/templates/overrides/components/index.ts +15 -0
  47. package/templates/overrides/components/overrides/AlertModal.vue +11 -0
  48. package/templates/overrides/components/overrides/ConfirmModal.vue +20 -0
  49. package/templates/overrides/components/overrides/ErrorReportModal.vue +35 -0
  50. package/templates/overrides/components/overrides/LoadingModal.vue +12 -0
  51. package/templates/overrides/components/overrides/ModalWrapper.vue +22 -0
  52. package/templates/overrides/components/overrides/SnackbarNotification.vue +34 -0
  53. package/templates/overrides-story/Overrides.story.vue +86 -0
  54. package/templates/postcss-pseudo-classes/postcss.config.js +15 -0
  55. package/templates/service/[service.name].ts +1 -1
  56. /package/bin/{ag → gel} +0 -0
package/src/cli.ts CHANGED
@@ -1,9 +1,14 @@
1
1
  import { Command } from 'commander';
2
+ import { facade, fail } from '@noeldemartin/utils';
3
+ import { resolve } from 'path';
4
+ import { existsSync, readFileSync } from 'fs';
5
+
2
6
  import { CreateCommand } from '@/commands/create';
3
- import { facade } from '@noeldemartin/utils';
4
7
  import { GenerateComponentCommand } from '@/commands/generate-component';
5
8
  import { GenerateModelCommand } from '@/commands/generate-model';
9
+ import { GenerateOverridesCommand } from '@/commands/generate-overrides';
6
10
  import { GenerateServiceCommand } from '@/commands/generate-service';
11
+ import { InfoCommand } from '@/commands/info';
7
12
  import { InstallCommand } from '@/commands/install';
8
13
 
9
14
  export class CLIService {
@@ -11,17 +16,32 @@ export class CLIService {
11
16
  public run(argv?: string[]): void {
12
17
  const program = new Command();
13
18
 
14
- program.name('ag').description('AerogelJS CLI').version('0.0.0');
19
+ program.name('gel').description('AerogelJS CLI').version(this.getVersion());
15
20
 
16
21
  CreateCommand.define(program);
17
22
  GenerateComponentCommand.define(program);
18
23
  GenerateModelCommand.define(program);
24
+ GenerateOverridesCommand.define(program);
19
25
  GenerateServiceCommand.define(program);
26
+ InfoCommand.define(program);
20
27
  InstallCommand.define(program);
21
28
 
22
29
  program.parse(argv);
23
30
  }
24
31
 
32
+ public getVersion(): string {
33
+ const errorMessage = 'Could not find CLI\'s version, please report this bug.';
34
+ const packageJsonPath = resolve(__dirname, '../package.json');
35
+
36
+ if (!existsSync(packageJsonPath)) {
37
+ throw new Error(errorMessage);
38
+ }
39
+
40
+ const packageJson = JSON.parse(readFileSync(packageJsonPath).toString()) as { version?: string };
41
+
42
+ return packageJson.version ?? fail(errorMessage);
43
+ }
44
+
25
45
  }
26
46
 
27
- export default facade(new CLIService());
47
+ export default facade(CLIService);
@@ -8,10 +8,10 @@ export type CommandOptions = Record<string, string | { description: string; type
8
8
 
9
9
  export default class Command {
10
10
 
11
- public static command: string = '';
12
- public static description: string = '';
13
- public static parameters: [string, string][] = [];
14
- public static options: CommandOptions = {};
11
+ protected static command: string = '';
12
+ protected static description: string = '';
13
+ protected static parameters: [string, string][] = [];
14
+ protected static options: CommandOptions = {};
15
15
 
16
16
  public static define(program: CommanderCommand): void {
17
17
  program = program.command(this.command).description(this.description);
@@ -33,11 +33,16 @@ export default class Command {
33
33
  public static async run<T extends CommandConstructor>(this: T, ...args: ConstructorParameters<T>): Promise<void> {
34
34
  const instance = new this(...args);
35
35
 
36
+ await instance.validate();
36
37
  await instance.run();
37
38
  }
38
39
 
39
- public async run(): Promise<void> {
40
- //
40
+ protected async validate(): Promise<void> {
41
+ // Placeholder for overrides, don't place any functionality here.
42
+ }
43
+
44
+ protected async run(): Promise<void> {
45
+ // Placeholder for overrides, don't place any functionality here.
41
46
  }
42
47
 
43
48
  protected assertAerogelOrDirectory(path?: string): void {
@@ -15,10 +15,10 @@ export interface Options {
15
15
 
16
16
  export class CreateCommand extends Command {
17
17
 
18
- public static command: string = 'create';
19
- public static description: string = 'Create AerogelJS app';
20
- public static parameters: [string, string][] = [['path', 'Application path']];
21
- public static options: CommandOptions = {
18
+ protected static command: string = 'create';
19
+ protected static description: string = 'Create AerogelJS app';
20
+ protected static parameters: [string, string][] = [['path', 'Application path']];
21
+ protected static options: CommandOptions = {
22
22
  name: 'Application name',
23
23
  local: {
24
24
  type: 'boolean',
@@ -40,7 +40,7 @@ export class CreateCommand extends Command {
40
40
  this.options = options;
41
41
  }
42
42
 
43
- public async run(): Promise<void> {
43
+ protected async run(): Promise<void> {
44
44
  const path = this.path;
45
45
  const name = this.options.name ?? stringToTitleCase(basename(path));
46
46
 
@@ -30,8 +30,13 @@ describe('Generate Component command', () => {
30
30
 
31
31
  it('generates components with stories', async () => {
32
32
  // Arrange
33
- FileMock.stub('package.json', '@aerogel/core');
34
- FileMock.stub('src/main.histoire.ts');
33
+ FileMock.stub(
34
+ 'package.json',
35
+ `
36
+ "@aerogel/core": "*",
37
+ "histoire": "*"
38
+ `,
39
+ );
35
40
 
36
41
  // Act
37
42
  await GenerateComponentCommand.run('FooBar', { story: true });
@@ -41,4 +46,46 @@ describe('Generate Component command', () => {
41
46
  FileMock.expectCreated('src/components/FooBar.story.vue').toContain('<FooBar />');
42
47
  });
43
48
 
49
+ it('generates input components with stories', async () => {
50
+ // Arrange
51
+ FileMock.stub(
52
+ 'package.json',
53
+ `
54
+ "@aerogel/core": "*",
55
+ "histoire": "*"
56
+ `,
57
+ );
58
+
59
+ // Act
60
+ await GenerateComponentCommand.run('FooBar', { input: true, story: true });
61
+
62
+ // Assert
63
+ FileMock.expectCreated('src/components/FooBar.vue').toContain('<AGHeadlessInputInput v-bind="attrs" />');
64
+ FileMock.expectCreated('src/components/FooBar.story.vue').toContain('.story-foobar .variant-playground');
65
+ FileMock.expectCreated('src/components/FooBar.story.vue').toContain(
66
+ '<FooBar name="food" :label="label" :placeholder="placeholder" />',
67
+ );
68
+ });
69
+
70
+ it('generates button components with stories', async () => {
71
+ // Arrange
72
+ FileMock.stub(
73
+ 'package.json',
74
+ `
75
+ "@aerogel/core": "*",
76
+ "histoire": "*"
77
+ `,
78
+ );
79
+
80
+ // Act
81
+ await GenerateComponentCommand.run('FooBar', { button: true, story: true });
82
+
83
+ // Assert
84
+ FileMock.expectCreated('src/components/FooBar.vue').toContain(
85
+ '<AGHeadlessButton :class="variantClasses" :disabled="disabled">',
86
+ );
87
+ FileMock.expectCreated('src/components/FooBar.story.vue').toContain('.story-foobar .variant-playground');
88
+ FileMock.expectCreated('src/components/FooBar.story.vue').toContain('<FooBar :color="color">');
89
+ });
90
+
44
91
  });
@@ -1,4 +1,4 @@
1
- import { arrayFrom } from '@noeldemartin/utils';
1
+ import { arrayFrom, stringToSlug } from '@noeldemartin/utils';
2
2
  import { Node, SyntaxKind } from 'ts-morph';
3
3
  import type { ArrayLiteralExpression, CallExpression, SourceFile } from 'ts-morph';
4
4
 
@@ -12,18 +12,28 @@ import { templatePath } from '@/lib/utils/paths';
12
12
  import type { CommandOptions } from '@/commands/Command';
13
13
 
14
14
  export interface Options {
15
+ button?: boolean;
16
+ input?: boolean;
15
17
  story?: boolean;
16
18
  }
17
19
 
18
20
  export class GenerateComponentCommand extends Command {
19
21
 
20
- public static command: string = 'generate:component';
21
- public static description: string = 'Generate an AerogelJS Component';
22
- public static parameters: [string, string][] = [
22
+ protected static command: string = 'generate:component';
23
+ protected static description: string = 'Generate an AerogelJS Component';
24
+ protected static parameters: [string, string][] = [
23
25
  ['path', 'Component path (relative to components folder; extension not necessary)'],
24
26
  ];
25
27
 
26
- public static options: CommandOptions = {
28
+ protected static options: CommandOptions = {
29
+ button: {
30
+ description: 'Create a custom button',
31
+ type: 'boolean',
32
+ },
33
+ input: {
34
+ description: 'Create a custom input',
35
+ type: 'boolean',
36
+ },
27
37
  story: {
28
38
  description: 'Create component story using Histoire',
29
39
  type: 'boolean',
@@ -40,7 +50,13 @@ export class GenerateComponentCommand extends Command {
40
50
  this.options = options;
41
51
  }
42
52
 
43
- public async run(): Promise<void> {
53
+ protected async validate(): Promise<void> {
54
+ if (this.options.button && this.options.input) {
55
+ Log.fail('Cannot use both \'button\' and \'input\' flags!');
56
+ }
57
+ }
58
+
59
+ protected async run(): Promise<void> {
44
60
  this.assertAerogelOrDirectory('src/components');
45
61
  this.assertHistoireInstalled();
46
62
 
@@ -48,7 +64,7 @@ export class GenerateComponentCommand extends Command {
48
64
  const [directoryName, componentName] = this.parsePathComponents();
49
65
 
50
66
  await this.createComponent(directoryName, componentName, files);
51
- await this.createStory(componentName, files);
67
+ await this.createStory(directoryName, componentName, files);
52
68
  await this.declareComponents();
53
69
 
54
70
  const filesList = arrayFrom(files)
@@ -63,8 +79,11 @@ export class GenerateComponentCommand extends Command {
63
79
  return;
64
80
  }
65
81
 
66
- if (!File.exists('src/main.histoire.ts')) {
67
- Log.fail('Histoire is not installed yet!');
82
+ if (!File.contains('package.json', '"histoire"') && !File.contains('package.json', '"@aerogel/histoire"')) {
83
+ Log.fail(`
84
+ Histoire is not installed yet! You can install it running:
85
+ npx gel install histoire
86
+ `);
68
87
  }
69
88
  }
70
89
 
@@ -74,22 +93,38 @@ export class GenerateComponentCommand extends Command {
74
93
  Log.fail(`${this.path} component already exists!`);
75
94
  }
76
95
 
77
- const componentFiles = Template.instantiate(templatePath('component'), `src/components/${directoryName}`, {
78
- component: { name: componentName },
96
+ const templateName = this.options.input
97
+ ? 'component-input'
98
+ : this.options.button
99
+ ? 'component-button'
100
+ : 'component';
101
+ const componentFiles = Template.instantiate(templatePath(templateName), `src/components/${directoryName}`, {
102
+ component: {
103
+ name: componentName,
104
+ slug: stringToSlug(componentName),
105
+ },
79
106
  });
80
107
 
81
108
  componentFiles.forEach((file) => files.add(file));
82
109
  });
83
110
  }
84
111
 
85
- protected async createStory(componentName: string, files: Set<string>): Promise<void> {
112
+ protected async createStory(directoryName: string, componentName: string, files: Set<string>): Promise<void> {
86
113
  if (!this.options.story) {
87
114
  return;
88
115
  }
89
116
 
90
117
  await Log.animate('Creating story', async () => {
91
- const storyFiles = Template.instantiate(templatePath('component-story'), 'src/components', {
92
- component: { name: componentName },
118
+ const templateName = this.options.input
119
+ ? 'component-input-story'
120
+ : this.options.button
121
+ ? 'component-button-story'
122
+ : 'component-story';
123
+ const storyFiles = Template.instantiate(templatePath(templateName), `src/components/${directoryName}`, {
124
+ component: {
125
+ name: componentName,
126
+ slug: stringToSlug(componentName),
127
+ },
93
128
  });
94
129
 
95
130
  storyFiles.forEach((file) => files.add(file));
@@ -13,10 +13,10 @@ interface Options {
13
13
 
14
14
  export class GenerateModelCommand extends Command {
15
15
 
16
- public static command: string = 'generate:model';
17
- public static description: string = 'Generate an AerogelJS Model';
18
- public static parameters: [string, string][] = [['name', 'Model name']];
19
- public static options: CommandOptions = {
16
+ protected static command: string = 'generate:model';
17
+ protected static description: string = 'Generate an AerogelJS Model';
18
+ protected static parameters: [string, string][] = [['name', 'Model name']];
19
+ protected static options: CommandOptions = {
20
20
  fields: 'Create model with the given fields',
21
21
  };
22
22
 
@@ -30,7 +30,7 @@ export class GenerateModelCommand extends Command {
30
30
  this.options = options;
31
31
  }
32
32
 
33
- public async run(): Promise<void> {
33
+ protected async run(): Promise<void> {
34
34
  this.assertAerogelOrDirectory('src/models');
35
35
 
36
36
  if (File.exists(`src/models/${this.name}.ts`)) {
@@ -90,7 +90,7 @@ export class GenerateModelCommand extends Command {
90
90
  if (!File.contains('package.json', '"soukai"') && !File.contains('package.json', '"@aerogel/plugin-soukai"')) {
91
91
  Log.fail(`
92
92
  Soukai is not installed yet! You can install it running:
93
- npx ag install soukai
93
+ npx gel install soukai
94
94
  `);
95
95
  }
96
96
  }
@@ -0,0 +1,85 @@
1
+ import { arrayFrom } from '@noeldemartin/utils';
2
+
3
+ import Command from '@/commands/Command';
4
+ import File from '@/lib/File';
5
+ import Log from '@/lib/Log';
6
+ import Template from '@/lib/Template';
7
+ import { templatePath } from '@/lib/utils/paths';
8
+ import type { CommandOptions } from '@/commands/Command';
9
+
10
+ export interface Options {
11
+ story?: boolean;
12
+ }
13
+
14
+ export class GenerateOverridesCommand extends Command {
15
+
16
+ protected static command: string = 'generate:overrides';
17
+ protected static description: string = 'Generate AerogelJS component overrides';
18
+
19
+ protected static options: CommandOptions = {
20
+ story: {
21
+ description: 'Create overrides story using Histoire',
22
+ type: 'boolean',
23
+ },
24
+ };
25
+
26
+ private options: Options;
27
+
28
+ constructor(options: Options = {}) {
29
+ super();
30
+
31
+ this.options = options;
32
+ }
33
+
34
+ protected async run(): Promise<void> {
35
+ this.assertAerogelOrDirectory('src/components');
36
+ this.assertHistoireInstalled();
37
+
38
+ const files = new Set<string>();
39
+
40
+ await this.createComponents(files);
41
+ await this.createStory(files);
42
+
43
+ const filesList = arrayFrom(files)
44
+ .map((file) => `- ${file}`)
45
+ .join('\n');
46
+
47
+ Log.info(`Overrides created successfully! The following files were created:\n\n${filesList}`);
48
+ Log.info('\nRemember to declare your components in main.ts and main.histoire.ts!');
49
+ }
50
+
51
+ protected assertHistoireInstalled(): void {
52
+ if (!this.options.story) {
53
+ return;
54
+ }
55
+
56
+ if (!File.contains('package.json', '"histoire"') && !File.contains('package.json', '"@aerogel/histoire"')) {
57
+ Log.fail(`
58
+ Histoire is not installed yet! You can install it running:
59
+ npx gel install histoire
60
+ `);
61
+ }
62
+ }
63
+
64
+ protected async createComponents(files: Set<string>): Promise<void> {
65
+ await Log.animate('Creating components', async () => {
66
+ if (File.exists('src/components/ModalWrapper.vue')) {
67
+ Log.fail('ModalWrapper component already exists!');
68
+ }
69
+
70
+ Template.instantiate(templatePath('overrides'), 'src').forEach((file) => files.add(file));
71
+ });
72
+ }
73
+
74
+ protected async createStory(files: Set<string>): Promise<void> {
75
+ if (!this.options.story) {
76
+ return;
77
+ }
78
+
79
+ await Log.animate('Creating story', async () => {
80
+ Template.instantiate(templatePath('overrides-story'), 'src/components/overrides/').forEach((file) =>
81
+ files.add(file));
82
+ });
83
+ }
84
+
85
+ }
@@ -15,7 +15,7 @@ describe('Generate Service command', () => {
15
15
 
16
16
  // Assert
17
17
  FileMock.expectCreated('src/services/FooBar.ts').toContain('class FooBarService extends Service');
18
- FileMock.expectCreated('src/services/FooBar.ts').toContain('export default facade(new FooBarService());');
18
+ FileMock.expectCreated('src/services/FooBar.ts').toContain('export default facade(FooBarService);');
19
19
  });
20
20
 
21
21
  });
@@ -13,9 +13,9 @@ import type { Editor } from '@/lib/Editor';
13
13
 
14
14
  export class GenerateServiceCommand extends Command {
15
15
 
16
- public static command: string = 'generate:service';
17
- public static description: string = 'Generate an AerogelJS Service';
18
- public static parameters: [string, string][] = [['name', 'Service name']];
16
+ protected static command: string = 'generate:service';
17
+ protected static description: string = 'Generate an AerogelJS Service';
18
+ protected static parameters: [string, string][] = [['name', 'Service name']];
19
19
 
20
20
  private name: string;
21
21
 
@@ -25,7 +25,7 @@ export class GenerateServiceCommand extends Command {
25
25
  this.name = name;
26
26
  }
27
27
 
28
- public async run(): Promise<void> {
28
+ protected async run(): Promise<void> {
29
29
  this.assertAerogelOrDirectory('src/services');
30
30
 
31
31
  const files = new Set<string>();
@@ -122,7 +122,7 @@ export class GenerateServiceCommand extends Command {
122
122
  protected getBootstrapOptions(mainConfig: SourceFile): ObjectLiteralExpression | null {
123
123
  const bootstrapAppCall = findDescendant(mainConfig, {
124
124
  guard: Node.isCallExpression,
125
- validate: (callExpression) => callExpression.getExpression().getText() === 'bootstrapApplication',
125
+ validate: (callExpression) => callExpression.getExpression().getText() === 'bootstrap',
126
126
  skip: SyntaxKind.ImportDeclaration,
127
127
  });
128
128
  const bootstrapOptions = bootstrapAppCall?.getArguments()[1];
@@ -0,0 +1,14 @@
1
+ import Command from '@/commands/Command';
2
+ import Log from '@/lib/Log';
3
+
4
+ export class InfoCommand extends Command {
5
+
6
+ protected static command: string = 'info';
7
+ protected static description: string = 'Show debugging information about the CLI';
8
+
9
+ protected async run(): Promise<void> {
10
+ Log.info('[AerogelJS CLI info]');
11
+ Log.info('Installation directory: ' + __dirname);
12
+ }
13
+
14
+ }
@@ -1,12 +1,13 @@
1
1
  import { describe, it } from 'vitest';
2
2
 
3
+ import FileMock from '@/lib/File.mock';
3
4
  import ShellMock from '@/lib/Shell.mock';
4
5
 
5
6
  import { InstallCommand } from './install';
6
7
 
7
8
  describe('Install plugin command', () => {
8
9
 
9
- it('installs plugins', async () => {
10
+ it('installs solid', async () => {
10
11
  // Act
11
12
  await InstallCommand.run('solid');
12
13
 
@@ -15,4 +16,26 @@ describe('Install plugin command', () => {
15
16
  ShellMock.expectRan('npm install @aerogel/plugin-solid@next --save-exact');
16
17
  });
17
18
 
19
+ it('installs soukai', async () => {
20
+ // Act
21
+ await InstallCommand.run('soukai');
22
+
23
+ // Assert
24
+ ShellMock.expectRan('npm install soukai@next --save-exact');
25
+ ShellMock.expectRan('npm install @aerogel/plugin-soukai@next --save-exact');
26
+ });
27
+
28
+ it('installs histoire', async () => {
29
+ // Arrange
30
+ FileMock.stub('package.json', '"@aerogel/core"');
31
+
32
+ // Act
33
+ await InstallCommand.run('histoire');
34
+
35
+ // Assert
36
+ ShellMock.expectRan('npm install histoire@0.17.6 --save-dev');
37
+ ShellMock.expectRan('npm install @aerogel/histoire@next --save-exact --save-dev');
38
+ ShellMock.expectRan('npm install patch-package --save-dev');
39
+ });
40
+
18
41
  });
@@ -1,19 +1,20 @@
1
1
  import Command from '@/commands/Command';
2
2
  import Log from '@/lib/Log';
3
+ import { Histoire } from '@/plugins/Histoire';
3
4
  import { Solid } from '@/plugins/Solid';
4
5
  import { Soukai } from '@/plugins/Soukai';
5
6
  import type Plugin from '@/plugins/Plugin';
6
7
 
7
- const plugins = [new Soukai(), new Solid()].reduce(
8
+ const plugins = [new Soukai(), new Solid(), new Histoire()].reduce(
8
9
  (pluginsObject, plugin) => Object.assign(pluginsObject, { [plugin.name]: plugin }),
9
10
  {} as Record<string, Plugin>,
10
11
  );
11
12
 
12
13
  export class InstallCommand extends Command {
13
14
 
14
- public static command: string = 'install';
15
- public static description: string = 'Install an AerogelJS plugin';
16
- public static parameters: [string, string][] = [['plugin', 'Plugin to install']];
15
+ protected static command: string = 'install';
16
+ protected static description: string = 'Install an AerogelJS plugin';
17
+ protected static parameters: [string, string][] = [['plugin', 'Plugin to install']];
17
18
 
18
19
  private plugin: Plugin;
19
20
 
@@ -25,7 +26,7 @@ export class InstallCommand extends Command {
25
26
  Log.fail(`Plugin '${plugin}' doesn't exist. Available plugins: ${Object.keys(plugins).join(', ')}`);
26
27
  }
27
28
 
28
- public async run(): Promise<void> {
29
+ protected async run(): Promise<void> {
29
30
  await this.plugin.install();
30
31
  }
31
32
 
package/src/lib/Editor.ts CHANGED
@@ -33,13 +33,15 @@ export class Editor {
33
33
  await Log.animate('Formatting modified files', async () => {
34
34
  const usingPrettier = File.exists('prettier.config.js') || File.contains('package.json', '"prettier": {');
35
35
  const usingESLint = File.exists('.eslintrc.js') || File.contains('package.json', '"eslintConfig"');
36
-
37
- await Promise.all(
38
- arrayFrom(this.modifiedFiles).map(async (file) => {
36
+ const usingPrettierESLint = File.contains('package.json', '"prettier-eslint-cli"');
37
+ const formatFile = usingPrettierESLint
38
+ ? (file: string) => Shell.run(`npx prettier-eslint ${file} --write`)
39
+ : async (file: string) => {
39
40
  usingPrettier && (await Shell.run(`npx prettier ${file} --write`));
40
41
  file.match(/\.(ts|js|vue)$/) && usingESLint && (await Shell.run(`npx eslint ${file} --fix`));
41
- }),
42
- );
42
+ };
43
+
44
+ await Promise.all(arrayFrom(this.modifiedFiles).map(async (file) => formatFile(file)));
43
45
  });
44
46
  }
45
47
 
@@ -41,10 +41,6 @@ export class FileMockService extends FileService {
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
@@ -73,4 +73,4 @@ export class FileService {
73
73
 
74
74
  }
75
75
 
76
- export default facade(new FileService());
76
+ export default facade(FileService);
@@ -24,14 +24,10 @@ export class LogServiceMock extends LogService {
24
24
  throw new Error(`Fail: ${message}`);
25
25
  }
26
26
 
27
- public reset(): void {
28
- this.logs = [];
29
- }
30
-
31
27
  protected stdout(): void {
32
28
  //
33
29
  }
34
30
 
35
31
  }
36
32
 
37
- export default facade(new LogServiceMock());
33
+ export default facade(LogServiceMock);
package/src/lib/Log.ts CHANGED
@@ -92,4 +92,4 @@ export class LogService {
92
92
 
93
93
  }
94
94
 
95
- export default facade(new LogService());
95
+ export default facade(LogService);
@@ -8,7 +8,7 @@ export class ShellServiceMock extends ShellService {
8
8
  private history: string[] = [];
9
9
 
10
10
  public async run(command: string): Promise<void> {
11
- this.history.push(command);
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
@@ -25,4 +25,4 @@ export class ShellService {
25
25
 
26
26
  }
27
27
 
28
- export default facade(new ShellService());
28
+ export default facade(ShellService);
@@ -6,7 +6,11 @@ import File from '@/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);
@@ -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 {