@frigear-nu/cli 0.2.4 → 0.2.6

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.
@@ -1,58 +0,0 @@
1
- import { kebabCase } from 'scule';
2
- import { existsSync } from 'node:fs';
3
- import { readdir } from 'node:fs/promises';
4
- import { join, dirname } from 'node:path';
5
- import { readPackageJSON, findNearestFile, writePackageJSON } from 'pkg-types';
6
-
7
- const getDefaultCommandArgs = () => {
8
- return {
9
- cwd: {
10
- type: "string",
11
- description: "The current working directory",
12
- default: process.env.INIT_CWD || process.cwd()
13
- }
14
- };
15
- };
16
- const defineCommandArgs = (args) => {
17
- return {
18
- ...getDefaultCommandArgs(),
19
- ...args
20
- };
21
- };
22
- const templateArgs = {
23
- ref: {
24
- type: "string",
25
- description: "Branch or tag of the frigear-nu repository to copy from",
26
- default: "main"
27
- },
28
- install: {
29
- type: "boolean",
30
- description: "Install dependencies afterwards (--no-install to skip)",
31
- default: true
32
- }
33
- };
34
-
35
- const findWorkspaceRoot = async (cwd) => {
36
- const file = await findNearestFile("pnpm-workspace.yaml", { startingFrom: cwd }).catch(() => void 0);
37
- return file ? dirname(file) : void 0;
38
- };
39
- const readPackage = async (dir) => {
40
- const path = join(dir, "package.json");
41
- return existsSync(path) ? readPackageJSON(path) : void 0;
42
- };
43
- const hasPackage = (dir) => existsSync(join(dir, "package.json"));
44
- const renamePackage = async (dir, name) => {
45
- const path = join(dir, "package.json");
46
- const pkg = await readPackageJSON(path);
47
- await writePackageJSON(path, { ...pkg, name });
48
- };
49
- const packageScope = (name) => name?.startsWith("@") ? name.split("/")[0] : void 0;
50
- const listDirs = async (dir) => {
51
- if (!existsSync(dir)) return [];
52
- const entries = await readdir(dir, { withFileTypes: true });
53
- return entries.filter((entry) => entry.isDirectory()).map((entry) => join(dir, entry.name));
54
- };
55
- const isEmptyDir = async (dir) => !existsSync(dir) || (await readdir(dir)).length === 0;
56
- const toPackageName = (name) => kebabCase(name.replace(/[^\w-]+/g, "-")).replace(/-+/g, "-").replace(/^-|-$/g, "");
57
-
58
- export { readPackage as a, templateArgs as b, defineCommandArgs as d, findWorkspaceRoot as f, hasPackage as h, isEmptyDir as i, listDirs as l, packageScope as p, renamePackage as r, toPackageName as t };
@@ -1,7 +0,0 @@
1
- import { installDependencies, addDependency, runScript } from 'nypm';
2
-
3
- const installDeps = (cwd) => installDependencies({ cwd, packageManager: "pnpm" });
4
- const addDeps = (names, cwd) => addDependency(names, { cwd, packageManager: "pnpm" });
5
- const runPackageScript = (name, cwd) => runScript(name, { cwd, packageManager: "pnpm" });
6
-
7
- export { addDeps as a, installDeps as i, runPackageScript as r };