@idevconn/create-icore 0.3.1 → 0.4.1
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/cli.js +31 -2
- package/dist/index.cjs +31 -2
- package/dist/index.js +31 -2
- package/package.json +1 -1
- package/templates/.yarn/releases/yarn-4.15.0.cjs +940 -0
- package/templates/.yarnrc.yml +6 -1
- package/templates/apps/microservices/auth/src/app/app.module.ts +23 -13
- package/templates/apps/microservices/notes/src/app/app.module.ts +33 -23
- package/templates/apps/microservices/upload/src/app/app.module.ts +28 -18
- package/templates/apps/templates/client-antd/vite.config.mts +16 -48
- package/templates/apps/templates/client-mui/vite.config.mts +16 -48
- package/templates/apps/templates/client-shadcn/vite.config.mts +16 -48
- package/templates/libs/shared/package.json +10 -0
- package/templates/libs/shared/src/__tests__/cross-boundary.unit.test.ts +121 -0
- package/templates/libs/shared/src/client.ts +5 -0
- package/templates/libs/template-shared/src/lib/abilities/ability-provider.tsx +1 -1
- package/templates/libs/vite-plugins/README.md +7 -0
- package/templates/libs/vite-plugins/eslint.config.mjs +19 -0
- package/templates/libs/vite-plugins/package.json +18 -0
- package/templates/libs/vite-plugins/project.json +19 -0
- package/templates/libs/vite-plugins/src/index.d.mts +21 -0
- package/templates/libs/vite-plugins/src/index.mjs +106 -0
- package/templates/libs/vite-plugins/tsconfig.json +20 -0
- package/templates/libs/vite-plugins/tsconfig.lib.json +9 -0
- package/templates/tsconfig.base.json +3 -1
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { AbilityProvider as CaslAbilityProvider, Can } from '@casl/react';
|
|
2
2
|
import type { ReactNode } from 'react';
|
|
3
3
|
import { useMemo } from 'react';
|
|
4
|
-
import { defineAbilitiesFor, type AppAbility } from '@icore/shared';
|
|
4
|
+
import { defineAbilitiesFor, type AppAbility } from '@icore/shared/client';
|
|
5
5
|
import { useAuthStore } from '../stores/auth.store.js';
|
|
6
6
|
|
|
7
7
|
export { Can };
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import baseConfig from '../../eslint.config.mjs';
|
|
2
|
+
|
|
3
|
+
export default [
|
|
4
|
+
...baseConfig,
|
|
5
|
+
{
|
|
6
|
+
files: ['**/*.json'],
|
|
7
|
+
rules: {
|
|
8
|
+
'@nx/dependency-checks': [
|
|
9
|
+
'error',
|
|
10
|
+
{
|
|
11
|
+
ignoredFiles: ['{projectRoot}/eslint.config.{js,cjs,mjs,ts,cts,mts}'],
|
|
12
|
+
},
|
|
13
|
+
],
|
|
14
|
+
},
|
|
15
|
+
languageOptions: {
|
|
16
|
+
parser: await import('jsonc-eslint-parser'),
|
|
17
|
+
},
|
|
18
|
+
},
|
|
19
|
+
];
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@icore/vite-plugins",
|
|
3
|
+
"version": "0.0.1",
|
|
4
|
+
"private": true,
|
|
5
|
+
"type": "module",
|
|
6
|
+
"main": "./src/index.mjs",
|
|
7
|
+
"types": "./src/index.d.mts",
|
|
8
|
+
"peerDependencies": {
|
|
9
|
+
"tslib": "^2.3.0",
|
|
10
|
+
"vite": "^8.0.0",
|
|
11
|
+
"vitest": "~4.1.0"
|
|
12
|
+
},
|
|
13
|
+
"peerDependenciesMeta": {
|
|
14
|
+
"vite": {
|
|
15
|
+
"optional": false
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "vite-plugins",
|
|
3
|
+
"$schema": "../../node_modules/nx/schemas/project-schema.json",
|
|
4
|
+
"sourceRoot": "libs/vite-plugins/src",
|
|
5
|
+
"projectType": "library",
|
|
6
|
+
"tags": [],
|
|
7
|
+
"targets": {
|
|
8
|
+
"build": {
|
|
9
|
+
"executor": "@nx/js:tsc",
|
|
10
|
+
"outputs": ["{options.outputPath}"],
|
|
11
|
+
"options": {
|
|
12
|
+
"outputPath": "dist/libs/vite-plugins",
|
|
13
|
+
"main": "libs/vite-plugins/src/index.ts",
|
|
14
|
+
"tsConfig": "libs/vite-plugins/tsconfig.lib.json",
|
|
15
|
+
"assets": ["libs/vite-plugins/*.md"]
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import type { Plugin } from 'vite';
|
|
2
|
+
import type { UserConfig } from 'vitest/config';
|
|
3
|
+
|
|
4
|
+
export declare function noServerModulesPlugin(): Plugin;
|
|
5
|
+
|
|
6
|
+
export declare function injectAppVersionPlugin(pkg: { version: string }): Plugin;
|
|
7
|
+
|
|
8
|
+
export declare function commonDefines(pkg: {
|
|
9
|
+
version: string;
|
|
10
|
+
dependencies?: Record<string, string>;
|
|
11
|
+
devDependencies?: Record<string, string>;
|
|
12
|
+
}): Record<string, string>;
|
|
13
|
+
|
|
14
|
+
export declare function commonManualChunks(
|
|
15
|
+
uiChunkFn?: (id: string) => string | undefined,
|
|
16
|
+
): (id: string) => string | undefined;
|
|
17
|
+
|
|
18
|
+
export declare function commonTestConfig(
|
|
19
|
+
name: string,
|
|
20
|
+
coverageDir: string,
|
|
21
|
+
): NonNullable<UserConfig['test']>;
|
|
@@ -0,0 +1,106 @@
|
|
|
1
|
+
// @icore/vite-plugins — shared Vite plugin helpers for iCore client templates.
|
|
2
|
+
// Plain ESM (no TypeScript syntax) so vite.config.mts can import it directly.
|
|
3
|
+
|
|
4
|
+
const SERVER_ONLY_RE = /^(@nestjs\/|firebase-admin$|bullmq$|ioredis$)/;
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* Fails the Vite build if server-only modules are imported in client code.
|
|
8
|
+
* @returns {import('vite').Plugin}
|
|
9
|
+
*/
|
|
10
|
+
export function noServerModulesPlugin() {
|
|
11
|
+
return {
|
|
12
|
+
name: 'no-server-modules',
|
|
13
|
+
enforce: 'pre',
|
|
14
|
+
resolveId(id, importer) {
|
|
15
|
+
if (SERVER_ONLY_RE.test(id)) {
|
|
16
|
+
throw new Error(
|
|
17
|
+
`Server-only module "${id}" imported in client code` +
|
|
18
|
+
(importer ? ` (from ${importer})` : '') +
|
|
19
|
+
`. Use @icore/shared/client instead of @icore/shared for browser-safe imports.`,
|
|
20
|
+
);
|
|
21
|
+
}
|
|
22
|
+
},
|
|
23
|
+
};
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
/**
|
|
27
|
+
* Replaces %APP_VERSION% in index.html with the root package.json version.
|
|
28
|
+
* @param {{ version: string }} pkg
|
|
29
|
+
* @returns {import('vite').Plugin}
|
|
30
|
+
*/
|
|
31
|
+
export function injectAppVersionPlugin(pkg) {
|
|
32
|
+
return {
|
|
33
|
+
name: 'inject-app-version-meta',
|
|
34
|
+
transformIndexHtml(html) {
|
|
35
|
+
return html.replace('%APP_VERSION%', pkg.version);
|
|
36
|
+
},
|
|
37
|
+
};
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
/**
|
|
41
|
+
* Returns Vite `define` entries shared by all iCore client templates.
|
|
42
|
+
* Each template spreads this and adds its own UI-lib-specific entry.
|
|
43
|
+
*
|
|
44
|
+
* @param {{ version: string, dependencies?: Record<string,string>, devDependencies?: Record<string,string> }} pkg
|
|
45
|
+
* @returns {Record<string, string>}
|
|
46
|
+
*/
|
|
47
|
+
export function commonDefines(pkg) {
|
|
48
|
+
const dep = (name) =>
|
|
49
|
+
JSON.stringify(pkg.dependencies?.[name] ?? pkg.devDependencies?.[name] ?? '?');
|
|
50
|
+
return {
|
|
51
|
+
'import.meta.env.VITE_APP_VERSION': JSON.stringify(pkg.version),
|
|
52
|
+
'import.meta.env.VITE_DEP_REACT': dep('react'),
|
|
53
|
+
'import.meta.env.VITE_DEP_VITE': dep('vite'),
|
|
54
|
+
'import.meta.env.VITE_DEP_TANSTACK_ROUTER': dep('@tanstack/react-router'),
|
|
55
|
+
'import.meta.env.VITE_DEP_TANSTACK_QUERY': dep('@tanstack/react-query'),
|
|
56
|
+
'import.meta.env.VITE_DEP_ZUSTAND': dep('zustand'),
|
|
57
|
+
'import.meta.env.VITE_DEP_CASL': dep('@casl/ability'),
|
|
58
|
+
};
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
/**
|
|
62
|
+
* Returns a manualChunks function with the common vendor splits pre-applied.
|
|
63
|
+
* Pass a `uiChunkFn` to add UI-library-specific splits before the fallback.
|
|
64
|
+
*
|
|
65
|
+
* @param {(id: string) => string | undefined} [uiChunkFn]
|
|
66
|
+
* @returns {(id: string) => string | undefined}
|
|
67
|
+
*/
|
|
68
|
+
export function commonManualChunks(uiChunkFn) {
|
|
69
|
+
return (id) => {
|
|
70
|
+
if (!id.includes('node_modules')) return undefined;
|
|
71
|
+
if (id.includes('/react/') || id.includes('/react-dom/') || id.includes('scheduler'))
|
|
72
|
+
return 'vendor-react';
|
|
73
|
+
if (id.includes('@tanstack')) return 'vendor-tanstack';
|
|
74
|
+
if (id.includes('i18next') || id.includes('react-i18next')) return 'vendor-i18n';
|
|
75
|
+
if (id.includes('@casl')) return 'vendor-casl';
|
|
76
|
+
if (uiChunkFn) {
|
|
77
|
+
const chunk = uiChunkFn(id);
|
|
78
|
+
if (chunk) return chunk;
|
|
79
|
+
}
|
|
80
|
+
if (id.includes('zustand')) return 'vendor-state';
|
|
81
|
+
if (id.includes('@idevconn')) return 'vendor-idevconn';
|
|
82
|
+
return 'vendor-core';
|
|
83
|
+
};
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
/**
|
|
87
|
+
* Returns a vitest `test` configuration block shared by all iCore client templates.
|
|
88
|
+
*
|
|
89
|
+
* @param {string} name - project name (e.g. 'client-shadcn')
|
|
90
|
+
* @param {string} coverageDir - relative path to coverage output dir
|
|
91
|
+
* @returns {import('vitest/config').UserConfig['test']}
|
|
92
|
+
*/
|
|
93
|
+
export function commonTestConfig(name, coverageDir) {
|
|
94
|
+
return {
|
|
95
|
+
name,
|
|
96
|
+
watch: false,
|
|
97
|
+
globals: true,
|
|
98
|
+
environment: 'jsdom',
|
|
99
|
+
include: ['{src,tests}/**/*.{test,spec}.{js,mjs,cjs,ts,mts,cts,jsx,tsx}'],
|
|
100
|
+
reporters: ['default'],
|
|
101
|
+
coverage: {
|
|
102
|
+
reportsDirectory: coverageDir,
|
|
103
|
+
provider: 'v8',
|
|
104
|
+
},
|
|
105
|
+
};
|
|
106
|
+
}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
{
|
|
2
|
+
"extends": "../../tsconfig.base.json",
|
|
3
|
+
"compilerOptions": {
|
|
4
|
+
"module": "commonjs",
|
|
5
|
+
"forceConsistentCasingInFileNames": true,
|
|
6
|
+
"strict": true,
|
|
7
|
+
"importHelpers": true,
|
|
8
|
+
"noImplicitOverride": true,
|
|
9
|
+
"noImplicitReturns": true,
|
|
10
|
+
"noFallthroughCasesInSwitch": true,
|
|
11
|
+
"noPropertyAccessFromIndexSignature": true
|
|
12
|
+
},
|
|
13
|
+
"files": [],
|
|
14
|
+
"include": [],
|
|
15
|
+
"references": [
|
|
16
|
+
{
|
|
17
|
+
"path": "./tsconfig.lib.json"
|
|
18
|
+
}
|
|
19
|
+
]
|
|
20
|
+
}
|
|
@@ -13,6 +13,7 @@
|
|
|
13
13
|
"baseUrl": ".",
|
|
14
14
|
"paths": {
|
|
15
15
|
"@icore/shared": ["./libs/shared/src/index.ts"],
|
|
16
|
+
"@icore/shared/client": ["./libs/shared/src/client.ts"],
|
|
16
17
|
"@icore/auth-supabase": ["./libs/auth-strategies/supabase/src/index.ts"],
|
|
17
18
|
"@icore/auth-client": ["./libs/auth-client/src/index.ts"],
|
|
18
19
|
"@icore/package.json": ["./package.json"],
|
|
@@ -27,7 +28,8 @@
|
|
|
27
28
|
"@icore/db-firestore": ["./libs/db-strategies/firestore/src/index.ts"],
|
|
28
29
|
"@icore/payment-client": ["./libs/payment-client/src/index.ts"],
|
|
29
30
|
"@icore/notes-client": ["./libs/notes-client/src/index.ts"],
|
|
30
|
-
"@icore/jobs-client": ["./libs/jobs-client/src/index.ts"]
|
|
31
|
+
"@icore/jobs-client": ["./libs/jobs-client/src/index.ts"],
|
|
32
|
+
"@icore/vite-plugins": ["./libs/vite-plugins/src/index.d.mts"]
|
|
31
33
|
}
|
|
32
34
|
},
|
|
33
35
|
"exclude": ["node_modules", "dist", ".nx"]
|