create-super-admin 0.0.0-bootstrap.0
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/README.md +9 -0
- package/dist/cli.d.ts +3 -0
- package/dist/cli.d.ts.map +1 -0
- package/dist/cli.js +4 -0
- package/dist/generate-starter.d.ts +9 -0
- package/dist/generate-starter.d.ts.map +1 -0
- package/dist/generate-starter.js +150 -0
- package/dist/index.d.ts +8 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +3 -0
- package/dist/parse-args.d.ts +21 -0
- package/dist/parse-args.d.ts.map +1 -0
- package/dist/parse-args.js +104 -0
- package/dist/run-create-super-admin.d.ts +8 -0
- package/dist/run-create-super-admin.d.ts.map +1 -0
- package/dist/run-create-super-admin.js +33 -0
- package/dist/templates.d.ts +22 -0
- package/dist/templates.d.ts.map +1 -0
- package/dist/templates.js +998 -0
- package/dist/theme-options.d.ts +14 -0
- package/dist/theme-options.d.ts.map +1 -0
- package/dist/theme-options.js +35 -0
- package/package.json +43 -0
package/README.md
ADDED
package/dist/cli.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"cli.d.ts","sourceRoot":"","sources":["../src/cli.ts"],"names":[],"mappings":""}
|
package/dist/cli.js
ADDED
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import type { StarterGenerationInput } from './parse-args.js';
|
|
2
|
+
export type GenerateStarterOptions = {
|
|
3
|
+
sourceRoot?: string;
|
|
4
|
+
};
|
|
5
|
+
export type GenerateStarterResult = {
|
|
6
|
+
targetDirectory: string;
|
|
7
|
+
};
|
|
8
|
+
export declare function generateStarter(input: StarterGenerationInput, options?: GenerateStarterOptions): Promise<GenerateStarterResult>;
|
|
9
|
+
//# sourceMappingURL=generate-starter.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"generate-starter.d.ts","sourceRoot":"","sources":["../src/generate-starter.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,iBAAiB,CAAA;AAoB7D,MAAM,MAAM,sBAAsB,GAAG;IACnC,UAAU,CAAC,EAAE,MAAM,CAAA;CACpB,CAAA;AAED,MAAM,MAAM,qBAAqB,GAAG;IAClC,eAAe,EAAE,MAAM,CAAA;CACxB,CAAA;AAkKD,wBAAsB,eAAe,CACnC,KAAK,EAAE,sBAAsB,EAC7B,OAAO,GAAE,sBAA2B,GACnC,OAAO,CAAC,qBAAqB,CAAC,CAyBhC"}
|
|
@@ -0,0 +1,150 @@
|
|
|
1
|
+
import { cp, mkdir, readFile, readdir, rename, rm, rmdir, writeFile } from 'node:fs/promises';
|
|
2
|
+
import { dirname, relative, resolve, sep } from 'node:path';
|
|
3
|
+
import { fileURLToPath } from 'node:url';
|
|
4
|
+
import { createAuthSession, createAuthSessionStore, createAuthTypes, createEnvDts, createGlobalPreferences, createI18nIndex, createIndexHtml, createLoginPage, createPackageJson, createPreferencesStore, createReadme, createSuperAdminConfig, createThemeRegistry, createTsconfig, createUsersApi, createViteConfig } from './templates.js';
|
|
5
|
+
function getDefaultSourceRoot() {
|
|
6
|
+
return resolve(dirname(fileURLToPath(import.meta.url)), '../../..');
|
|
7
|
+
}
|
|
8
|
+
function toPosixPath(path) {
|
|
9
|
+
return path.split(sep).join('/');
|
|
10
|
+
}
|
|
11
|
+
async function directoryEntries(path) {
|
|
12
|
+
try {
|
|
13
|
+
return await readdir(path, { withFileTypes: true });
|
|
14
|
+
}
|
|
15
|
+
catch (error) {
|
|
16
|
+
if (error instanceof Error && 'code' in error && error.code === 'ENOENT') {
|
|
17
|
+
return null;
|
|
18
|
+
}
|
|
19
|
+
throw error;
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
async function ensureTargetIsWritable(targetDirectory) {
|
|
23
|
+
const entries = await directoryEntries(targetDirectory);
|
|
24
|
+
if (!entries) {
|
|
25
|
+
return;
|
|
26
|
+
}
|
|
27
|
+
if (entries.length > 0) {
|
|
28
|
+
throw new Error(`Target directory is not empty: ${targetDirectory}`);
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
async function writeText(root, filePath, content) {
|
|
32
|
+
const target = resolve(root, filePath);
|
|
33
|
+
await mkdir(dirname(target), { recursive: true });
|
|
34
|
+
await writeFile(target, content);
|
|
35
|
+
}
|
|
36
|
+
function shouldSkipSourceFile(relativePath, context) {
|
|
37
|
+
if (relativePath.startsWith('api/reference/')) {
|
|
38
|
+
return true;
|
|
39
|
+
}
|
|
40
|
+
if (/\.(test|spec)\.(ts|tsx|js|mjs)$/.test(relativePath)) {
|
|
41
|
+
return true;
|
|
42
|
+
}
|
|
43
|
+
if (relativePath.endsWith('.tsbuildinfo')) {
|
|
44
|
+
return true;
|
|
45
|
+
}
|
|
46
|
+
if (!context.input.i18n.switcher && relativePath === 'i18n/locales/en-US.ts') {
|
|
47
|
+
return true;
|
|
48
|
+
}
|
|
49
|
+
return false;
|
|
50
|
+
}
|
|
51
|
+
function transformSourceText(relativePath, text, context) {
|
|
52
|
+
if (relativePath === 'env.d.ts') {
|
|
53
|
+
return createEnvDts();
|
|
54
|
+
}
|
|
55
|
+
if (relativePath === 'api/users.api.ts') {
|
|
56
|
+
return createUsersApi();
|
|
57
|
+
}
|
|
58
|
+
if (relativePath === 'modules/auth/LoginPage.vue') {
|
|
59
|
+
return createLoginPage();
|
|
60
|
+
}
|
|
61
|
+
if (relativePath === 'modules/auth/auth-session.ts') {
|
|
62
|
+
return createAuthSession();
|
|
63
|
+
}
|
|
64
|
+
if (relativePath === 'modules/auth/auth.types.ts') {
|
|
65
|
+
return createAuthTypes();
|
|
66
|
+
}
|
|
67
|
+
if (relativePath === 'stores/auth-session.store.ts') {
|
|
68
|
+
return createAuthSessionStore();
|
|
69
|
+
}
|
|
70
|
+
if (relativePath === 'stores/preferences.store.ts') {
|
|
71
|
+
return createPreferencesStore();
|
|
72
|
+
}
|
|
73
|
+
if (relativePath === 'i18n/index.ts') {
|
|
74
|
+
return createI18nIndex(context.input.i18n.installed);
|
|
75
|
+
}
|
|
76
|
+
if (relativePath === 'shell/preferences/GlobalPreferences.vue') {
|
|
77
|
+
return createGlobalPreferences({
|
|
78
|
+
includeLocaleSwitcher: context.input.i18n.switcher,
|
|
79
|
+
includeThemeSwitcher: context.input.themes.installed.length > 1
|
|
80
|
+
});
|
|
81
|
+
}
|
|
82
|
+
if (relativePath === 'super-admin/theme-registry.generated.ts') {
|
|
83
|
+
return createThemeRegistry(context.input.themes.installed, context.input.themes.default);
|
|
84
|
+
}
|
|
85
|
+
if (relativePath === 'styles/main.css') {
|
|
86
|
+
return text.replace('@source "../../../../packages/ui/src";', '@source "../../node_modules/@super-admin-org/ui/dist";');
|
|
87
|
+
}
|
|
88
|
+
return text;
|
|
89
|
+
}
|
|
90
|
+
async function copySourceDirectory(sourceDir, targetDir, context, currentDir = sourceDir) {
|
|
91
|
+
const entries = await readdir(currentDir, { withFileTypes: true });
|
|
92
|
+
for (const entry of entries) {
|
|
93
|
+
const sourcePath = resolve(currentDir, entry.name);
|
|
94
|
+
const relativePath = toPosixPath(relative(sourceDir, sourcePath));
|
|
95
|
+
if (entry.isDirectory()) {
|
|
96
|
+
if (shouldSkipSourceFile(`${relativePath}/`, context)) {
|
|
97
|
+
continue;
|
|
98
|
+
}
|
|
99
|
+
await copySourceDirectory(sourceDir, targetDir, context, sourcePath);
|
|
100
|
+
continue;
|
|
101
|
+
}
|
|
102
|
+
if (!entry.isFile() || shouldSkipSourceFile(relativePath, context)) {
|
|
103
|
+
continue;
|
|
104
|
+
}
|
|
105
|
+
const targetPath = resolve(targetDir, relativePath);
|
|
106
|
+
await mkdir(dirname(targetPath), { recursive: true });
|
|
107
|
+
const text = await readFile(sourcePath, 'utf8');
|
|
108
|
+
await writeFile(targetPath, transformSourceText(relativePath, text, context));
|
|
109
|
+
}
|
|
110
|
+
}
|
|
111
|
+
async function writeGeneratedRootFiles(outputRoot, input, sourceAppDir) {
|
|
112
|
+
await cp(resolve(sourceAppDir, 'components.json'), resolve(outputRoot, 'components.json'));
|
|
113
|
+
await writeText(outputRoot, 'index.html', createIndexHtml(input.projectName));
|
|
114
|
+
await writeText(outputRoot, 'package.json', createPackageJson(input));
|
|
115
|
+
await writeText(outputRoot, 'README.md', createReadme(input.projectName, input.packageManager));
|
|
116
|
+
await writeText(outputRoot, 'super-admin.config.ts', createSuperAdminConfig(input));
|
|
117
|
+
await writeText(outputRoot, 'tsconfig.json', createTsconfig());
|
|
118
|
+
await writeText(outputRoot, 'vite.config.ts', createViteConfig());
|
|
119
|
+
}
|
|
120
|
+
async function materializeOutput(tempDirectory, targetDirectory) {
|
|
121
|
+
const targetEntries = await directoryEntries(targetDirectory);
|
|
122
|
+
if (targetEntries && targetEntries.length === 0) {
|
|
123
|
+
await rmdir(targetDirectory);
|
|
124
|
+
}
|
|
125
|
+
await rename(tempDirectory, targetDirectory);
|
|
126
|
+
}
|
|
127
|
+
export async function generateStarter(input, options = {}) {
|
|
128
|
+
const sourceRoot = options.sourceRoot ?? getDefaultSourceRoot();
|
|
129
|
+
const sourceAppDir = resolve(sourceRoot, 'apps/admin');
|
|
130
|
+
const targetDirectory = input.targetDirectory;
|
|
131
|
+
const tempDirectory = resolve(dirname(targetDirectory), `.${input.projectName}.tmp-${Date.now()}-${process.pid}`);
|
|
132
|
+
const context = {
|
|
133
|
+
input
|
|
134
|
+
};
|
|
135
|
+
await ensureTargetIsWritable(targetDirectory);
|
|
136
|
+
await rm(tempDirectory, { force: true, recursive: true });
|
|
137
|
+
await mkdir(tempDirectory, { recursive: true });
|
|
138
|
+
try {
|
|
139
|
+
await writeGeneratedRootFiles(tempDirectory, input, sourceAppDir);
|
|
140
|
+
await copySourceDirectory(resolve(sourceAppDir, 'src'), resolve(tempDirectory, 'src'), context);
|
|
141
|
+
await materializeOutput(tempDirectory, targetDirectory);
|
|
142
|
+
}
|
|
143
|
+
catch (error) {
|
|
144
|
+
await rm(tempDirectory, { force: true, recursive: true });
|
|
145
|
+
throw error;
|
|
146
|
+
}
|
|
147
|
+
return {
|
|
148
|
+
targetDirectory
|
|
149
|
+
};
|
|
150
|
+
}
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
export { generateStarter } from './generate-starter.js';
|
|
2
|
+
export { parseCreateSuperAdminArgs } from './parse-args.js';
|
|
3
|
+
export { runCreateSuperAdmin } from './run-create-super-admin.js';
|
|
4
|
+
export type { GenerateStarterOptions, GenerateStarterResult } from './generate-starter.js';
|
|
5
|
+
export type { ParseCreateSuperAdminArgsOptions, StarterGenerationInput } from './parse-args.js';
|
|
6
|
+
export type { CreateSuperAdminIo } from './run-create-super-admin.js';
|
|
7
|
+
export type { StarterLocaleId, StarterPackageManager, StarterThemeId } from './theme-options.js';
|
|
8
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,MAAM,uBAAuB,CAAA;AACvD,OAAO,EAAE,yBAAyB,EAAE,MAAM,iBAAiB,CAAA;AAC3D,OAAO,EAAE,mBAAmB,EAAE,MAAM,6BAA6B,CAAA;AACjE,YAAY,EAAE,sBAAsB,EAAE,qBAAqB,EAAE,MAAM,uBAAuB,CAAA;AAC1F,YAAY,EAAE,gCAAgC,EAAE,sBAAsB,EAAE,MAAM,iBAAiB,CAAA;AAC/F,YAAY,EAAE,kBAAkB,EAAE,MAAM,6BAA6B,CAAA;AACrE,YAAY,EAAE,eAAe,EAAE,qBAAqB,EAAE,cAAc,EAAE,MAAM,oBAAoB,CAAA"}
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import type { StarterLocaleId, StarterPackageManager, StarterThemeId } from './theme-options.js';
|
|
2
|
+
export type StarterGenerationInput = {
|
|
3
|
+
projectName: string;
|
|
4
|
+
packageName: string;
|
|
5
|
+
packageManager: StarterPackageManager;
|
|
6
|
+
targetDirectory: string;
|
|
7
|
+
themes: {
|
|
8
|
+
installed: StarterThemeId[];
|
|
9
|
+
default: StarterThemeId;
|
|
10
|
+
};
|
|
11
|
+
i18n: {
|
|
12
|
+
installed: StarterLocaleId[];
|
|
13
|
+
default: StarterLocaleId;
|
|
14
|
+
switcher: boolean;
|
|
15
|
+
};
|
|
16
|
+
};
|
|
17
|
+
export type ParseCreateSuperAdminArgsOptions = {
|
|
18
|
+
cwd?: string;
|
|
19
|
+
};
|
|
20
|
+
export declare function parseCreateSuperAdminArgs(argv: string[], options?: ParseCreateSuperAdminArgsOptions): StarterGenerationInput;
|
|
21
|
+
//# sourceMappingURL=parse-args.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"parse-args.d.ts","sourceRoot":"","sources":["../src/parse-args.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,eAAe,EAAE,qBAAqB,EAAE,cAAc,EAAE,MAAM,oBAAoB,CAAA;AAEhG,MAAM,MAAM,sBAAsB,GAAG;IACnC,WAAW,EAAE,MAAM,CAAA;IACnB,WAAW,EAAE,MAAM,CAAA;IACnB,cAAc,EAAE,qBAAqB,CAAA;IACrC,eAAe,EAAE,MAAM,CAAA;IACvB,MAAM,EAAE;QACN,SAAS,EAAE,cAAc,EAAE,CAAA;QAC3B,OAAO,EAAE,cAAc,CAAA;KACxB,CAAA;IACD,IAAI,EAAE;QACJ,SAAS,EAAE,eAAe,EAAE,CAAA;QAC5B,OAAO,EAAE,eAAe,CAAA;QACxB,QAAQ,EAAE,OAAO,CAAA;KAClB,CAAA;CACF,CAAA;AAED,MAAM,MAAM,gCAAgC,GAAG;IAC7C,GAAG,CAAC,EAAE,MAAM,CAAA;CACb,CAAA;AAgHD,wBAAgB,yBAAyB,CACvC,IAAI,EAAE,MAAM,EAAE,EACd,OAAO,GAAE,gCAAqC,GAC7C,sBAAsB,CA0BxB"}
|
|
@@ -0,0 +1,104 @@
|
|
|
1
|
+
import { basename, resolve } from 'node:path';
|
|
2
|
+
import { isStarterPackageManager, isStarterThemeId, starterPackageManagers, starterThemeIds } from './theme-options.js';
|
|
3
|
+
function readFlagValue(args, index, flag) {
|
|
4
|
+
const value = args[index + 1];
|
|
5
|
+
if (!value || value.startsWith('--')) {
|
|
6
|
+
throw new Error(`${flag} requires a value.`);
|
|
7
|
+
}
|
|
8
|
+
return value;
|
|
9
|
+
}
|
|
10
|
+
function parseFlags(argv) {
|
|
11
|
+
const parsed = {
|
|
12
|
+
i18n: false
|
|
13
|
+
};
|
|
14
|
+
for (let index = 0; index < argv.length; index += 1) {
|
|
15
|
+
const arg = argv[index];
|
|
16
|
+
if (arg === '--i18n') {
|
|
17
|
+
parsed.i18n = true;
|
|
18
|
+
continue;
|
|
19
|
+
}
|
|
20
|
+
if (arg === '--theme') {
|
|
21
|
+
parsed.theme = readFlagValue(argv, index, arg);
|
|
22
|
+
index += 1;
|
|
23
|
+
continue;
|
|
24
|
+
}
|
|
25
|
+
if (arg === '--themes') {
|
|
26
|
+
parsed.themes = readFlagValue(argv, index, arg);
|
|
27
|
+
index += 1;
|
|
28
|
+
continue;
|
|
29
|
+
}
|
|
30
|
+
if (arg === '--pm' || arg === '--package-manager') {
|
|
31
|
+
parsed.packageManager = readFlagValue(argv, index, arg);
|
|
32
|
+
index += 1;
|
|
33
|
+
continue;
|
|
34
|
+
}
|
|
35
|
+
if (arg.startsWith('--')) {
|
|
36
|
+
throw new Error(`Unknown option: ${arg}`);
|
|
37
|
+
}
|
|
38
|
+
if (parsed.project) {
|
|
39
|
+
throw new Error(`Unexpected extra argument: ${arg}`);
|
|
40
|
+
}
|
|
41
|
+
parsed.project = arg;
|
|
42
|
+
}
|
|
43
|
+
return parsed;
|
|
44
|
+
}
|
|
45
|
+
function normalizePackageName(project) {
|
|
46
|
+
const name = basename(project)
|
|
47
|
+
.trim()
|
|
48
|
+
.toLowerCase()
|
|
49
|
+
.replace(/[^a-z0-9._-]+/g, '-')
|
|
50
|
+
.replace(/^-+|-+$/g, '');
|
|
51
|
+
return name || 'super-admin-app';
|
|
52
|
+
}
|
|
53
|
+
function normalizeThemes(theme, themes) {
|
|
54
|
+
if (theme && themes) {
|
|
55
|
+
throw new Error('--theme and --themes are mutually exclusive.');
|
|
56
|
+
}
|
|
57
|
+
const rawThemes = (themes ? themes.split(',') : [theme ?? 'base']).map((item) => item.trim()).filter(Boolean);
|
|
58
|
+
const normalizedThemes = [];
|
|
59
|
+
for (const rawTheme of rawThemes) {
|
|
60
|
+
if (!isStarterThemeId(rawTheme)) {
|
|
61
|
+
throw new Error(`Unknown theme "${rawTheme}". Supported themes: ${starterThemeIds.join(', ')}`);
|
|
62
|
+
}
|
|
63
|
+
if (!normalizedThemes.includes(rawTheme)) {
|
|
64
|
+
normalizedThemes.push(rawTheme);
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
if (normalizedThemes.length === 0) {
|
|
68
|
+
throw new Error('At least one generated starter theme is required.');
|
|
69
|
+
}
|
|
70
|
+
return normalizedThemes;
|
|
71
|
+
}
|
|
72
|
+
function normalizePackageManager(packageManager) {
|
|
73
|
+
if (!packageManager) {
|
|
74
|
+
return 'pnpm';
|
|
75
|
+
}
|
|
76
|
+
if (!isStarterPackageManager(packageManager)) {
|
|
77
|
+
throw new Error(`Unsupported package manager "${packageManager}". Supported package managers: ${starterPackageManagers.join(', ')}`);
|
|
78
|
+
}
|
|
79
|
+
return packageManager;
|
|
80
|
+
}
|
|
81
|
+
export function parseCreateSuperAdminArgs(argv, options = {}) {
|
|
82
|
+
const cwd = options.cwd ?? process.cwd();
|
|
83
|
+
const flags = parseFlags(argv);
|
|
84
|
+
if (!flags.project) {
|
|
85
|
+
throw new Error('Usage: create-super-admin <project> [--theme base] [--themes base,cyberpunk] [--i18n] [--pm pnpm]');
|
|
86
|
+
}
|
|
87
|
+
const themes = normalizeThemes(flags.theme, flags.themes);
|
|
88
|
+
const projectName = basename(flags.project);
|
|
89
|
+
return {
|
|
90
|
+
projectName,
|
|
91
|
+
packageName: normalizePackageName(projectName),
|
|
92
|
+
packageManager: normalizePackageManager(flags.packageManager),
|
|
93
|
+
targetDirectory: resolve(cwd, flags.project),
|
|
94
|
+
themes: {
|
|
95
|
+
installed: themes,
|
|
96
|
+
default: themes[0] ?? 'base'
|
|
97
|
+
},
|
|
98
|
+
i18n: {
|
|
99
|
+
installed: flags.i18n ? ['zh-CN', 'en-US'] : ['zh-CN'],
|
|
100
|
+
default: 'zh-CN',
|
|
101
|
+
switcher: flags.i18n
|
|
102
|
+
}
|
|
103
|
+
};
|
|
104
|
+
}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
export type CreateSuperAdminIo = {
|
|
2
|
+
cwd?: string;
|
|
3
|
+
sourceRoot?: string;
|
|
4
|
+
stdout?: (message: string) => void;
|
|
5
|
+
stderr?: (message: string) => void;
|
|
6
|
+
};
|
|
7
|
+
export declare function runCreateSuperAdmin(argv: string[], io?: CreateSuperAdminIo): Promise<number>;
|
|
8
|
+
//# sourceMappingURL=run-create-super-admin.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"run-create-super-admin.d.ts","sourceRoot":"","sources":["../src/run-create-super-admin.ts"],"names":[],"mappings":"AAGA,MAAM,MAAM,kBAAkB,GAAG;IAC/B,GAAG,CAAC,EAAE,MAAM,CAAA;IACZ,UAAU,CAAC,EAAE,MAAM,CAAA;IACnB,MAAM,CAAC,EAAE,CAAC,OAAO,EAAE,MAAM,KAAK,IAAI,CAAA;IAClC,MAAM,CAAC,EAAE,CAAC,OAAO,EAAE,MAAM,KAAK,IAAI,CAAA;CACnC,CAAA;AAoBD,wBAAsB,mBAAmB,CAAC,IAAI,EAAE,MAAM,EAAE,EAAE,EAAE,GAAE,kBAAuB,GAAG,OAAO,CAAC,MAAM,CAAC,CAgBtG"}
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import { generateStarter } from './generate-starter.js';
|
|
2
|
+
import { parseCreateSuperAdminArgs } from './parse-args.js';
|
|
3
|
+
function writeLine(writer, message) {
|
|
4
|
+
if (writer) {
|
|
5
|
+
writer(message);
|
|
6
|
+
return;
|
|
7
|
+
}
|
|
8
|
+
console.log(message);
|
|
9
|
+
}
|
|
10
|
+
function writeError(writer, message) {
|
|
11
|
+
if (writer) {
|
|
12
|
+
writer(message);
|
|
13
|
+
return;
|
|
14
|
+
}
|
|
15
|
+
console.error(message);
|
|
16
|
+
}
|
|
17
|
+
export async function runCreateSuperAdmin(argv, io = {}) {
|
|
18
|
+
try {
|
|
19
|
+
const input = parseCreateSuperAdminArgs(argv, {
|
|
20
|
+
cwd: io.cwd
|
|
21
|
+
});
|
|
22
|
+
await generateStarter(input, {
|
|
23
|
+
sourceRoot: io.sourceRoot
|
|
24
|
+
});
|
|
25
|
+
writeLine(io.stdout, `Created Super Admin starter at ${input.targetDirectory}`);
|
|
26
|
+
writeLine(io.stdout, `Next: cd ${input.projectName} && ${input.packageManager} install && ${input.packageManager} run dev`);
|
|
27
|
+
return 0;
|
|
28
|
+
}
|
|
29
|
+
catch (error) {
|
|
30
|
+
writeError(io.stderr, error instanceof Error ? error.message : String(error));
|
|
31
|
+
return 1;
|
|
32
|
+
}
|
|
33
|
+
}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import type { StarterGenerationInput } from './parse-args.js';
|
|
2
|
+
import type { StarterLocaleId, StarterThemeId } from './theme-options.js';
|
|
3
|
+
export declare function createPackageJson(input: StarterGenerationInput): string;
|
|
4
|
+
export declare function createIndexHtml(projectName: string): string;
|
|
5
|
+
export declare function createViteConfig(): string;
|
|
6
|
+
export declare function createTsconfig(): string;
|
|
7
|
+
export declare function createReadme(projectName: string, packageManager: string): string;
|
|
8
|
+
export declare function createSuperAdminConfig(input: StarterGenerationInput): string;
|
|
9
|
+
export declare function createThemeRegistry(themes: StarterThemeId[], defaultTheme: StarterThemeId): string;
|
|
10
|
+
export declare function createEnvDts(): string;
|
|
11
|
+
export declare function createUsersApi(): string;
|
|
12
|
+
export declare function createAuthTypes(): string;
|
|
13
|
+
export declare function createAuthSession(): string;
|
|
14
|
+
export declare function createAuthSessionStore(): string;
|
|
15
|
+
export declare function createLoginPage(): string;
|
|
16
|
+
export declare function createI18nIndex(locales: StarterLocaleId[]): string;
|
|
17
|
+
export declare function createPreferencesStore(): string;
|
|
18
|
+
export declare function createGlobalPreferences(options: {
|
|
19
|
+
includeThemeSwitcher: boolean;
|
|
20
|
+
includeLocaleSwitcher: boolean;
|
|
21
|
+
}): string;
|
|
22
|
+
//# sourceMappingURL=templates.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"templates.d.ts","sourceRoot":"","sources":["../src/templates.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,iBAAiB,CAAA;AAE7D,OAAO,KAAK,EAAE,eAAe,EAAE,cAAc,EAAE,MAAM,oBAAoB,CAAA;AAQzE,wBAAgB,iBAAiB,CAAC,KAAK,EAAE,sBAAsB,GAAG,MAAM,CA2CvE;AAED,wBAAgB,eAAe,CAAC,WAAW,EAAE,MAAM,GAAG,MAAM,CAc3D;AAED,wBAAgB,gBAAgB,IAAI,MAAM,CAezC;AAED,wBAAgB,cAAc,IAAI,MAAM,CAoBvC;AAED,wBAAgB,YAAY,CAAC,WAAW,EAAE,MAAM,EAAE,cAAc,EAAE,MAAM,GAAG,MAAM,CAoBhF;AAED,wBAAgB,sBAAsB,CAAC,KAAK,EAAE,sBAAsB,GAAG,MAAM,CAc5E;AAED,wBAAgB,mBAAmB,CAAC,MAAM,EAAE,cAAc,EAAE,EAAE,YAAY,EAAE,cAAc,GAAG,MAAM,CAmBlG;AAED,wBAAgB,YAAY,IAAI,MAAM,CAyBrC;AAED,wBAAgB,cAAc,IAAI,MAAM,CA2DvC;AAED,wBAAgB,eAAe,IAAI,MAAM,CA6BxC;AAED,wBAAgB,iBAAiB,IAAI,MAAM,CAiB1C;AAED,wBAAgB,sBAAsB,IAAI,MAAM,CAsC/C;AAED,wBAAgB,eAAe,IAAI,MAAM,CA6GxC;AAED,wBAAgB,eAAe,CAAC,OAAO,EAAE,eAAe,EAAE,GAAG,MAAM,CAkFlE;AAED,wBAAgB,sBAAsB,IAAI,MAAM,CA+L/C;AAED,wBAAgB,uBAAuB,CAAC,OAAO,EAAE;IAAE,oBAAoB,EAAE,OAAO,CAAC;IAAC,qBAAqB,EAAE,OAAO,CAAA;CAAE,GAAG,MAAM,CAuS1H"}
|