@windrun-huaiin/dev-scripts 13.0.0 → 13.1.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/dist/cli.js
CHANGED
|
@@ -158,9 +158,10 @@ commander.program
|
|
|
158
158
|
commander.program
|
|
159
159
|
.command('create-diaomao-app <project-name>')
|
|
160
160
|
.description('create a new diaomao app from template')
|
|
161
|
-
.
|
|
161
|
+
.option('-s, --schema <name>', 'Database schema name (optional, defaults to project name)')
|
|
162
|
+
.action(async (projectName, options) => {
|
|
162
163
|
try {
|
|
163
|
-
await createDiaomaoApp.createDiaomaoApp(projectName);
|
|
164
|
+
await createDiaomaoApp.createDiaomaoApp(projectName, options);
|
|
164
165
|
}
|
|
165
166
|
catch (error) {
|
|
166
167
|
console.error('Error:', error);
|
package/dist/cli.mjs
CHANGED
|
@@ -156,9 +156,10 @@ program
|
|
|
156
156
|
program
|
|
157
157
|
.command('create-diaomao-app <project-name>')
|
|
158
158
|
.description('create a new diaomao app from template')
|
|
159
|
-
.
|
|
159
|
+
.option('-s, --schema <name>', 'Database schema name (optional, defaults to project name)')
|
|
160
|
+
.action(async (projectName, options) => {
|
|
160
161
|
try {
|
|
161
|
-
await createDiaomaoApp(projectName);
|
|
162
|
+
await createDiaomaoApp(projectName, options);
|
|
162
163
|
}
|
|
163
164
|
catch (error) {
|
|
164
165
|
console.error('Error:', error);
|
|
@@ -1,2 +1,6 @@
|
|
|
1
|
-
|
|
1
|
+
type CreateDiaomaoOptions = {
|
|
2
|
+
schema?: string;
|
|
3
|
+
};
|
|
4
|
+
export declare function createDiaomaoApp(targetDir: string, options?: CreateDiaomaoOptions): Promise<void>;
|
|
5
|
+
export {};
|
|
2
6
|
//# sourceMappingURL=create-diaomao-app.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"create-diaomao-app.d.ts","sourceRoot":"","sources":["../../src/commands/create-diaomao-app.ts"],"names":[],"mappings":"AAKA,wBAAsB,gBAAgB,CAAC,SAAS,EAAE,MAAM,
|
|
1
|
+
{"version":3,"file":"create-diaomao-app.d.ts","sourceRoot":"","sources":["../../src/commands/create-diaomao-app.ts"],"names":[],"mappings":"AAKA,KAAK,oBAAoB,GAAG;IAC1B,MAAM,CAAC,EAAE,MAAM,CAAC;CACjB,CAAC;AAEF,wBAAsB,gBAAgB,CAAC,SAAS,EAAE,MAAM,EAAE,OAAO,GAAE,oBAAyB,iBAgL3F"}
|
|
@@ -5,11 +5,8 @@ var path = require('path');
|
|
|
5
5
|
var child_process = require('child_process');
|
|
6
6
|
var os = require('os');
|
|
7
7
|
|
|
8
|
-
async function createDiaomaoApp(targetDir) {
|
|
9
|
-
|
|
10
|
-
console.error('Usage: create-diaomao-app <project-name>');
|
|
11
|
-
process.exit(1);
|
|
12
|
-
}
|
|
8
|
+
async function createDiaomaoApp(targetDir, options = {}) {
|
|
9
|
+
const schemaName = options.schema || path.basename(targetDir);
|
|
13
10
|
const cwd = process.cwd();
|
|
14
11
|
const cwdPackageJson = path.join(cwd, 'package.json');
|
|
15
12
|
const cwdWorkspaceYaml = path.join(cwd, 'pnpm-workspace.yaml');
|
|
@@ -58,7 +55,31 @@ async function createDiaomaoApp(targetDir) {
|
|
|
58
55
|
const envPath = path.join(destDir, '.env.local');
|
|
59
56
|
if (await fsExtra.pathExists(envTxtPath)) {
|
|
60
57
|
await fsExtra.rename(envTxtPath, envPath);
|
|
61
|
-
console.log('Renamed .env.local.txt to .env.local');
|
|
58
|
+
console.log('🍻🍻Renamed .env.local.txt to .env.local');
|
|
59
|
+
}
|
|
60
|
+
// Try to 'generate prisma/schema.prisma'
|
|
61
|
+
const prismaDir = path.join(destDir, 'prisma');
|
|
62
|
+
const schemaPath = path.join(prismaDir, 'schema.prisma');
|
|
63
|
+
await fsExtra.ensureDir(prismaDir);
|
|
64
|
+
// Check prisma dir, if exists then not genarate
|
|
65
|
+
if (!(await fsExtra.pathExists(schemaPath))) {
|
|
66
|
+
const schemaContent = [
|
|
67
|
+
'generator client {',
|
|
68
|
+
' provider = "prisma-client-js"',
|
|
69
|
+
'}',
|
|
70
|
+
'',
|
|
71
|
+
'datasource db {',
|
|
72
|
+
' provider = "postgresql"',
|
|
73
|
+
' url = env("DATABASE_URL")',
|
|
74
|
+
` schemas = ["${schemaName}", "public"]`,
|
|
75
|
+
'}',
|
|
76
|
+
'',
|
|
77
|
+
].join('\n');
|
|
78
|
+
await fsExtra.writeFile(schemaPath, schemaContent, 'utf8');
|
|
79
|
+
console.log(`🍻🍻Generated initial prisma/schema.prisma with schema: ${schemaName}`);
|
|
80
|
+
}
|
|
81
|
+
else {
|
|
82
|
+
console.log('prisma/schema.prisma already exists in template, skipping generation');
|
|
62
83
|
}
|
|
63
84
|
// handle .changeset folder if exists
|
|
64
85
|
const changesetDir = path.join(destDir, '.changeset');
|
|
@@ -66,7 +87,7 @@ async function createDiaomaoApp(targetDir) {
|
|
|
66
87
|
const templateFile = path.join(changesetDir, 'd8-template.mdx');
|
|
67
88
|
const changesetContent = `---\n"${path.basename(targetDir)}": major\n---\n\nfeat(init): app created by @windrun-huaiin/diaomao`;
|
|
68
89
|
await fsExtra.writeFile(templateFile, changesetContent, 'utf8');
|
|
69
|
-
console.log('Created changeset template file: d8-template.mdx');
|
|
90
|
+
console.log('🍻🍻Created changeset template file: d8-template.mdx');
|
|
70
91
|
}
|
|
71
92
|
// read and modify package.json
|
|
72
93
|
const pkgPath = path.join(destDir, 'package.json');
|
|
@@ -74,32 +95,20 @@ async function createDiaomaoApp(targetDir) {
|
|
|
74
95
|
pkg.name = path.basename(targetDir);
|
|
75
96
|
pkg.version = "1.0.0";
|
|
76
97
|
pkg.private = true;
|
|
77
|
-
// add pnpm configuration for standalone project
|
|
78
|
-
pkg.pnpm = {
|
|
79
|
-
"onlyBuiltDependencies": [
|
|
80
|
-
"@clerk/shared",
|
|
81
|
-
"@parcel/watcher",
|
|
82
|
-
"@tailwindcss/oxide",
|
|
83
|
-
"core-js",
|
|
84
|
-
"esbuild",
|
|
85
|
-
"sharp",
|
|
86
|
-
"unrs-resolver"
|
|
87
|
-
],
|
|
88
|
-
"overrides": {
|
|
89
|
-
"@types/react": "19.1.2",
|
|
90
|
-
"@types/react-dom": "19.1.3"
|
|
91
|
-
},
|
|
92
|
-
"patchedDependencies": {
|
|
93
|
-
"fumadocs-ui@15.3.3": "patches/fumadocs-ui@15.3.3.patch"
|
|
94
|
-
}
|
|
95
|
-
};
|
|
96
98
|
// remove standalone-specific scripts for non-monorepo scenario
|
|
97
99
|
if (pkg.scripts) {
|
|
98
100
|
delete pkg.scripts['djvp'];
|
|
101
|
+
// Repalce 'core-sync-sql' command's '--schema diaomao'
|
|
102
|
+
const scriptKey = 'core-sync-sql';
|
|
103
|
+
if (pkg.scripts[scriptKey]) {
|
|
104
|
+
pkg.scripts[scriptKey] = pkg.scripts[scriptKey].replace('--schema diaomao', `--schema ${schemaName}`);
|
|
105
|
+
console.log(`Updated ${scriptKey} script: --schema ${schemaName}`);
|
|
106
|
+
}
|
|
99
107
|
}
|
|
100
108
|
// remove publish related config
|
|
101
109
|
delete pkg.publishConfig;
|
|
102
|
-
|
|
110
|
+
if (pkg.files)
|
|
111
|
+
delete pkg.files;
|
|
103
112
|
await fsExtra.writeJson(pkgPath, pkg, { spaces: 2 });
|
|
104
113
|
console.log('Installing dependencies...');
|
|
105
114
|
// auto install dependencies
|
|
@@ -115,6 +124,7 @@ async function createDiaomaoApp(targetDir) {
|
|
|
115
124
|
console.error('Failed to install dependencies. Please run npm install or pnpm install manually.');
|
|
116
125
|
}
|
|
117
126
|
}
|
|
127
|
+
console.log('🍻🍻Installed dependencies!');
|
|
118
128
|
console.log('Initializing Git repository...');
|
|
119
129
|
// initialize git
|
|
120
130
|
try {
|
|
@@ -125,13 +135,17 @@ async function createDiaomaoApp(targetDir) {
|
|
|
125
135
|
catch (error) {
|
|
126
136
|
console.warn('Failed to initialize Git repository. Please initialize manually.');
|
|
127
137
|
}
|
|
128
|
-
console.log(`\n
|
|
138
|
+
console.log(`\n🍻🍻 Project created: ${destDir}`);
|
|
129
139
|
console.log(`\nNext steps:`);
|
|
130
140
|
console.log(` cd ${targetDir}`);
|
|
141
|
+
console.log(` 🍎🍎NOTE: if you want to update @windrun-huaiin packages, please run pnpm windrun`);
|
|
142
|
+
console.log(` ⚠️⚠️NOTE: please check .env.local file and set your own env!`);
|
|
143
|
+
console.log(` ⚠️⚠️NOTE: USE 'pnpm core-list-route' for viewing latested api routes`);
|
|
144
|
+
console.log(` ⚠️⚠️NOTE: USE 'pnpm core-sync-route' for syncing latested api routes`);
|
|
145
|
+
console.log(` ⚠️⚠️NOTE: USE 'pnpm core-sync-schema' for appendding basic prisma models`);
|
|
146
|
+
console.log(` ⚠️⚠️NOTE: USE 'pnpm core-sync-sql' for initing sql`);
|
|
131
147
|
console.log(` pnpm build`);
|
|
132
148
|
console.log(` pnpm dev`);
|
|
133
|
-
console.log(` NOTE: if you want to update @windrun-huaiin packages, please run pnpm windrun`);
|
|
134
|
-
console.log(` NOTE: please check .env.local file and set your own env!`);
|
|
135
149
|
}
|
|
136
150
|
catch (error) {
|
|
137
151
|
console.error('Failed to create project:', error);
|
|
@@ -3,11 +3,8 @@ import path from 'path';
|
|
|
3
3
|
import { execSync } from 'child_process';
|
|
4
4
|
import os from 'os';
|
|
5
5
|
|
|
6
|
-
async function createDiaomaoApp(targetDir) {
|
|
7
|
-
|
|
8
|
-
console.error('Usage: create-diaomao-app <project-name>');
|
|
9
|
-
process.exit(1);
|
|
10
|
-
}
|
|
6
|
+
async function createDiaomaoApp(targetDir, options = {}) {
|
|
7
|
+
const schemaName = options.schema || path.basename(targetDir);
|
|
11
8
|
const cwd = process.cwd();
|
|
12
9
|
const cwdPackageJson = path.join(cwd, 'package.json');
|
|
13
10
|
const cwdWorkspaceYaml = path.join(cwd, 'pnpm-workspace.yaml');
|
|
@@ -56,7 +53,31 @@ async function createDiaomaoApp(targetDir) {
|
|
|
56
53
|
const envPath = path.join(destDir, '.env.local');
|
|
57
54
|
if (await pathExists(envTxtPath)) {
|
|
58
55
|
await rename(envTxtPath, envPath);
|
|
59
|
-
console.log('Renamed .env.local.txt to .env.local');
|
|
56
|
+
console.log('🍻🍻Renamed .env.local.txt to .env.local');
|
|
57
|
+
}
|
|
58
|
+
// Try to 'generate prisma/schema.prisma'
|
|
59
|
+
const prismaDir = path.join(destDir, 'prisma');
|
|
60
|
+
const schemaPath = path.join(prismaDir, 'schema.prisma');
|
|
61
|
+
await ensureDir(prismaDir);
|
|
62
|
+
// Check prisma dir, if exists then not genarate
|
|
63
|
+
if (!(await pathExists(schemaPath))) {
|
|
64
|
+
const schemaContent = [
|
|
65
|
+
'generator client {',
|
|
66
|
+
' provider = "prisma-client-js"',
|
|
67
|
+
'}',
|
|
68
|
+
'',
|
|
69
|
+
'datasource db {',
|
|
70
|
+
' provider = "postgresql"',
|
|
71
|
+
' url = env("DATABASE_URL")',
|
|
72
|
+
` schemas = ["${schemaName}", "public"]`,
|
|
73
|
+
'}',
|
|
74
|
+
'',
|
|
75
|
+
].join('\n');
|
|
76
|
+
await writeFile(schemaPath, schemaContent, 'utf8');
|
|
77
|
+
console.log(`🍻🍻Generated initial prisma/schema.prisma with schema: ${schemaName}`);
|
|
78
|
+
}
|
|
79
|
+
else {
|
|
80
|
+
console.log('prisma/schema.prisma already exists in template, skipping generation');
|
|
60
81
|
}
|
|
61
82
|
// handle .changeset folder if exists
|
|
62
83
|
const changesetDir = path.join(destDir, '.changeset');
|
|
@@ -64,7 +85,7 @@ async function createDiaomaoApp(targetDir) {
|
|
|
64
85
|
const templateFile = path.join(changesetDir, 'd8-template.mdx');
|
|
65
86
|
const changesetContent = `---\n"${path.basename(targetDir)}": major\n---\n\nfeat(init): app created by @windrun-huaiin/diaomao`;
|
|
66
87
|
await writeFile(templateFile, changesetContent, 'utf8');
|
|
67
|
-
console.log('Created changeset template file: d8-template.mdx');
|
|
88
|
+
console.log('🍻🍻Created changeset template file: d8-template.mdx');
|
|
68
89
|
}
|
|
69
90
|
// read and modify package.json
|
|
70
91
|
const pkgPath = path.join(destDir, 'package.json');
|
|
@@ -72,32 +93,20 @@ async function createDiaomaoApp(targetDir) {
|
|
|
72
93
|
pkg.name = path.basename(targetDir);
|
|
73
94
|
pkg.version = "1.0.0";
|
|
74
95
|
pkg.private = true;
|
|
75
|
-
// add pnpm configuration for standalone project
|
|
76
|
-
pkg.pnpm = {
|
|
77
|
-
"onlyBuiltDependencies": [
|
|
78
|
-
"@clerk/shared",
|
|
79
|
-
"@parcel/watcher",
|
|
80
|
-
"@tailwindcss/oxide",
|
|
81
|
-
"core-js",
|
|
82
|
-
"esbuild",
|
|
83
|
-
"sharp",
|
|
84
|
-
"unrs-resolver"
|
|
85
|
-
],
|
|
86
|
-
"overrides": {
|
|
87
|
-
"@types/react": "19.1.2",
|
|
88
|
-
"@types/react-dom": "19.1.3"
|
|
89
|
-
},
|
|
90
|
-
"patchedDependencies": {
|
|
91
|
-
"fumadocs-ui@15.3.3": "patches/fumadocs-ui@15.3.3.patch"
|
|
92
|
-
}
|
|
93
|
-
};
|
|
94
96
|
// remove standalone-specific scripts for non-monorepo scenario
|
|
95
97
|
if (pkg.scripts) {
|
|
96
98
|
delete pkg.scripts['djvp'];
|
|
99
|
+
// Repalce 'core-sync-sql' command's '--schema diaomao'
|
|
100
|
+
const scriptKey = 'core-sync-sql';
|
|
101
|
+
if (pkg.scripts[scriptKey]) {
|
|
102
|
+
pkg.scripts[scriptKey] = pkg.scripts[scriptKey].replace('--schema diaomao', `--schema ${schemaName}`);
|
|
103
|
+
console.log(`Updated ${scriptKey} script: --schema ${schemaName}`);
|
|
104
|
+
}
|
|
97
105
|
}
|
|
98
106
|
// remove publish related config
|
|
99
107
|
delete pkg.publishConfig;
|
|
100
|
-
|
|
108
|
+
if (pkg.files)
|
|
109
|
+
delete pkg.files;
|
|
101
110
|
await writeJson(pkgPath, pkg, { spaces: 2 });
|
|
102
111
|
console.log('Installing dependencies...');
|
|
103
112
|
// auto install dependencies
|
|
@@ -113,6 +122,7 @@ async function createDiaomaoApp(targetDir) {
|
|
|
113
122
|
console.error('Failed to install dependencies. Please run npm install or pnpm install manually.');
|
|
114
123
|
}
|
|
115
124
|
}
|
|
125
|
+
console.log('🍻🍻Installed dependencies!');
|
|
116
126
|
console.log('Initializing Git repository...');
|
|
117
127
|
// initialize git
|
|
118
128
|
try {
|
|
@@ -123,13 +133,17 @@ async function createDiaomaoApp(targetDir) {
|
|
|
123
133
|
catch (error) {
|
|
124
134
|
console.warn('Failed to initialize Git repository. Please initialize manually.');
|
|
125
135
|
}
|
|
126
|
-
console.log(`\n
|
|
136
|
+
console.log(`\n🍻🍻 Project created: ${destDir}`);
|
|
127
137
|
console.log(`\nNext steps:`);
|
|
128
138
|
console.log(` cd ${targetDir}`);
|
|
139
|
+
console.log(` 🍎🍎NOTE: if you want to update @windrun-huaiin packages, please run pnpm windrun`);
|
|
140
|
+
console.log(` ⚠️⚠️NOTE: please check .env.local file and set your own env!`);
|
|
141
|
+
console.log(` ⚠️⚠️NOTE: USE 'pnpm core-list-route' for viewing latested api routes`);
|
|
142
|
+
console.log(` ⚠️⚠️NOTE: USE 'pnpm core-sync-route' for syncing latested api routes`);
|
|
143
|
+
console.log(` ⚠️⚠️NOTE: USE 'pnpm core-sync-schema' for appendding basic prisma models`);
|
|
144
|
+
console.log(` ⚠️⚠️NOTE: USE 'pnpm core-sync-sql' for initing sql`);
|
|
129
145
|
console.log(` pnpm build`);
|
|
130
146
|
console.log(` pnpm dev`);
|
|
131
|
-
console.log(` NOTE: if you want to update @windrun-huaiin packages, please run pnpm windrun`);
|
|
132
|
-
console.log(` NOTE: please check .env.local file and set your own env!`);
|
|
133
147
|
}
|
|
134
148
|
catch (error) {
|
|
135
149
|
console.error('Failed to create project:', error);
|