create-ej-app 31.0.0 → 32.0.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 +1 -1
- package/cli.js +23 -2
- package/cli.ts +23 -2
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -59,7 +59,7 @@ You will be prompted for:
|
|
|
59
59
|
- Project name
|
|
60
60
|
- Description
|
|
61
61
|
- Template (`nextjs`, `saas-starter`, or `api`)
|
|
62
|
-
- Whether to initialize git. If yes, the CLI
|
|
62
|
+
- Whether to initialize git. If yes, the CLI creates the `main` branch (or your configured default, unless it is `master`) and makes the initial commit, as long as `.env` is ignored.
|
|
63
63
|
- Whether to update packages to their latest versions. With Bun it runs `bun update -i`, so you pick which packages to update.
|
|
64
64
|
|
|
65
65
|
Example:
|
package/cli.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
import { execSync } from 'child_process';
|
|
2
|
+
import { execFileSync, execSync } from 'child_process';
|
|
3
3
|
import { program } from 'commander';
|
|
4
4
|
import { randomBytes } from 'crypto';
|
|
5
5
|
import enquirer from 'enquirer';
|
|
@@ -66,6 +66,24 @@ const getUpdateCommands = (packageManager) => {
|
|
|
66
66
|
return null;
|
|
67
67
|
}
|
|
68
68
|
};
|
|
69
|
+
/**
|
|
70
|
+
* The branch name for a new repository: the one set in git's
|
|
71
|
+
* init.defaultBranch, unless that is unset or `master`, which become `main`.
|
|
72
|
+
*/
|
|
73
|
+
const defaultBranch = () => {
|
|
74
|
+
let configured = '';
|
|
75
|
+
try {
|
|
76
|
+
configured = execSync('git config --get init.defaultBranch', {
|
|
77
|
+
stdio: 'pipe'
|
|
78
|
+
})
|
|
79
|
+
.toString()
|
|
80
|
+
.trim();
|
|
81
|
+
}
|
|
82
|
+
catch {
|
|
83
|
+
// Not set
|
|
84
|
+
}
|
|
85
|
+
return configured && configured !== 'master' ? configured : 'main';
|
|
86
|
+
};
|
|
69
87
|
/**
|
|
70
88
|
* Commits the new project once. Skips the commit when .env is not ignored, so
|
|
71
89
|
* the generated secret never lands in history, and explains a missing git
|
|
@@ -266,7 +284,10 @@ program.action(async (options) => {
|
|
|
266
284
|
}
|
|
267
285
|
if (git === 'yes') {
|
|
268
286
|
try {
|
|
269
|
-
|
|
287
|
+
execFileSync('git', ['init', '-b', defaultBranch()], {
|
|
288
|
+
cwd: projectDir,
|
|
289
|
+
stdio: 'inherit'
|
|
290
|
+
});
|
|
270
291
|
commitEverything(projectDir);
|
|
271
292
|
}
|
|
272
293
|
catch (err) {
|
package/cli.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
|
|
3
|
-
import { execSync } from 'child_process'
|
|
3
|
+
import { execFileSync, execSync } from 'child_process'
|
|
4
4
|
import { program } from 'commander'
|
|
5
5
|
import { randomBytes } from 'crypto'
|
|
6
6
|
import enquirer from 'enquirer'
|
|
@@ -81,6 +81,24 @@ const getUpdateCommands = (packageManager: string) => {
|
|
|
81
81
|
}
|
|
82
82
|
}
|
|
83
83
|
|
|
84
|
+
/**
|
|
85
|
+
* The branch name for a new repository: the one set in git's
|
|
86
|
+
* init.defaultBranch, unless that is unset or `master`, which become `main`.
|
|
87
|
+
*/
|
|
88
|
+
const defaultBranch = () => {
|
|
89
|
+
let configured = ''
|
|
90
|
+
try {
|
|
91
|
+
configured = execSync('git config --get init.defaultBranch', {
|
|
92
|
+
stdio: 'pipe'
|
|
93
|
+
})
|
|
94
|
+
.toString()
|
|
95
|
+
.trim()
|
|
96
|
+
} catch {
|
|
97
|
+
// Not set
|
|
98
|
+
}
|
|
99
|
+
return configured && configured !== 'master' ? configured : 'main'
|
|
100
|
+
}
|
|
101
|
+
|
|
84
102
|
/**
|
|
85
103
|
* Commits the new project once. Skips the commit when .env is not ignored, so
|
|
86
104
|
* the generated secret never lands in history, and explains a missing git
|
|
@@ -348,7 +366,10 @@ program.action(async (options: Options) => {
|
|
|
348
366
|
|
|
349
367
|
if (git === 'yes') {
|
|
350
368
|
try {
|
|
351
|
-
|
|
369
|
+
execFileSync('git', ['init', '-b', defaultBranch()], {
|
|
370
|
+
cwd: projectDir,
|
|
371
|
+
stdio: 'inherit'
|
|
372
|
+
})
|
|
352
373
|
commitEverything(projectDir)
|
|
353
374
|
} catch (err) {
|
|
354
375
|
console.error('Error initializing git repository:', err)
|