@aerogel/cli 0.0.0-next.59bf5f7cc06e728d0cf6c00de28f1da48d7d6b8e → 0.0.0-next.b85327579d32f21c6a9fa21142f0165cdd320d7e

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 (41) hide show
  1. package/dist/aerogel-cli.cjs.js +1 -1
  2. package/dist/aerogel-cli.esm.js +1 -1
  3. package/noeldemartin.config.js +11 -1
  4. package/package.json +3 -2
  5. package/src/cli.ts +4 -0
  6. package/src/commands/create.test.ts +2 -3
  7. package/src/commands/create.ts +10 -2
  8. package/src/commands/generate-component.test.ts +1 -1
  9. package/src/commands/generate-component.ts +112 -15
  10. package/src/commands/generate-model.test.ts +2 -2
  11. package/src/commands/generate-model.ts +15 -17
  12. package/src/commands/generate-service.test.ts +21 -0
  13. package/src/commands/generate-service.ts +152 -0
  14. package/src/commands/install.test.ts +18 -0
  15. package/src/commands/install.ts +32 -0
  16. package/src/lib/App.ts +59 -4
  17. package/src/lib/Editor.ts +51 -0
  18. package/src/lib/File.ts +6 -0
  19. package/src/lib/Log.mock.ts +2 -1
  20. package/src/lib/Log.ts +6 -4
  21. package/src/lib/utils/app.ts +15 -0
  22. package/src/lib/utils/edit.ts +44 -0
  23. package/src/lib/{utils.test.ts → utils/format.test.ts} +2 -2
  24. package/src/lib/{utils.ts → utils/format.ts} +0 -6
  25. package/src/lib/utils/paths.ts +30 -0
  26. package/src/plugins/Plugin.ts +125 -0
  27. package/src/plugins/Solid.ts +65 -0
  28. package/src/plugins/Soukai.ts +19 -0
  29. package/src/testing/setup.ts +31 -6
  30. package/templates/app/.eslintrc.js +3 -0
  31. package/templates/app/.vscode/launch.json +16 -0
  32. package/templates/app/.vscode/settings.json +10 -0
  33. package/templates/app/cypress.config.ts +4 -0
  34. package/templates/app/index.html +1 -1
  35. package/templates/app/package.json +17 -7
  36. package/templates/app/prettier.config.js +5 -0
  37. package/templates/app/src/App.vue +3 -1
  38. package/templates/app/src/types/globals.d.ts +0 -1
  39. package/templates/app/tailwind.config.js +1 -1
  40. package/templates/app/vite.config.ts +0 -1
  41. 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
+ }
@@ -24,16 +24,41 @@ 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
+ }
28
53
 
29
- vi.mock('@/lib/utils', async () => {
30
- const utils = (await vi.importActual('@/lib/utils')) as object;
54
+ function packagePath(packageName: string) {
55
+ return basePath(`../${packageName}`);
56
+ }
31
57
 
32
58
  return {
33
- ...utils,
34
- basePath(path: string = '') {
35
- return resolve(__dirname, '../../', path);
36
- },
59
+ ...original,
60
+ basePath,
61
+ packagePath,
37
62
  };
38
63
  });
39
64
 
@@ -0,0 +1,3 @@
1
+ module.exports = {
2
+ extends: ['@noeldemartin/eslint-config-vue'],
3
+ };
@@ -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
+ }
@@ -0,0 +1,10 @@
1
+ {
2
+ "emeraldwalk.runonsave": {
3
+ "commands": [
4
+ {
5
+ "match": ".*",
6
+ "cmd": "npx prettier-eslint ${file} --write"
7
+ }
8
+ ]
9
+ }
10
+ }
@@ -1,8 +1,12 @@
1
+ import install from '@aerogel/cypress/dist/plugin';
1
2
  import { defineConfig } from 'cypress';
2
3
 
3
4
  export default defineConfig({
4
5
  e2e: {
5
6
  baseUrl: 'http://localhost:5001',
6
7
  video: false,
8
+ setupNodeEvents(on) {
9
+ install(on);
10
+ },
7
11
  },
8
12
  });
@@ -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": "<% #local %>file:<% &local.aerogelPath %>/core<% /local %><% ^local %>next<% /local %>",
19
- "@aerogel/plugin-i18n": "<% #local %>file:<% &local.aerogelPath %>/plugin-i18n<% /local %><% ^local %>next<% /local %>",
20
- "@aerogel/plugin-soukai": "<% #local %>file:<% &local.aerogelPath %>/plugin-soukai<% /local %><% ^local %>next<% /local %>",
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": "<% #local %>file:<% &local.aerogelPath %>/cli<% /local %><% ^local %>next<% /local %>",
31
- "@aerogel/cypress": "<% #local %>file:<% &local.aerogelPath %>/cypress<% /local %><% ^local %>next<% /local %>",
32
- "@aerogel/vite": "<% #local %>file:<% &local.aerogelPath %>/vite<% /local %><% ^local %>next<% /local %>",
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
  }
@@ -0,0 +1,5 @@
1
+ /** @type {import('prettier').Config} */
2
+ module.exports = {
3
+ plugins: [require('prettier-plugin-tailwindcss')],
4
+ printWidth: 120,
5
+ };
@@ -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">{{ $t('home.title') }}</h1>
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,3 +1,2 @@
1
1
  /// <reference types="vite/client" />
2
- /// <reference types="vue-router" />
3
2
  /// <reference types="vue-i18n" />
@@ -1,5 +1,5 @@
1
1
  /** @type {import('tailwindcss').Config} */
2
2
  module.exports = {
3
- content: ['./index.html', './src/**/*.{vue,ts}', './node_modules/@aerogel/core/dist/**/*.js'],
3
+ content: ['./index.html', './src/**/*.{vue,ts}', '<% &contentPath %>'],
4
4
  plugins: [require('@tailwindcss/forms'), require('@tailwindcss/typography')],
5
5
  };
@@ -9,7 +9,6 @@ export default {
9
9
  plugins: [
10
10
  Aerogel(),
11
11
  Components({
12
- dirs: ['src/pages'],
13
12
  dts: false,
14
13
  resolvers: [AerogelResolver(), IconsResolver()],
15
14
  }),
@@ -0,0 +1,8 @@
1
+ import { Service } from '@aerogel/core';
2
+ import { facade } from '@noeldemartin/utils';
3
+
4
+ export class <% service.name %>Service extends Service {
5
+
6
+ }
7
+
8
+ export default facade(new <% service.name %>Service());