tackl 1.0.0 → 1.0.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/bin/tackl.js +43 -24
- package/package.json +1 -1
package/bin/tackl.js
CHANGED
|
@@ -11,7 +11,7 @@ import { fileURLToPath } from 'url';
|
|
|
11
11
|
const __filename = fileURLToPath(import.meta.url);
|
|
12
12
|
const __dirname = path.dirname(__filename);
|
|
13
13
|
|
|
14
|
-
const OWNER = '
|
|
14
|
+
const OWNER = '12-studio';
|
|
15
15
|
const REPO = 'tackl';
|
|
16
16
|
const DEFAULT_REF = 'main';
|
|
17
17
|
|
|
@@ -20,6 +20,30 @@ const log = {
|
|
|
20
20
|
ok: m => console.log(pc.green('✔'), m),
|
|
21
21
|
warn: m => console.log(pc.yellow('▲'), m),
|
|
22
22
|
error: m => console.log(pc.red('✖'), m),
|
|
23
|
+
step: m => console.log(pc.blue('→'), m),
|
|
24
|
+
success: m => console.log(pc.green('🎉'), m),
|
|
25
|
+
};
|
|
26
|
+
|
|
27
|
+
const showBanner = () => {
|
|
28
|
+
console.log(
|
|
29
|
+
pc.bold(
|
|
30
|
+
pc.cyan(`
|
|
31
|
+
╔══════════════════════════════════════════════════════════════╗
|
|
32
|
+
║ ║
|
|
33
|
+
║ ████████╗ █████╗ ██████╗██╗ ██╗██╗ ║
|
|
34
|
+
║ ╚══██╔══╝██╔══██╗██╔════╝██║ ██╔╝██║ ║
|
|
35
|
+
║ ██║ ███████║██║ █████╔╝ ██║ ║
|
|
36
|
+
║ ██║ ██╔══██║██║ ██╔═██╗ ██║ ║
|
|
37
|
+
║ ██║ ██║ ██║╚██████╗██║ ██╗███████╗ ║
|
|
38
|
+
║ ╚═╝ ╚═╝ ╚═╝ ╚═════╝╚═╝ ╚═╝╚══════╝ ║
|
|
39
|
+
║ ║
|
|
40
|
+
║ The Ultimate Next.js Starter Kit ║
|
|
41
|
+
║ with Waffl Grid System ║
|
|
42
|
+
║ ║
|
|
43
|
+
╚══════════════════════════════════════════════════════════════╝
|
|
44
|
+
`)
|
|
45
|
+
)
|
|
46
|
+
);
|
|
23
47
|
};
|
|
24
48
|
|
|
25
49
|
async function main() {
|
|
@@ -34,14 +58,12 @@ ${pc.bold('Usage:')}
|
|
|
34
58
|
tackl [project-name] [options]
|
|
35
59
|
|
|
36
60
|
${pc.bold('Options:')}
|
|
37
|
-
--ref <branch> Template ref (branch or tag) (default: main)
|
|
38
61
|
--no-install Skip dependency installation
|
|
39
62
|
--no-git Skip git initialization
|
|
40
63
|
-h, --help Show this help message
|
|
41
64
|
|
|
42
65
|
${pc.bold('Examples:')}
|
|
43
66
|
tackl my-app
|
|
44
|
-
tackl my-app --ref develop
|
|
45
67
|
tackl my-app --no-install --no-git
|
|
46
68
|
|
|
47
69
|
${pc.bold('Repository:')} https://github.com/12-studio/tackl
|
|
@@ -50,16 +72,10 @@ ${pc.bold('Repository:')} https://github.com/12-studio/tackl
|
|
|
50
72
|
}
|
|
51
73
|
|
|
52
74
|
const argName = args.find(a => !a.startsWith('-'));
|
|
53
|
-
const getFlagVal = (key, fallback) => {
|
|
54
|
-
const idx = args.findIndex(a => a === key);
|
|
55
|
-
return idx >= 0 && args[idx + 1] && !args[idx + 1].startsWith('-')
|
|
56
|
-
? args[idx + 1]
|
|
57
|
-
: fallback;
|
|
58
|
-
};
|
|
59
75
|
|
|
60
76
|
const initial = {
|
|
61
77
|
name: argName,
|
|
62
|
-
ref:
|
|
78
|
+
ref: DEFAULT_REF, // Always use main branch
|
|
63
79
|
install: !args.includes('--no-install'),
|
|
64
80
|
git: !args.includes('--no-git'),
|
|
65
81
|
};
|
|
@@ -76,12 +92,6 @@ ${pc.bold('Repository:')} https://github.com/12-studio/tackl
|
|
|
76
92
|
? true
|
|
77
93
|
: 'Use lowercase letters, numbers, - . _',
|
|
78
94
|
},
|
|
79
|
-
{
|
|
80
|
-
type: 'text',
|
|
81
|
-
name: 'ref',
|
|
82
|
-
message: 'Template ref (branch or tag)',
|
|
83
|
-
initial: initial.ref,
|
|
84
|
-
},
|
|
85
95
|
{
|
|
86
96
|
type: 'toggle',
|
|
87
97
|
name: 'install',
|
|
@@ -131,14 +141,18 @@ ${pc.bold('Repository:')} https://github.com/12-studio/tackl
|
|
|
131
141
|
}
|
|
132
142
|
fs.mkdirSync(targetDir, { recursive: true });
|
|
133
143
|
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
144
|
+
showBanner();
|
|
145
|
+
console.log(pc.bold(pc.white('🚀 Starting project creation...\n')));
|
|
146
|
+
|
|
147
|
+
log.step(`Creating project: ${pc.bold(pc.cyan(projectName))}`);
|
|
148
|
+
log.step(`Template: ${pc.bold(pc.yellow(`${OWNER}/${REPO}@${ref}`))}`);
|
|
149
|
+
console.log();
|
|
137
150
|
|
|
138
151
|
const tarUrl = `https://codeload.github.com/${OWNER}/${REPO}/tar.gz/${encodeURIComponent(ref)}`;
|
|
139
152
|
const tmpTar = path.join(os.tmpdir(), `tackl-${Date.now()}.tgz`);
|
|
140
153
|
|
|
141
154
|
try {
|
|
155
|
+
log.step('📥 Downloading template...');
|
|
142
156
|
const res = await fetch(tarUrl);
|
|
143
157
|
if (!res.ok)
|
|
144
158
|
throw new Error(`Download failed: ${res.status} ${res.statusText}`);
|
|
@@ -148,17 +162,20 @@ ${pc.bold('Repository:')} https://github.com/12-studio/tackl
|
|
|
148
162
|
res.body.on('error', reject);
|
|
149
163
|
out.on('finish', resolve);
|
|
150
164
|
});
|
|
151
|
-
log.ok('
|
|
165
|
+
log.ok('Template downloaded successfully!');
|
|
152
166
|
} catch (e) {
|
|
153
|
-
log.error(e.message);
|
|
167
|
+
log.error(`Download failed: ${e.message}`);
|
|
168
|
+
log.error('Please check your internet connection and try again.');
|
|
154
169
|
process.exit(1);
|
|
155
170
|
}
|
|
156
171
|
|
|
157
172
|
try {
|
|
173
|
+
log.step('📦 Extracting files...');
|
|
158
174
|
await tar.x({ file: tmpTar, cwd: targetDir, strip: 1 });
|
|
159
|
-
log.ok('
|
|
175
|
+
log.ok('Files extracted successfully!');
|
|
160
176
|
} catch (e) {
|
|
161
177
|
log.error(`Extraction failed: ${e.message}`);
|
|
178
|
+
log.error('Please try again or check if the template is valid.');
|
|
162
179
|
process.exit(1);
|
|
163
180
|
} finally {
|
|
164
181
|
try {
|
|
@@ -174,13 +191,14 @@ ${pc.bold('Repository:')} https://github.com/12-studio/tackl
|
|
|
174
191
|
} catch {}
|
|
175
192
|
|
|
176
193
|
// Patch package name
|
|
194
|
+
log.step('📝 Updating project configuration...');
|
|
177
195
|
const pkg = path.join(targetDir, 'package.json');
|
|
178
196
|
if (fs.existsSync(pkg)) {
|
|
179
197
|
try {
|
|
180
198
|
const json = JSON.parse(fs.readFileSync(pkg, 'utf8'));
|
|
181
199
|
json.name = projectName.toLowerCase();
|
|
182
200
|
fs.writeFileSync(pkg, JSON.stringify(json, null, 2));
|
|
183
|
-
log.ok('
|
|
201
|
+
log.ok('Project configuration updated!');
|
|
184
202
|
} catch (e) {
|
|
185
203
|
log.warn(`Could not update package.json: ${e.message}`);
|
|
186
204
|
}
|
|
@@ -188,13 +206,14 @@ ${pc.bold('Repository:')} https://github.com/12-studio/tackl
|
|
|
188
206
|
|
|
189
207
|
if (doGit) {
|
|
190
208
|
try {
|
|
209
|
+
log.step('🔧 Initializing git repository...');
|
|
191
210
|
execSync('git init', { cwd: targetDir, stdio: 'ignore' });
|
|
192
211
|
execSync('git add -A', { cwd: targetDir, stdio: 'ignore' });
|
|
193
212
|
execSync('git commit -m "chore: scaffold with tackl"', {
|
|
194
213
|
cwd: targetDir,
|
|
195
214
|
stdio: 'ignore',
|
|
196
215
|
});
|
|
197
|
-
log.ok('
|
|
216
|
+
log.ok('Git repository initialized!');
|
|
198
217
|
} catch (e) {
|
|
199
218
|
log.warn(`Git init failed: ${e.message}`);
|
|
200
219
|
}
|