tackl 1.0.0 → 1.0.1
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 +42 -9
- 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() {
|
|
@@ -131,14 +155,18 @@ ${pc.bold('Repository:')} https://github.com/12-studio/tackl
|
|
|
131
155
|
}
|
|
132
156
|
fs.mkdirSync(targetDir, { recursive: true });
|
|
133
157
|
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
158
|
+
showBanner();
|
|
159
|
+
console.log(pc.bold(pc.white('🚀 Starting project creation...\n')));
|
|
160
|
+
|
|
161
|
+
log.step(`Creating project: ${pc.bold(pc.cyan(projectName))}`);
|
|
162
|
+
log.step(`Template: ${pc.bold(pc.yellow(`${OWNER}/${REPO}@${ref}`))}`);
|
|
163
|
+
console.log();
|
|
137
164
|
|
|
138
165
|
const tarUrl = `https://codeload.github.com/${OWNER}/${REPO}/tar.gz/${encodeURIComponent(ref)}`;
|
|
139
166
|
const tmpTar = path.join(os.tmpdir(), `tackl-${Date.now()}.tgz`);
|
|
140
167
|
|
|
141
168
|
try {
|
|
169
|
+
log.step('📥 Downloading template...');
|
|
142
170
|
const res = await fetch(tarUrl);
|
|
143
171
|
if (!res.ok)
|
|
144
172
|
throw new Error(`Download failed: ${res.status} ${res.statusText}`);
|
|
@@ -148,17 +176,20 @@ ${pc.bold('Repository:')} https://github.com/12-studio/tackl
|
|
|
148
176
|
res.body.on('error', reject);
|
|
149
177
|
out.on('finish', resolve);
|
|
150
178
|
});
|
|
151
|
-
log.ok('
|
|
179
|
+
log.ok('Template downloaded successfully!');
|
|
152
180
|
} catch (e) {
|
|
153
|
-
log.error(e.message);
|
|
181
|
+
log.error(`Download failed: ${e.message}`);
|
|
182
|
+
log.error('Please check your internet connection and try again.');
|
|
154
183
|
process.exit(1);
|
|
155
184
|
}
|
|
156
185
|
|
|
157
186
|
try {
|
|
187
|
+
log.step('📦 Extracting files...');
|
|
158
188
|
await tar.x({ file: tmpTar, cwd: targetDir, strip: 1 });
|
|
159
|
-
log.ok('
|
|
189
|
+
log.ok('Files extracted successfully!');
|
|
160
190
|
} catch (e) {
|
|
161
191
|
log.error(`Extraction failed: ${e.message}`);
|
|
192
|
+
log.error('Please try again or check if the template is valid.');
|
|
162
193
|
process.exit(1);
|
|
163
194
|
} finally {
|
|
164
195
|
try {
|
|
@@ -174,13 +205,14 @@ ${pc.bold('Repository:')} https://github.com/12-studio/tackl
|
|
|
174
205
|
} catch {}
|
|
175
206
|
|
|
176
207
|
// Patch package name
|
|
208
|
+
log.step('📝 Updating project configuration...');
|
|
177
209
|
const pkg = path.join(targetDir, 'package.json');
|
|
178
210
|
if (fs.existsSync(pkg)) {
|
|
179
211
|
try {
|
|
180
212
|
const json = JSON.parse(fs.readFileSync(pkg, 'utf8'));
|
|
181
213
|
json.name = projectName.toLowerCase();
|
|
182
214
|
fs.writeFileSync(pkg, JSON.stringify(json, null, 2));
|
|
183
|
-
log.ok('
|
|
215
|
+
log.ok('Project configuration updated!');
|
|
184
216
|
} catch (e) {
|
|
185
217
|
log.warn(`Could not update package.json: ${e.message}`);
|
|
186
218
|
}
|
|
@@ -188,13 +220,14 @@ ${pc.bold('Repository:')} https://github.com/12-studio/tackl
|
|
|
188
220
|
|
|
189
221
|
if (doGit) {
|
|
190
222
|
try {
|
|
223
|
+
log.step('🔧 Initializing git repository...');
|
|
191
224
|
execSync('git init', { cwd: targetDir, stdio: 'ignore' });
|
|
192
225
|
execSync('git add -A', { cwd: targetDir, stdio: 'ignore' });
|
|
193
226
|
execSync('git commit -m "chore: scaffold with tackl"', {
|
|
194
227
|
cwd: targetDir,
|
|
195
228
|
stdio: 'ignore',
|
|
196
229
|
});
|
|
197
|
-
log.ok('
|
|
230
|
+
log.ok('Git repository initialized!');
|
|
198
231
|
} catch (e) {
|
|
199
232
|
log.warn(`Git init failed: ${e.message}`);
|
|
200
233
|
}
|