@frigear-nu/cli 0.1.0 → 0.1.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.
@@ -3,13 +3,14 @@ import consola from 'consola';
3
3
  import { join } from 'node:path';
4
4
  import { f as findWorkspaceRoot, t as toPackageName, h as hasPackage, r as renamePackage, d as defineCommandArgs, b as templateArgs, l as listDirs, p as packageScope, a as readPackage } from '../shared/cli.Cfkcp0w9.mjs';
5
5
  import { i as installDeps } from '../shared/cli.CCJgOooL.mjs';
6
- import { d as downloadTemplateToDir, r as repoSource } from '../shared/cli.C_62nhcg.mjs';
6
+ import { d as downloadTemplateToDir, r as repoSource } from '../shared/cli.C_0i5HKZ.mjs';
7
7
  import 'scule';
8
8
  import 'node:fs';
9
9
  import 'node:fs/promises';
10
10
  import 'pkg-types';
11
11
  import 'nypm';
12
12
  import 'giget';
13
+ import 'node:os';
13
14
 
14
15
  const APP_TEMPLATES = {
15
16
  "web": ".starters/workspace/apps/web",
@@ -3,13 +3,14 @@ import consola from 'consola';
3
3
  import { resolve, basename, relative } from 'node:path';
4
4
  import { i as isEmptyDir, h as hasPackage, r as renamePackage, t as toPackageName, a as readPackage, d as defineCommandArgs, b as templateArgs } from '../shared/cli.Cfkcp0w9.mjs';
5
5
  import { i as installDeps, r as runPackageScript } from '../shared/cli.CCJgOooL.mjs';
6
- import { d as downloadTemplateToDir, r as repoSource } from '../shared/cli.C_62nhcg.mjs';
6
+ import { d as downloadTemplateToDir, r as repoSource } from '../shared/cli.C_0i5HKZ.mjs';
7
7
  import 'scule';
8
8
  import 'node:fs';
9
9
  import 'node:fs/promises';
10
10
  import 'pkg-types';
11
11
  import 'nypm';
12
12
  import 'giget';
13
+ import 'node:os';
13
14
 
14
15
  const PLATFORMS = ["web", "mobile"];
15
16
  const STARTERS = {
@@ -1,13 +1,14 @@
1
1
  import { defineCommand } from 'citty';
2
2
  import { resolve } from 'node:path';
3
3
  import { t as toPackageName, f as findWorkspaceRoot, h as hasPackage, r as renamePackage, d as defineCommandArgs, p as packageScope, a as readPackage } from '../shared/cli.Cfkcp0w9.mjs';
4
- import { d as downloadTemplateToDir } from '../shared/cli.C_62nhcg.mjs';
4
+ import { d as downloadTemplateToDir } from '../shared/cli.C_0i5HKZ.mjs';
5
5
  import consola from 'consola';
6
6
  import 'scule';
7
7
  import 'node:fs';
8
8
  import 'node:fs/promises';
9
9
  import 'pkg-types';
10
10
  import 'giget';
11
+ import 'node:os';
11
12
 
12
13
  const resolveModuleScope = async (root, scope) => {
13
14
  if (scope !== void 0) return scope ? `@${scope.replace(/^@/, "")}` : void 0;
package/dist/cli.mjs CHANGED
@@ -1,5 +1,5 @@
1
1
  #!/usr/bin/env node
2
- import { m as main } from './shared/cli.CeeYOUjI.mjs';
2
+ import { m as main } from './shared/cli.Bt1wuyrA.mjs';
3
3
  import 'citty';
4
4
 
5
5
  await main();
package/dist/index.mjs CHANGED
@@ -1,4 +1,4 @@
1
- export { m as default, a as mainCmd } from './shared/cli.CeeYOUjI.mjs';
1
+ export { m as default, a as mainCmd } from './shared/cli.Bt1wuyrA.mjs';
2
2
  export { PLATFORMS, STARTERS, default as initCmd, resolveStarter } from './chunks/init.mjs';
3
3
  import 'citty';
4
4
  import 'consola';
@@ -10,5 +10,6 @@ import 'node:fs/promises';
10
10
  import 'pkg-types';
11
11
  import './shared/cli.CCJgOooL.mjs';
12
12
  import 'nypm';
13
- import './shared/cli.C_62nhcg.mjs';
13
+ import './shared/cli.C_0i5HKZ.mjs';
14
14
  import 'giget';
15
+ import 'node:os';
@@ -1,6 +1,6 @@
1
1
  import { defineCommand, runMain } from 'citty';
2
2
 
3
- const version = "0.1.0";
3
+ const version = "0.1.2";
4
4
  const pkg = {
5
5
  version: version};
6
6
 
@@ -0,0 +1,35 @@
1
+ import { downloadTemplate } from 'giget';
2
+ import { rm } from 'node:fs/promises';
3
+ import { tmpdir, homedir } from 'node:os';
4
+ import { join, resolve } from 'node:path';
5
+
6
+ const FRIGEAR_REPO = "gh:Frigear-nu/frigear-nu";
7
+ const repoSource = (path, ref = "main") => `${FRIGEAR_REPO}/${path}#${ref}`;
8
+ const gigetCacheDir = (env = process.env, platform = process.platform) => {
9
+ if (platform === "win32") return resolve(tmpdir(), "giget");
10
+ return env.XDG_CACHE_HOME ? resolve(env.XDG_CACHE_HOME, "giget") : resolve(homedir(), ".cache/giget");
11
+ };
12
+ const cachedTarball = (template, cacheDir = gigetCacheDir()) => {
13
+ const match = /^gh:([\w.-]+)\/([\w.-]+)(?:\/[^#]*)?(?:#(.+))?$/.exec(template);
14
+ if (!match) return void 0;
15
+ const [, owner, repo, ref = "main"] = match;
16
+ return join(cacheDir, "gh", `${owner}-${repo}`.replace(/[^\da-z-]/gi, "-"), `${ref}.tar.gz`);
17
+ };
18
+ const downloadTemplateToDir = async ({ template, path, cwd, force }) => {
19
+ const cached = template.startsWith(FRIGEAR_REPO) ? cachedTarball(template) : void 0;
20
+ if (cached) await Promise.all([rm(cached, { force: true }), rm(`${cached}.json`, { force: true })]);
21
+ return downloadTemplate(template, {
22
+ cwd,
23
+ dir: path,
24
+ force
25
+ }).catch((error) => {
26
+ const message = error instanceof Error ? error.message : String(error);
27
+ if (template.startsWith(FRIGEAR_REPO) && /\b(?:401|403|404)\b/.test(message) && !process.env.GIGET_AUTH) {
28
+ throw new Error(`${message}
29
+ While Frigear-nu/frigear-nu is not public, set GIGET_AUTH to a GitHub token that can read it, e.g. GIGET_AUTH=$(gh auth token).`, { cause: error });
30
+ }
31
+ throw error;
32
+ });
33
+ };
34
+
35
+ export { downloadTemplateToDir as d, repoSource as r };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@frigear-nu/cli",
3
- "version": "0.1.0",
3
+ "version": "0.1.2",
4
4
  "type": "module",
5
5
  "private": false,
6
6
  "description": "Frigear CLI: scaffold projects, apps and modules, and add Frigear modules to an app.",
@@ -12,7 +12,7 @@
12
12
  "homepage": "https://docs.frigear.dev/contribute/tooling/cli",
13
13
  "repository": {
14
14
  "type": "git",
15
- "url": "git+https://github.com/frigear-nu/frigear-nu.git",
15
+ "url": "git+https://github.com/Frigear-nu/frigear-nu.git",
16
16
  "directory": "packages/cli"
17
17
  },
18
18
  "license": "MIT",
@@ -39,18 +39,18 @@
39
39
  "consola": "^3.4.2",
40
40
  "giget": "^3.3.1",
41
41
  "magicast": "^0.5.5",
42
- "nypm": "^0.6.10",
42
+ "nypm": "^0.6.12",
43
43
  "pkg-types": "^2.4.0",
44
44
  "scule": "^1.3.0"
45
45
  },
46
46
  "devDependencies": {
47
- "@frigear-nu/eslint-config": "^0.2.3",
48
- "@types/node": "^26.6.5",
49
- "eslint": "^10.12.0",
47
+ "@frigear-nu/eslint-config": "^0.2.5",
48
+ "@types/node": "^26.6.6",
49
+ "eslint": "^10.14.0",
50
50
  "jiti": "^2.7.0",
51
51
  "typescript": "^6.0.3",
52
52
  "unbuild": "^3.6.1",
53
- "vitest": "^5.0.2"
53
+ "vitest": "^5.1.0"
54
54
  },
55
55
  "scripts": {
56
56
  "dev": "node bin/cli.mjs",
@@ -1,20 +0,0 @@
1
- import { downloadTemplate } from 'giget';
2
-
3
- const FRIGEAR_REPO = "gh:Frigear-nu/frigear-nu";
4
- const repoSource = (path, ref = "main") => `${FRIGEAR_REPO}/${path}#${ref}`;
5
- const downloadTemplateToDir = async ({ template, path, cwd, force }) => {
6
- return downloadTemplate(template, {
7
- cwd,
8
- dir: path,
9
- force
10
- }).catch((error) => {
11
- const message = error instanceof Error ? error.message : String(error);
12
- if (template.startsWith(FRIGEAR_REPO) && /\b(?:401|403|404)\b/.test(message) && !process.env.GIGET_AUTH) {
13
- throw new Error(`${message}
14
- While Frigear-nu/frigear-nu is not public, set GIGET_AUTH to a GitHub token that can read it, e.g. GIGET_AUTH=$(gh auth token).`, { cause: error });
15
- }
16
- throw error;
17
- });
18
- };
19
-
20
- export { downloadTemplateToDir as d, repoSource as r };