@aerogel/cli 0.0.0-next.59bf5f7cc06e728d0cf6c00de28f1da48d7d6b8e → 0.0.0-next.7e89f52eb37d9154f4879a5ccd058d27d476dada
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/dist/aerogel-cli.cjs.js +1 -1
- package/dist/aerogel-cli.esm.js +1 -1
- package/noeldemartin.config.js +11 -1
- package/package.json +3 -2
- package/src/cli.ts +4 -0
- package/src/commands/create.test.ts +2 -3
- package/src/commands/create.ts +10 -2
- package/src/commands/generate-component.test.ts +1 -1
- package/src/commands/generate-component.ts +111 -16
- package/src/commands/generate-model.test.ts +2 -2
- package/src/commands/generate-model.ts +15 -17
- package/src/commands/generate-service.test.ts +21 -0
- package/src/commands/generate-service.ts +152 -0
- package/src/commands/install.test.ts +18 -0
- package/src/commands/install.ts +32 -0
- package/src/lib/App.ts +60 -5
- package/src/lib/Editor.ts +51 -0
- package/src/lib/File.ts +6 -0
- package/src/lib/Log.mock.ts +2 -1
- package/src/lib/Log.ts +6 -4
- package/src/lib/utils/app.ts +15 -0
- package/src/lib/utils/edit.ts +44 -0
- package/src/lib/{utils.test.ts → utils/format.test.ts} +2 -2
- package/src/lib/{utils.ts → utils/format.ts} +0 -6
- package/src/lib/utils/paths.ts +34 -0
- package/src/plugins/Plugin.ts +125 -0
- package/src/plugins/Solid.ts +65 -0
- package/src/plugins/Soukai.ts +19 -0
- package/src/testing/setup.ts +36 -6
- package/templates/app/.eslintrc.js +3 -0
- package/templates/app/.vscode/launch.json +16 -0
- package/templates/app/.vscode/settings.json +10 -0
- package/templates/app/cypress.config.ts +4 -0
- package/templates/app/index.html +1 -1
- package/templates/app/package.json +17 -7
- package/templates/app/prettier.config.js +5 -0
- package/templates/app/src/App.vue +3 -1
- package/templates/app/src/types/globals.d.ts +0 -1
- package/templates/app/tailwind.config.js +1 -1
- package/templates/app/vite.config.ts +0 -1
- package/templates/service/[service.name].ts +8 -0
|
@@ -0,0 +1,65 @@
|
|
|
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';
|
|
11
|
+
|
|
12
|
+
export class Solid extends Plugin {
|
|
13
|
+
|
|
14
|
+
constructor() {
|
|
15
|
+
super('solid');
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
protected async updateFiles(editor: Editor): Promise<void> {
|
|
19
|
+
await this.updateTailwindConfig(editor);
|
|
20
|
+
await super.updateFiles(editor);
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
protected async installNpmDependencies(): Promise<void> {
|
|
24
|
+
await Shell.run('npm install soukai-solid@next');
|
|
25
|
+
await super.installNpmDependencies();
|
|
26
|
+
}
|
|
27
|
+
|
|
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\'';
|
|
35
|
+
|
|
36
|
+
if (!contentArray) {
|
|
37
|
+
return Log.fail(`
|
|
38
|
+
Could not find content array in tailwind config, please add the following manually:
|
|
39
|
+
|
|
40
|
+
${contentValue}
|
|
41
|
+
`);
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
contentArray.addElement(contentValue);
|
|
45
|
+
|
|
46
|
+
await editor.save(tailwindConfig);
|
|
47
|
+
});
|
|
48
|
+
}
|
|
49
|
+
|
|
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();
|
|
57
|
+
|
|
58
|
+
if (!Node.isArrayLiteralExpression(contentArray)) {
|
|
59
|
+
return null;
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
return contentArray;
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import Plugin from '@/plugins/Plugin';
|
|
2
|
+
import Shell from '@/lib/Shell';
|
|
3
|
+
|
|
4
|
+
export class Soukai extends Plugin {
|
|
5
|
+
|
|
6
|
+
constructor() {
|
|
7
|
+
super('soukai');
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
protected async installNpmDependencies(): Promise<void> {
|
|
11
|
+
await Shell.run('npm install soukai@next');
|
|
12
|
+
await super.installNpmDependencies();
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
protected getBootstrapConfig(): string {
|
|
16
|
+
return 'soukai({ models: import.meta.glob(\'@/models/*\', { eager: true }) })';
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
}
|
package/src/testing/setup.ts
CHANGED
|
@@ -24,16 +24,46 @@ beforeEach(() => {
|
|
|
24
24
|
Shell.mock();
|
|
25
25
|
});
|
|
26
26
|
|
|
27
|
+
vi.mock('@/lib/utils/app', async () => {
|
|
28
|
+
const original = (await vi.importActual('@/lib/utils/app')) as object;
|
|
29
|
+
|
|
30
|
+
return {
|
|
31
|
+
...original,
|
|
32
|
+
isLocalApp: () => false,
|
|
33
|
+
isLinkedLocalApp: () => false,
|
|
34
|
+
};
|
|
35
|
+
});
|
|
36
|
+
|
|
37
|
+
vi.mock('@/lib/utils/edit', async () => {
|
|
38
|
+
const original = (await vi.importActual('@/lib/utils/edit')) as object;
|
|
39
|
+
|
|
40
|
+
return {
|
|
41
|
+
...original,
|
|
42
|
+
editFiles: () => false,
|
|
43
|
+
};
|
|
44
|
+
});
|
|
45
|
+
|
|
27
46
|
// 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 basePath(path: string = '') {
|
|
51
|
+
return resolve(__dirname, '../../', path);
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
function packagePath(packageName: string) {
|
|
55
|
+
return basePath(`../${packageName}`);
|
|
56
|
+
}
|
|
28
57
|
|
|
29
|
-
|
|
30
|
-
|
|
58
|
+
function templatePath(name: string = '') {
|
|
59
|
+
return resolve(__dirname, `../../templates/${name}`);
|
|
60
|
+
}
|
|
31
61
|
|
|
32
62
|
return {
|
|
33
|
-
...
|
|
34
|
-
basePath
|
|
35
|
-
|
|
36
|
-
|
|
63
|
+
...original,
|
|
64
|
+
basePath,
|
|
65
|
+
packagePath,
|
|
66
|
+
templatePath,
|
|
37
67
|
};
|
|
38
68
|
});
|
|
39
69
|
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": "0.2.0",
|
|
3
|
+
"configurations": [
|
|
4
|
+
{
|
|
5
|
+
"type": "node",
|
|
6
|
+
"request": "launch",
|
|
7
|
+
"name": "Debug Current Test File",
|
|
8
|
+
"autoAttachChildProcesses": true,
|
|
9
|
+
"skipFiles": ["<node_internals>/**", "**/node_modules/**"],
|
|
10
|
+
"program": "${workspaceRoot}/node_modules/vitest/vitest.mjs",
|
|
11
|
+
"args": ["run", "${fileBasenameNoExtension}"],
|
|
12
|
+
"smartStep": true,
|
|
13
|
+
"console": "integratedTerminal"
|
|
14
|
+
}
|
|
15
|
+
]
|
|
16
|
+
}
|
package/templates/app/index.html
CHANGED
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
|
6
6
|
<title><% app.name %></title>
|
|
7
7
|
</head>
|
|
8
|
-
<body class="h-full w-full">
|
|
8
|
+
<body class="h-full w-full text-base font-normal leading-tight text-gray-900 antialiased">
|
|
9
9
|
<div id="app" class="h-full"></div>
|
|
10
10
|
<script type="module" src="./src/main.ts"></script>
|
|
11
11
|
</body>
|
|
@@ -8,6 +8,8 @@
|
|
|
8
8
|
"cy:open": "cypress open --e2e --browser chromium",
|
|
9
9
|
"cy:run": "cypress run",
|
|
10
10
|
"cy:test": "start-server-and-test test:serve-app http-get://localhost:5001 cy:run",
|
|
11
|
+
"cy:test-snapshots": "docker run -it -u `id -u ${whoami}` -e CYPRESS_SNAPSHOTS=true -v ./:/app -w /app cypress/base:18.16.0 sh -c \"npx cypress install && npm run cy:test\"",
|
|
12
|
+
"cy:test-snapshots:ci": "docker run -e CYPRESS_SNAPSHOTS=true -v ./:/app -w /app cypress/base:18.16.0 sh -c \"npx cypress install && npm run cy:test\"",
|
|
11
13
|
"dev": "vite",
|
|
12
14
|
"lint": "noeldemartin-lint src",
|
|
13
15
|
"test": "vitest --run",
|
|
@@ -15,30 +17,38 @@
|
|
|
15
17
|
"test:serve-app": "vite --port 5001"
|
|
16
18
|
},
|
|
17
19
|
"dependencies": {
|
|
18
|
-
"@aerogel/core": "<%
|
|
19
|
-
"@aerogel/plugin-i18n": "<%
|
|
20
|
-
"@aerogel/plugin-soukai": "<%
|
|
20
|
+
"@aerogel/core": "<% &dependencies.aerogelCore %>",
|
|
21
|
+
"@aerogel/plugin-i18n": "<% &dependencies.aerogelPluginI18n %>",
|
|
22
|
+
"@aerogel/plugin-soukai": "<% &dependencies.aerogelPluginSoukai %>",
|
|
21
23
|
"@intlify/unplugin-vue-i18n": "^0.12.2",
|
|
22
24
|
"@noeldemartin/utils": "next",
|
|
23
25
|
"@tailwindcss/forms": "^0.5.3",
|
|
24
26
|
"@tailwindcss/typography": "^0.5.9",
|
|
27
|
+
"soukai": "next",
|
|
25
28
|
"tailwindcss": "^3.3.2",
|
|
26
29
|
"vue": "^3.3.0",
|
|
27
30
|
"vue-i18n": "9.3.0-beta.19"
|
|
28
31
|
},
|
|
29
32
|
"devDependencies": {
|
|
30
|
-
"@aerogel/cli": "<%
|
|
31
|
-
"@aerogel/cypress": "<%
|
|
32
|
-
"@aerogel/vite": "<%
|
|
33
|
+
"@aerogel/cli": "<% &dependencies.aerogelCli %>",
|
|
34
|
+
"@aerogel/cypress": "<% &dependencies.aerogelCypress %>",
|
|
35
|
+
"@aerogel/vite": "<% &dependencies.aerogelVite %>",
|
|
36
|
+
"@noeldemartin/eslint-config-vue": "next",
|
|
37
|
+
"@noeldemartin/scripts": "next",
|
|
33
38
|
"@total-typescript/ts-reset": "^0.4.2",
|
|
34
39
|
"@types/node": "^20.3.1",
|
|
35
40
|
"autoprefixer": "^10.4.14",
|
|
36
41
|
"concurrently": "^8.2.0",
|
|
37
42
|
"cypress": "^12.17.0",
|
|
43
|
+
"eslint": "^8.40.0",
|
|
44
|
+
"prettier": "^2.8.8",
|
|
45
|
+
"prettier-eslint-cli": "^7.1.0",
|
|
46
|
+
"prettier-plugin-tailwindcss": "^0.2.8",
|
|
38
47
|
"start-server-and-test": "^2.0.0",
|
|
39
48
|
"unplugin-icons": "^0.16.3",
|
|
40
49
|
"unplugin-vue-components": "^0.24.1",
|
|
41
50
|
"vite": "^4.3.0",
|
|
42
|
-
"vitest": "^0.33.0"
|
|
51
|
+
"vitest": "^0.33.0",
|
|
52
|
+
"vue-tsc": "^1.8.15"
|
|
43
53
|
}
|
|
44
54
|
}
|
|
@@ -1,7 +1,9 @@
|
|
|
1
1
|
<template>
|
|
2
2
|
<AGAppLayout>
|
|
3
3
|
<main class="flex flex-grow flex-col items-center justify-center bg-blue-50">
|
|
4
|
-
<h1 class="text-4xl font-semibold">
|
|
4
|
+
<h1 class="text-4xl font-semibold">
|
|
5
|
+
{{ $t('home.title') }}
|
|
6
|
+
</h1>
|
|
5
7
|
<a href="https://aerogel.js.org" target="_blank" class="mt-2 underline opacity-75 hover:opacity-100">
|
|
6
8
|
{{ $t('home.getStarted') }}
|
|
7
9
|
</a>
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/** @type {import('tailwindcss').Config} */
|
|
2
2
|
module.exports = {
|
|
3
|
-
content: ['./index.html', './src/**/*.{vue,ts}', '
|
|
3
|
+
content: ['./index.html', './src/**/*.{vue,ts}', '<% &contentPath %>'],
|
|
4
4
|
plugins: [require('@tailwindcss/forms'), require('@tailwindcss/typography')],
|
|
5
5
|
};
|