@aerogel/cli 0.0.0-next.444e75523f9ddc8b8de7cd36b333f476ef86a46c → 0.0.0-next.46a3020f90bb19fb98d8b9c75a7228de4fe76346
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/bin/gel +1 -1
- package/dist/aerogel-cli.d.ts +2 -2
- package/dist/aerogel-cli.js +833 -0
- package/dist/aerogel-cli.js.map +1 -0
- package/package.json +20 -33
- package/src/cli.ts +27 -9
- package/src/commands/Command.ts +4 -7
- package/src/commands/create.test.ts +6 -14
- package/src/commands/create.ts +11 -11
- package/src/commands/generate-component.test.ts +10 -16
- package/src/commands/generate-component.ts +30 -19
- package/src/commands/generate-model.test.ts +3 -11
- package/src/commands/generate-model.ts +11 -11
- package/src/commands/generate-overrides.ts +10 -10
- package/src/commands/generate-service.test.ts +4 -12
- package/src/commands/generate-service.ts +14 -14
- package/src/commands/info.ts +15 -0
- package/src/commands/install.test.ts +4 -26
- package/src/commands/install.ts +11 -12
- package/src/lib/App.ts +9 -6
- package/src/lib/Editor.ts +3 -4
- package/src/lib/File.mock.ts +7 -11
- package/src/lib/File.ts +3 -3
- package/src/lib/Log.mock.ts +4 -8
- package/src/lib/Log.test.ts +4 -4
- package/src/lib/Log.ts +7 -7
- package/src/lib/Shell.mock.ts +2 -2
- package/src/lib/Shell.ts +2 -2
- package/src/lib/Template.ts +19 -16
- package/src/lib/utils/app.ts +2 -2
- package/src/lib/utils/edit.ts +2 -2
- package/src/lib/utils/paths.ts +15 -7
- package/src/plugins/Plugin.ts +7 -26
- package/src/plugins/Solid.ts +15 -22
- package/src/plugins/Soukai.ts +4 -4
- package/src/testing/setup.ts +30 -31
- package/templates/app/.github/workflows/ci.yml +4 -4
- package/templates/app/.nvmrc +1 -1
- package/templates/app/.vscode/launch.json +1 -0
- package/templates/app/cypress/cypress.config.ts +2 -4
- package/templates/app/cypress/support/e2e.ts +1 -3
- package/templates/app/cypress/tsconfig.json +7 -8
- package/templates/app/index.html +2 -2
- package/templates/app/package.json +19 -18
- package/templates/app/src/App.vue +1 -1
- package/templates/app/src/assets/css/main.css +4 -0
- package/templates/app/src/main.ts +2 -2
- package/templates/app/tsconfig.json +3 -10
- package/templates/app/vite.config.ts +6 -4
- package/templates/component-button/[component.name].vue +2 -2
- package/templates/component-checkbox/[component.name].vue +34 -0
- package/templates/component-checkbox-story/[component.name].story.vue +63 -0
- package/templates/component-input/[component.name].vue +1 -0
- package/templates/overrides/components/overrides/ConfirmModal.vue +5 -5
- package/templates/overrides/components/overrides/ErrorReportModal.vue +6 -6
- package/templates/overrides/components/overrides/ModalWrapper.vue +3 -3
- package/templates/overrides/components/overrides/SnackbarNotification.vue +3 -3
- package/templates/overrides-story/Overrides.story.vue +10 -10
- package/templates/service/[service.name].ts +1 -1
- package/.prettierignore +0 -1
- package/dist/aerogel-cli.cjs.js +0 -2
- package/dist/aerogel-cli.cjs.js.map +0 -1
- package/dist/aerogel-cli.esm.js +0 -2
- package/dist/aerogel-cli.esm.js.map +0 -1
- package/src/plugins/Histoire.ts +0 -105
- package/src/testing/stubs/ProgramStub.ts +0 -35
- package/src/testing/utils.ts +0 -14
- package/templates/app/postcss.config.js +0 -6
- package/templates/app/src/assets/css/styles.css +0 -3
- package/templates/app/tailwind.config.js +0 -5
- package/templates/histoire/histoire.config.ts +0 -7
- package/templates/histoire/patches/histoire+0.17.6.patch +0 -13
- package/templates/histoire/src/main.histoire.ts +0 -8
- package/templates/postcss-pseudo-classes/postcss.config.js +0 -15
- package/tsconfig.json +0 -11
- package/vite.config.ts +0 -14
- /package/src/{main.ts → index.ts} +0 -0
|
@@ -1,20 +1,12 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { describe, it } from 'vitest';
|
|
2
2
|
import { formatCodeBlock } from '@noeldemartin/utils';
|
|
3
3
|
|
|
4
|
-
import FileMock from '
|
|
5
|
-
import { stubCommandRunner } from '@/testing/utils';
|
|
6
|
-
import type { StubCommandRunner } from '@/testing/utils';
|
|
4
|
+
import FileMock from '@aerogel/cli/lib/File.mock';
|
|
7
5
|
|
|
8
6
|
import { GenerateModelCommand } from './generate-model';
|
|
9
7
|
|
|
10
8
|
describe('Generate Model command', () => {
|
|
11
9
|
|
|
12
|
-
let run: StubCommandRunner<typeof GenerateModelCommand>;
|
|
13
|
-
|
|
14
|
-
beforeEach(() => {
|
|
15
|
-
run = stubCommandRunner(GenerateModelCommand);
|
|
16
|
-
});
|
|
17
|
-
|
|
18
10
|
it('generates models', async () => {
|
|
19
11
|
// Arrange
|
|
20
12
|
FileMock.stub(
|
|
@@ -28,7 +20,7 @@ describe('Generate Model command', () => {
|
|
|
28
20
|
);
|
|
29
21
|
|
|
30
22
|
// Act
|
|
31
|
-
await run('FooBar', {
|
|
23
|
+
await GenerateModelCommand.run('FooBar', {
|
|
32
24
|
fields: 'name:string:required,age:number,birth:Date',
|
|
33
25
|
});
|
|
34
26
|
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import { formatCodeBlock, stringToStudlyCase } from '@noeldemartin/utils';
|
|
2
2
|
|
|
3
|
-
import Command from '
|
|
4
|
-
import File from '
|
|
5
|
-
import Log from '
|
|
6
|
-
import Template from '
|
|
7
|
-
import { templatePath } from '
|
|
8
|
-
import type { CommandOptions } from '
|
|
3
|
+
import Command from '@aerogel/cli/commands/Command';
|
|
4
|
+
import File from '@aerogel/cli/lib/File';
|
|
5
|
+
import Log from '@aerogel/cli/lib/Log';
|
|
6
|
+
import Template from '@aerogel/cli/lib/Template';
|
|
7
|
+
import { templatePath } from '@aerogel/cli/lib/utils/paths';
|
|
8
|
+
import type { CommandOptions } from '@aerogel/cli/commands/Command';
|
|
9
9
|
|
|
10
10
|
interface Options {
|
|
11
11
|
fields?: string;
|
|
@@ -13,10 +13,10 @@ interface Options {
|
|
|
13
13
|
|
|
14
14
|
export class GenerateModelCommand extends Command {
|
|
15
15
|
|
|
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 = {
|
|
16
|
+
protected static override command: string = 'generate:model';
|
|
17
|
+
protected static override description: string = 'Generate an AerogelJS Model';
|
|
18
|
+
protected static override parameters: [string, string][] = [['name', 'Model name']];
|
|
19
|
+
protected static override 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
|
-
protected async run(): Promise<void> {
|
|
33
|
+
protected override async run(): Promise<void> {
|
|
34
34
|
this.assertAerogelOrDirectory('src/models');
|
|
35
35
|
|
|
36
36
|
if (File.exists(`src/models/${this.name}.ts`)) {
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import { arrayFrom } from '@noeldemartin/utils';
|
|
2
2
|
|
|
3
|
-
import Command from '
|
|
4
|
-
import File from '
|
|
5
|
-
import Log from '
|
|
6
|
-
import Template from '
|
|
7
|
-
import { templatePath } from '
|
|
8
|
-
import type { CommandOptions } from '
|
|
3
|
+
import Command from '@aerogel/cli/commands/Command';
|
|
4
|
+
import File from '@aerogel/cli/lib/File';
|
|
5
|
+
import Log from '@aerogel/cli/lib/Log';
|
|
6
|
+
import Template from '@aerogel/cli/lib/Template';
|
|
7
|
+
import { templatePath } from '@aerogel/cli/lib/utils/paths';
|
|
8
|
+
import type { CommandOptions } from '@aerogel/cli/commands/Command';
|
|
9
9
|
|
|
10
10
|
export interface Options {
|
|
11
11
|
story?: boolean;
|
|
@@ -13,10 +13,10 @@ export interface Options {
|
|
|
13
13
|
|
|
14
14
|
export class GenerateOverridesCommand extends Command {
|
|
15
15
|
|
|
16
|
-
protected static command: string = 'generate:overrides';
|
|
17
|
-
protected static description: string = 'Generate AerogelJS component overrides';
|
|
16
|
+
protected static override command: string = 'generate:overrides';
|
|
17
|
+
protected static override description: string = 'Generate AerogelJS component overrides';
|
|
18
18
|
|
|
19
|
-
protected static options: CommandOptions = {
|
|
19
|
+
protected static override options: CommandOptions = {
|
|
20
20
|
story: {
|
|
21
21
|
description: 'Create overrides story using Histoire',
|
|
22
22
|
type: 'boolean',
|
|
@@ -31,7 +31,7 @@ export class GenerateOverridesCommand extends Command {
|
|
|
31
31
|
this.options = options;
|
|
32
32
|
}
|
|
33
33
|
|
|
34
|
-
protected async run(): Promise<void> {
|
|
34
|
+
protected override async run(): Promise<void> {
|
|
35
35
|
this.assertAerogelOrDirectory('src/components');
|
|
36
36
|
this.assertHistoireInstalled();
|
|
37
37
|
|
|
@@ -1,29 +1,21 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { describe, it } from 'vitest';
|
|
2
2
|
|
|
3
|
-
import FileMock from '
|
|
4
|
-
import { stubCommandRunner } from '@/testing/utils';
|
|
5
|
-
import type { StubCommandRunner } from '@/testing/utils';
|
|
3
|
+
import FileMock from '@aerogel/cli/lib/File.mock';
|
|
6
4
|
|
|
7
5
|
import { GenerateServiceCommand } from './generate-service';
|
|
8
6
|
|
|
9
7
|
describe('Generate Service command', () => {
|
|
10
8
|
|
|
11
|
-
let run: StubCommandRunner<typeof GenerateServiceCommand>;
|
|
12
|
-
|
|
13
|
-
beforeEach(() => {
|
|
14
|
-
run = stubCommandRunner(GenerateServiceCommand);
|
|
15
|
-
});
|
|
16
|
-
|
|
17
9
|
it('generates services', async () => {
|
|
18
10
|
// Arrange
|
|
19
11
|
FileMock.stub('package.json', '@aerogel/core');
|
|
20
12
|
|
|
21
13
|
// Act
|
|
22
|
-
await run('FooBar');
|
|
14
|
+
await GenerateServiceCommand.run('FooBar');
|
|
23
15
|
|
|
24
16
|
// Assert
|
|
25
17
|
FileMock.expectCreated('src/services/FooBar.ts').toContain('class FooBarService extends Service');
|
|
26
|
-
FileMock.expectCreated('src/services/FooBar.ts').toContain('export default facade(
|
|
18
|
+
FileMock.expectCreated('src/services/FooBar.ts').toContain('export default facade(FooBarService);');
|
|
27
19
|
});
|
|
28
20
|
|
|
29
21
|
});
|
|
@@ -2,20 +2,20 @@ import { arrayFrom, formatCodeBlock, stringToCamelCase } from '@noeldemartin/uti
|
|
|
2
2
|
import { Node, SyntaxKind } from 'ts-morph';
|
|
3
3
|
import type { ObjectLiteralExpression, SourceFile } from 'ts-morph';
|
|
4
4
|
|
|
5
|
-
import Command from '
|
|
6
|
-
import File from '
|
|
7
|
-
import Log from '
|
|
8
|
-
import Template from '
|
|
9
|
-
import { app } from '
|
|
10
|
-
import { templatePath } from '
|
|
11
|
-
import { editFiles, findDescendant } from '
|
|
12
|
-
import type { Editor } from '
|
|
5
|
+
import Command from '@aerogel/cli/commands/Command';
|
|
6
|
+
import File from '@aerogel/cli/lib/File';
|
|
7
|
+
import Log from '@aerogel/cli/lib/Log';
|
|
8
|
+
import Template from '@aerogel/cli/lib/Template';
|
|
9
|
+
import { app } from '@aerogel/cli/lib/utils/app';
|
|
10
|
+
import { templatePath } from '@aerogel/cli/lib/utils/paths';
|
|
11
|
+
import { editFiles, findDescendant } from '@aerogel/cli/lib/utils/edit';
|
|
12
|
+
import type { Editor } from '@aerogel/cli/lib/Editor';
|
|
13
13
|
|
|
14
14
|
export class GenerateServiceCommand extends Command {
|
|
15
15
|
|
|
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']];
|
|
16
|
+
protected static override command: string = 'generate:service';
|
|
17
|
+
protected static override description: string = 'Generate an AerogelJS Service';
|
|
18
|
+
protected static override 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
|
-
protected async run(): Promise<void> {
|
|
28
|
+
protected override async run(): Promise<void> {
|
|
29
29
|
this.assertAerogelOrDirectory('src/services');
|
|
30
30
|
|
|
31
31
|
const files = new Set<string>();
|
|
@@ -95,8 +95,8 @@ export class GenerateServiceCommand extends Command {
|
|
|
95
95
|
|
|
96
96
|
export type AppServices = typeof services;
|
|
97
97
|
|
|
98
|
-
declare module '@
|
|
99
|
-
interface
|
|
98
|
+
declare module '@aerogel/core' {
|
|
99
|
+
interface Services extends AppServices {}
|
|
100
100
|
}
|
|
101
101
|
`),
|
|
102
102
|
);
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { URL, fileURLToPath } from 'node:url';
|
|
2
|
+
|
|
3
|
+
import Command from '@aerogel/cli/commands/Command';
|
|
4
|
+
import Log from '@aerogel/cli/lib/Log';
|
|
5
|
+
export class InfoCommand extends Command {
|
|
6
|
+
|
|
7
|
+
protected static override command: string = 'info';
|
|
8
|
+
protected static override description: string = 'Show debugging information about the CLI';
|
|
9
|
+
|
|
10
|
+
protected override async run(): Promise<void> {
|
|
11
|
+
Log.info('[AerogelJS CLI info]');
|
|
12
|
+
Log.info('Installation directory: ' + fileURLToPath(new URL(/* @vite-ignore */ './', import.meta.url)));
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
}
|
|
@@ -1,23 +1,14 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { describe, it } from 'vitest';
|
|
2
2
|
|
|
3
|
-
import
|
|
4
|
-
import ShellMock from '@/lib/Shell.mock';
|
|
5
|
-
import { stubCommandRunner } from '@/testing/utils';
|
|
6
|
-
import type { StubCommandRunner } from '@/testing/utils';
|
|
3
|
+
import ShellMock from '@aerogel/cli/lib/Shell.mock';
|
|
7
4
|
|
|
8
5
|
import { InstallCommand } from './install';
|
|
9
6
|
|
|
10
7
|
describe('Install plugin command', () => {
|
|
11
8
|
|
|
12
|
-
let run: StubCommandRunner<typeof InstallCommand>;
|
|
13
|
-
|
|
14
|
-
beforeEach(() => {
|
|
15
|
-
run = stubCommandRunner(InstallCommand);
|
|
16
|
-
});
|
|
17
|
-
|
|
18
9
|
it('installs solid', async () => {
|
|
19
10
|
// Act
|
|
20
|
-
await run('solid');
|
|
11
|
+
await InstallCommand.run('solid');
|
|
21
12
|
|
|
22
13
|
// Assert
|
|
23
14
|
ShellMock.expectRan('npm install soukai-solid@next --save-exact');
|
|
@@ -26,24 +17,11 @@ describe('Install plugin command', () => {
|
|
|
26
17
|
|
|
27
18
|
it('installs soukai', async () => {
|
|
28
19
|
// Act
|
|
29
|
-
await run('soukai');
|
|
20
|
+
await InstallCommand.run('soukai');
|
|
30
21
|
|
|
31
22
|
// Assert
|
|
32
23
|
ShellMock.expectRan('npm install soukai@next --save-exact');
|
|
33
24
|
ShellMock.expectRan('npm install @aerogel/plugin-soukai@next --save-exact');
|
|
34
25
|
});
|
|
35
26
|
|
|
36
|
-
it('installs histoire', async () => {
|
|
37
|
-
// Arrange
|
|
38
|
-
FileMock.stub('package.json', '"@aerogel/core"');
|
|
39
|
-
|
|
40
|
-
// Act
|
|
41
|
-
await run('histoire');
|
|
42
|
-
|
|
43
|
-
// Assert
|
|
44
|
-
ShellMock.expectRan('npm install histoire@0.17.6 --save-dev');
|
|
45
|
-
ShellMock.expectRan('npm install @aerogel/histoire@next --save-exact --save-dev');
|
|
46
|
-
ShellMock.expectRan('npm install patch-package --save-dev');
|
|
47
|
-
});
|
|
48
|
-
|
|
49
27
|
});
|
package/src/commands/install.ts
CHANGED
|
@@ -1,20 +1,19 @@
|
|
|
1
|
-
import Command from '
|
|
2
|
-
import Log from '
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
import
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
const plugins = [new Soukai(), new Solid(), new Histoire()].reduce(
|
|
1
|
+
import Command from '@aerogel/cli/commands/Command';
|
|
2
|
+
import Log from '@aerogel/cli/lib/Log';
|
|
3
|
+
import { Solid } from '@aerogel/cli/plugins/Solid';
|
|
4
|
+
import { Soukai } from '@aerogel/cli/plugins/Soukai';
|
|
5
|
+
import type Plugin from '@aerogel/cli/plugins/Plugin';
|
|
6
|
+
|
|
7
|
+
const plugins = [new Soukai(), new Solid()].reduce(
|
|
9
8
|
(pluginsObject, plugin) => Object.assign(pluginsObject, { [plugin.name]: plugin }),
|
|
10
9
|
{} as Record<string, Plugin>,
|
|
11
10
|
);
|
|
12
11
|
|
|
13
12
|
export class InstallCommand extends Command {
|
|
14
13
|
|
|
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']];
|
|
14
|
+
protected static override command: string = 'install';
|
|
15
|
+
protected static override description: string = 'Install an AerogelJS plugin';
|
|
16
|
+
protected static override parameters: [string, string][] = [['plugin', 'Plugin to install']];
|
|
18
17
|
|
|
19
18
|
private plugin: Plugin;
|
|
20
19
|
|
|
@@ -26,7 +25,7 @@ export class InstallCommand extends Command {
|
|
|
26
25
|
Log.fail(`Plugin '${plugin}' doesn't exist. Available plugins: ${Object.keys(plugins).join(', ')}`);
|
|
27
26
|
}
|
|
28
27
|
|
|
29
|
-
protected async run(): Promise<void> {
|
|
28
|
+
protected override async run(): Promise<void> {
|
|
30
29
|
await this.plugin.install();
|
|
31
30
|
}
|
|
32
31
|
|
package/src/lib/App.ts
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import { stringToSlug } from '@noeldemartin/utils';
|
|
2
2
|
|
|
3
|
-
import File from '
|
|
4
|
-
import Log from '
|
|
5
|
-
import Template from '
|
|
6
|
-
import { packNotFound, packagePackPath, packagePath, templatePath } from '
|
|
7
|
-
import { Editor } from '
|
|
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
8
|
|
|
9
9
|
interface Dependencies {
|
|
10
10
|
aerogelCli: string;
|
|
@@ -22,7 +22,10 @@ export interface Options {
|
|
|
22
22
|
|
|
23
23
|
export default class App {
|
|
24
24
|
|
|
25
|
-
constructor(
|
|
25
|
+
constructor(
|
|
26
|
+
protected name: string,
|
|
27
|
+
protected options: Options = {},
|
|
28
|
+
) {}
|
|
26
29
|
|
|
27
30
|
public create(path: string): void {
|
|
28
31
|
if (File.exists(path) && (!File.isDirectory(path) || !File.isEmptyDirectory(path))) {
|
package/src/lib/Editor.ts
CHANGED
|
@@ -2,9 +2,9 @@ import { arrayFrom } from '@noeldemartin/utils';
|
|
|
2
2
|
import { Project } from 'ts-morph';
|
|
3
3
|
import type { SourceFile } from 'ts-morph';
|
|
4
4
|
|
|
5
|
-
import File from '
|
|
6
|
-
import Log from '
|
|
7
|
-
import Shell from '
|
|
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
8
|
|
|
9
9
|
export class Editor {
|
|
10
10
|
|
|
@@ -16,7 +16,6 @@ export class Editor {
|
|
|
16
16
|
this.modifiedFiles = new Set();
|
|
17
17
|
|
|
18
18
|
this.project.addSourceFilesAtPaths('src/**/*.ts');
|
|
19
|
-
this.project.addSourceFilesAtPaths('tailwind.config.js');
|
|
20
19
|
this.project.addSourceFilesAtPaths('vite.config.ts');
|
|
21
20
|
this.project.addSourceFilesAtPaths('package.json');
|
|
22
21
|
}
|
package/src/lib/File.mock.ts
CHANGED
|
@@ -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(
|
|
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
|
|
|
@@ -73,4 +73,4 @@ export class FileService {
|
|
|
73
73
|
|
|
74
74
|
}
|
|
75
75
|
|
|
76
|
-
export default facade(
|
|
76
|
+
export default facade(FileService);
|
package/src/lib/Log.mock.ts
CHANGED
|
@@ -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
|
-
|
|
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(
|
|
33
|
+
export default facade(LogServiceMock);
|
package/src/lib/Log.test.ts
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
import
|
|
1
|
+
import chalk from 'chalk';
|
|
2
2
|
import { describe, it } from 'vitest';
|
|
3
3
|
|
|
4
|
-
import LogMock from '
|
|
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(
|
|
95
|
+
export default facade(LogService);
|
package/src/lib/Shell.mock.ts
CHANGED
|
@@ -7,7 +7,7 @@ export class ShellServiceMock extends ShellService {
|
|
|
7
7
|
|
|
8
8
|
private history: string[] = [];
|
|
9
9
|
|
|
10
|
-
public async run(command: string): Promise<void> {
|
|
10
|
+
public override async run(command: string): Promise<void> {
|
|
11
11
|
this.history.push(command.trim());
|
|
12
12
|
}
|
|
13
13
|
|
|
@@ -17,4 +17,4 @@ export class ShellServiceMock extends ShellService {
|
|
|
17
17
|
|
|
18
18
|
}
|
|
19
19
|
|
|
20
|
-
export default facade(
|
|
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(
|
|
28
|
+
export default facade(ShellService);
|
package/src/lib/Template.ts
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import
|
|
2
|
-
import {
|
|
1
|
+
import Mustache from 'mustache';
|
|
2
|
+
import { readFileSync } from 'node:fs';
|
|
3
3
|
import { toString } from '@noeldemartin/utils';
|
|
4
4
|
|
|
5
|
-
import File from '
|
|
5
|
+
import File from '@aerogel/cli/lib/File';
|
|
6
6
|
|
|
7
7
|
export default class Template {
|
|
8
8
|
|
|
@@ -32,7 +32,7 @@ export default class Template {
|
|
|
32
32
|
const filePath =
|
|
33
33
|
destination + (relativePath.endsWith('.template') ? relativePath.slice(0, -9) : relativePath);
|
|
34
34
|
|
|
35
|
-
File.write(filePath, render(fileContents, replacements, undefined, ['<%', '%>']));
|
|
35
|
+
File.write(filePath, Mustache.render(fileContents, replacements, undefined, ['<%', '%>']));
|
|
36
36
|
files.push(filePath);
|
|
37
37
|
}
|
|
38
38
|
|
|
@@ -43,18 +43,21 @@ export default class Template {
|
|
|
43
43
|
replacements: Record<string, unknown>,
|
|
44
44
|
prefix: string = '',
|
|
45
45
|
): Record<string, string> {
|
|
46
|
-
return Object.entries(replacements).reduce(
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
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
|
+
);
|
|
58
61
|
}
|
|
59
62
|
|
|
60
63
|
}
|
package/src/lib/utils/app.ts
CHANGED
package/src/lib/utils/edit.ts
CHANGED
|
@@ -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();
|