tempora-cli 0.1.3 → 0.1.4
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/index.js +61 -9
- package/dist/registry.json +1 -1
- package/package.json +1 -1
- package/registry.json +1 -1
package/dist/index.js
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
// src/index.ts
|
|
4
4
|
import { Command } from "commander";
|
|
5
|
-
import { createRequire as
|
|
5
|
+
import { createRequire as createRequire3 } from "module";
|
|
6
6
|
|
|
7
7
|
// src/commands/init.ts
|
|
8
8
|
import ora from "ora";
|
|
@@ -99,11 +99,11 @@ var config = {
|
|
|
99
99
|
// src/utils/downloader.ts
|
|
100
100
|
var __dirname = path2.dirname(fileURLToPath(import.meta.url));
|
|
101
101
|
function findLocalTemplatesDir() {
|
|
102
|
-
let
|
|
102
|
+
let current3 = __dirname;
|
|
103
103
|
for (let i = 0; i < 6; i++) {
|
|
104
|
-
const candidate = path2.join(
|
|
104
|
+
const candidate = path2.join(current3, "templates");
|
|
105
105
|
if (fs2.existsSync(candidate)) return candidate;
|
|
106
|
-
|
|
106
|
+
current3 = path2.dirname(current3);
|
|
107
107
|
}
|
|
108
108
|
return null;
|
|
109
109
|
}
|
|
@@ -204,7 +204,19 @@ import fs3 from "fs";
|
|
|
204
204
|
import path4 from "path";
|
|
205
205
|
import { fileURLToPath as fileURLToPath2 } from "url";
|
|
206
206
|
var __dirname2 = path4.dirname(fileURLToPath2(import.meta.url));
|
|
207
|
-
|
|
207
|
+
var REMOTE_REGISTRY_URL = "https://raw.githubusercontent.com/DidIrb/tempora/main/packages/cli/registry.json";
|
|
208
|
+
async function loadRegistry() {
|
|
209
|
+
try {
|
|
210
|
+
const res = await fetch(REMOTE_REGISTRY_URL, {
|
|
211
|
+
signal: AbortSignal.timeout(4e3)
|
|
212
|
+
});
|
|
213
|
+
if (res.ok) {
|
|
214
|
+
const data = await res.json();
|
|
215
|
+
return data;
|
|
216
|
+
}
|
|
217
|
+
} catch {
|
|
218
|
+
console.log("Failed");
|
|
219
|
+
}
|
|
208
220
|
const registryPath = path4.resolve(__dirname2, "./registry.json");
|
|
209
221
|
if (!fs3.existsSync(registryPath)) {
|
|
210
222
|
throw new Error("Registry not found. Please rebuild the CLI with npm run build.");
|
|
@@ -289,7 +301,7 @@ function registerInitCommand(program2) {
|
|
|
289
301
|
program2.command("init [template] [directory]").description("Scaffold a new project from a Tempora template").action(async (template, directory) => {
|
|
290
302
|
const spinner = ora();
|
|
291
303
|
try {
|
|
292
|
-
const registry = loadRegistry();
|
|
304
|
+
const registry = await loadRegistry();
|
|
293
305
|
let resolvedTemplate = template;
|
|
294
306
|
let resolvedDirectory = directory;
|
|
295
307
|
if (!resolvedTemplate) {
|
|
@@ -324,7 +336,7 @@ function registerInitCommand(program2) {
|
|
|
324
336
|
function registerInfoCommand(program2) {
|
|
325
337
|
program2.command("info <template>").description("Show details about a specific template").action(async (template) => {
|
|
326
338
|
try {
|
|
327
|
-
const registry = loadRegistry();
|
|
339
|
+
const registry = await loadRegistry();
|
|
328
340
|
const entry = registry.templates[template];
|
|
329
341
|
if (!entry) {
|
|
330
342
|
logger.error(`Template "${template}" not found.`);
|
|
@@ -356,9 +368,47 @@ function registerInfoCommand(program2) {
|
|
|
356
368
|
});
|
|
357
369
|
}
|
|
358
370
|
|
|
359
|
-
// src/
|
|
371
|
+
// src/commands/update.ts
|
|
372
|
+
import { createRequire as createRequire2 } from "module";
|
|
373
|
+
import pc3 from "picocolors";
|
|
360
374
|
var require3 = createRequire2(import.meta.url);
|
|
361
|
-
var { version } = require3("../package.json");
|
|
375
|
+
var { version: current2 } = require3("../package.json");
|
|
376
|
+
function registerUpdateCommand(program2) {
|
|
377
|
+
program2.command("update").description("Check for updates to the Tempora CLI").action(async () => {
|
|
378
|
+
try {
|
|
379
|
+
console.log("");
|
|
380
|
+
console.log(" Checking for updates...");
|
|
381
|
+
const res = await fetch("https://registry.npmjs.org/tempora-cli/latest", {
|
|
382
|
+
signal: AbortSignal.timeout(5e3)
|
|
383
|
+
});
|
|
384
|
+
if (!res.ok) {
|
|
385
|
+
console.log(" " + pc3.red("Could not reach npm registry. Check your connection."));
|
|
386
|
+
return;
|
|
387
|
+
}
|
|
388
|
+
const { version: latest } = await res.json();
|
|
389
|
+
if (current2 === latest) {
|
|
390
|
+
console.log(" " + pc3.green("\u2714") + " You are on the latest version " + pc3.bold(current2));
|
|
391
|
+
} else {
|
|
392
|
+
const [curMajor, curMinor] = current2.split(".").map(Number);
|
|
393
|
+
const [latMajor, latMinor] = latest.split(".").map(Number);
|
|
394
|
+
let type = "patch";
|
|
395
|
+
if (latMajor > curMajor) type = "major";
|
|
396
|
+
else if (latMinor > curMinor) type = "minor";
|
|
397
|
+
console.log("");
|
|
398
|
+
console.log(" " + pc3.bgYellow(pc3.black(` ${type.toUpperCase()} UPDATE `)) + " " + pc3.dim(current2) + " \u2192 " + pc3.green(pc3.bold(latest)));
|
|
399
|
+
console.log(" " + pc3.dim("Run: ") + pc3.cyan("npm install -g tempora-cli"));
|
|
400
|
+
console.log(" " + pc3.dim("https://www.npmjs.com/package/tempora-cli"));
|
|
401
|
+
}
|
|
402
|
+
console.log("");
|
|
403
|
+
} catch {
|
|
404
|
+
console.log(" " + pc3.red("Failed to check for updates."));
|
|
405
|
+
}
|
|
406
|
+
});
|
|
407
|
+
}
|
|
408
|
+
|
|
409
|
+
// src/index.ts
|
|
410
|
+
var require4 = createRequire3(import.meta.url);
|
|
411
|
+
var { version } = require4("../package.json");
|
|
362
412
|
var program = new Command();
|
|
363
413
|
program.name("tempora").description("Scaffold projects from curated templates").version(version, "-v, --version", "Show the current version").addHelpText("after", `
|
|
364
414
|
Examples:
|
|
@@ -366,7 +416,9 @@ Examples:
|
|
|
366
416
|
$ tempora init next-tailwind .
|
|
367
417
|
$ tempora init
|
|
368
418
|
$ tempora info next-tailwind
|
|
419
|
+
$ tempora update
|
|
369
420
|
`);
|
|
370
421
|
registerInitCommand(program);
|
|
371
422
|
registerInfoCommand(program);
|
|
423
|
+
registerUpdateCommand(program);
|
|
372
424
|
program.parse(process.argv);
|
package/dist/registry.json
CHANGED
package/package.json
CHANGED