kaddidlehopper 0.7.0 → 0.7.2
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 +3 -12
- package/dist/types/types.d.ts +0 -1
- package/package.json +1 -1
- package/src/cli.ts +2 -19
- package/src/types.ts +0 -1
package/dist/cli.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { resolve, basename } from 'node:path';
|
|
2
|
-
import { existsSync
|
|
2
|
+
import { existsSync } from 'node:fs';
|
|
3
3
|
import { cp, rm, mkdtemp, readFile, writeFile } from 'node:fs/promises';
|
|
4
4
|
import { tmpdir } from 'node:os';
|
|
5
5
|
import { join } from 'node:path';
|
|
@@ -51,8 +51,7 @@ export function cli() {
|
|
|
51
51
|
.option('--add-ons [id]', 'starter ID to use from the template repo')
|
|
52
52
|
.option('--list-addons-json', 'list all available starters as JSON', false)
|
|
53
53
|
.option('--no-git', 'do not create a git repository')
|
|
54
|
-
.option('--target-dir <path>', 'the target directory for the application root')
|
|
55
|
-
.option('-f, --force', 'force project creation even if the target directory is not empty');
|
|
54
|
+
.option('--target-dir <path>', 'the target directory for the application root');
|
|
56
55
|
program.action(async (projectName, options) => {
|
|
57
56
|
// Handle --list-addons-json
|
|
58
57
|
if (options.listAddonsJson) {
|
|
@@ -77,14 +76,6 @@ export function cli() {
|
|
|
77
76
|
console.error(chalk.red(error));
|
|
78
77
|
process.exit(1);
|
|
79
78
|
}
|
|
80
|
-
// Check if target directory exists and is non-empty
|
|
81
|
-
if (existsSync(targetDir)) {
|
|
82
|
-
const contents = readdirSync(targetDir);
|
|
83
|
-
if (contents.length > 0 && !options.force) {
|
|
84
|
-
console.error(chalk.red(`Target directory "${targetDir}" is not empty. Use --force to overwrite.`));
|
|
85
|
-
process.exit(1);
|
|
86
|
-
}
|
|
87
|
-
}
|
|
88
79
|
// Delete index.html if it exists in the target directory
|
|
89
80
|
const indexHtmlPath = join(targetDir, 'index.html');
|
|
90
81
|
if (existsSync(indexHtmlPath)) {
|
|
@@ -100,7 +91,7 @@ export function cli() {
|
|
|
100
91
|
try {
|
|
101
92
|
console.log(chalk.gray('⟳ Fetching template...'));
|
|
102
93
|
const sparsePaths = [`starters/${starterId}`, ...(frameworkId ? [`frameworks/${frameworkId}`] : [])];
|
|
103
|
-
execSync(`git clone --depth=1 --
|
|
94
|
+
execSync(`git clone --depth=1 --sparse ${GITHUB_REPO} ${tmpDir}`, { stdio: 'pipe' });
|
|
104
95
|
execSync(`git -C ${tmpDir} sparse-checkout set ${sparsePaths.join(' ')}`, { stdio: 'pipe' });
|
|
105
96
|
const starterPath = join(tmpDir, 'starters', starterId);
|
|
106
97
|
if (!existsSync(starterPath)) {
|
package/dist/types/types.d.ts
CHANGED
package/package.json
CHANGED
package/src/cli.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { resolve, basename } from 'node:path'
|
|
2
|
-
import { existsSync
|
|
2
|
+
import { existsSync } from 'node:fs'
|
|
3
3
|
import { cp, rm, mkdtemp, readFile, writeFile } from 'node:fs/promises'
|
|
4
4
|
import { tmpdir } from 'node:os'
|
|
5
5
|
import { join } from 'node:path'
|
|
@@ -72,10 +72,6 @@ export function cli() {
|
|
|
72
72
|
'--target-dir <path>',
|
|
73
73
|
'the target directory for the application root',
|
|
74
74
|
)
|
|
75
|
-
.option(
|
|
76
|
-
'-f, --force',
|
|
77
|
-
'force project creation even if the target directory is not empty',
|
|
78
|
-
)
|
|
79
75
|
|
|
80
76
|
program.action(async (projectName: string | undefined, options: CliOptions) => {
|
|
81
77
|
// Handle --list-addons-json
|
|
@@ -106,19 +102,6 @@ export function cli() {
|
|
|
106
102
|
process.exit(1)
|
|
107
103
|
}
|
|
108
104
|
|
|
109
|
-
// Check if target directory exists and is non-empty
|
|
110
|
-
if (existsSync(targetDir)) {
|
|
111
|
-
const contents = readdirSync(targetDir)
|
|
112
|
-
if (contents.length > 0 && !options.force) {
|
|
113
|
-
console.error(
|
|
114
|
-
chalk.red(
|
|
115
|
-
`Target directory "${targetDir}" is not empty. Use --force to overwrite.`,
|
|
116
|
-
),
|
|
117
|
-
)
|
|
118
|
-
process.exit(1)
|
|
119
|
-
}
|
|
120
|
-
}
|
|
121
|
-
|
|
122
105
|
// Delete index.html if it exists in the target directory
|
|
123
106
|
const indexHtmlPath = join(targetDir, 'index.html')
|
|
124
107
|
if (existsSync(indexHtmlPath)) {
|
|
@@ -144,7 +127,7 @@ export function cli() {
|
|
|
144
127
|
console.log(chalk.gray('⟳ Fetching template...'))
|
|
145
128
|
const sparsePaths = [`starters/${starterId}`, ...(frameworkId ? [`frameworks/${frameworkId}`] : [])]
|
|
146
129
|
execSync(
|
|
147
|
-
`git clone --depth=1 --
|
|
130
|
+
`git clone --depth=1 --sparse ${GITHUB_REPO} ${tmpDir}`,
|
|
148
131
|
{ stdio: 'pipe' },
|
|
149
132
|
)
|
|
150
133
|
execSync(
|