@reliverse/dler 1.6.1 → 1.6.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/README.md +40 -13
- package/bin/app/agg/run.js +2 -2
- package/bin/app/check/cmd.d.ts +8 -0
- package/bin/app/check/cmd.js +19 -0
- package/bin/app/cmds.d.ts +297 -72
- package/bin/app/cmds.js +50 -11
- package/bin/app/conv/cmd.d.ts +33 -0
- package/bin/app/conv/cmd.js +189 -0
- package/bin/app/inject/cmd.js +2 -2
- package/bin/app/libs/cmd.d.ts +13 -0
- package/bin/app/libs/cmd.js +109 -0
- package/bin/app/relifso/cmd.js +4 -4
- package/bin/app/relinka/cmd.d.ts +18 -0
- package/bin/app/relinka/cmd.js +149 -0
- package/bin/app/rempts/{init/cmd → cmd}/cmd.d.ts +8 -4
- package/bin/app/rempts/cmd/cmd.js +152 -0
- package/bin/app/rempts/cmd/templates.d.ts +2 -0
- package/bin/app/rempts/cmd/templates.js +30 -0
- package/bin/app/rempts/{init/cmds → cmdsTs}/cmd.d.ts +1 -3
- package/bin/app/rempts/{init/cmds → cmdsTs}/cmd.js +30 -13
- package/bin/cli.js +3 -3
- package/bin/init/info.js +1 -1
- package/bin/init/load.d.ts +2 -2
- package/bin/libs/sdk/default.d.ts +2 -2
- package/bin/libs/sdk/sdk-impl/build/build-library.d.ts +2 -2
- package/bin/libs/sdk/sdk-impl/build/build-regular.d.ts +3 -3
- package/bin/libs/sdk/sdk-impl/library-flow.d.ts +3 -3
- package/bin/libs/sdk/sdk-impl/regular-flow.d.ts +2 -2
- package/bin/libs/sdk/sdk-impl/utils/utils-deps.d.ts +2 -2
- package/bin/libs/sdk/sdk-impl/utils/utils-pkg-json-libs.d.ts +2 -2
- package/bin/libs/sdk/sdk-impl/utils/utils-pkg-json-reg.d.ts +2 -2
- package/bin/libs/sdk/sdk-types.d.ts +1 -1
- package/bin/mod.d.ts +2 -2
- package/package.json +2 -2
- package/bin/app/mono/cmd.d.ts +0 -0
- package/bin/app/mono/cmd.js +0 -0
- package/bin/app/rempts/init/cmd/cmd.js +0 -67
|
@@ -0,0 +1,152 @@
|
|
|
1
|
+
import path from "@reliverse/pathkit";
|
|
2
|
+
import fs from "@reliverse/relifso";
|
|
3
|
+
import { relinka } from "@reliverse/relinka";
|
|
4
|
+
import { defineArgs, defineCommand } from "@reliverse/rempts";
|
|
5
|
+
import { createJiti } from "jiti";
|
|
6
|
+
import { generateCommandTemplate, cliTemplate } from "./templates.js";
|
|
7
|
+
export default defineCommand({
|
|
8
|
+
meta: {
|
|
9
|
+
name: "init",
|
|
10
|
+
version: "1.0.0",
|
|
11
|
+
description: "Scaffold new CLI commands quickly."
|
|
12
|
+
},
|
|
13
|
+
args: defineArgs({
|
|
14
|
+
init: {
|
|
15
|
+
type: "string",
|
|
16
|
+
required: true,
|
|
17
|
+
description: "Names of commands to initialize (space-separated or quoted)"
|
|
18
|
+
},
|
|
19
|
+
overwrite: {
|
|
20
|
+
type: "boolean",
|
|
21
|
+
default: false,
|
|
22
|
+
description: "Overwrite existing commands"
|
|
23
|
+
},
|
|
24
|
+
customCmdsRoot: {
|
|
25
|
+
type: "string",
|
|
26
|
+
default: "",
|
|
27
|
+
description: "Root directory for custom commands"
|
|
28
|
+
}
|
|
29
|
+
}),
|
|
30
|
+
async run({ args }) {
|
|
31
|
+
let cmdNames = [];
|
|
32
|
+
if (Array.isArray(args.init)) {
|
|
33
|
+
cmdNames = args.init;
|
|
34
|
+
} else if (typeof args.init === "string") {
|
|
35
|
+
cmdNames = args.init.split(/\s+/).filter(Boolean);
|
|
36
|
+
}
|
|
37
|
+
if (cmdNames.length === 1) {
|
|
38
|
+
const argv = process.argv;
|
|
39
|
+
const initIndex = argv.findIndex((arg) => arg === "--init");
|
|
40
|
+
if (initIndex !== -1 && initIndex + 1 < argv.length) {
|
|
41
|
+
const additionalArgs = [];
|
|
42
|
+
for (let i = initIndex + 2; i < argv.length; i++) {
|
|
43
|
+
const arg = argv[i];
|
|
44
|
+
if (arg?.startsWith("--")) break;
|
|
45
|
+
if (arg && !arg.startsWith("-")) {
|
|
46
|
+
additionalArgs.push(arg);
|
|
47
|
+
} else {
|
|
48
|
+
break;
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
if (additionalArgs.length > 0 && cmdNames[0]) {
|
|
52
|
+
cmdNames = [cmdNames[0], ...additionalArgs];
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
if (cmdNames.length === 0) {
|
|
57
|
+
relinka("error", "\u274C No command names provided");
|
|
58
|
+
return;
|
|
59
|
+
}
|
|
60
|
+
let cmdsRoot = args.customCmdsRoot;
|
|
61
|
+
let cliFilePath = "";
|
|
62
|
+
if (!cmdsRoot) {
|
|
63
|
+
const defaultCmdsRoot = path.resolve("src/app");
|
|
64
|
+
if (await fs.pathExists(defaultCmdsRoot)) {
|
|
65
|
+
cmdsRoot = defaultCmdsRoot;
|
|
66
|
+
} else {
|
|
67
|
+
const { cmdsRoot: configCmdsRoot, cliFile } = await handleDlerConfig();
|
|
68
|
+
cmdsRoot = configCmdsRoot;
|
|
69
|
+
cliFilePath = cliFile;
|
|
70
|
+
}
|
|
71
|
+
} else {
|
|
72
|
+
cmdsRoot = path.resolve(cmdsRoot);
|
|
73
|
+
}
|
|
74
|
+
relinka(
|
|
75
|
+
"info",
|
|
76
|
+
`\u{1F680} Creating ${cmdNames.length} command(s): ${cmdNames.join(", ")}`
|
|
77
|
+
);
|
|
78
|
+
for (const cmdName of cmdNames) {
|
|
79
|
+
const dirPath = path.join(cmdsRoot, cmdName);
|
|
80
|
+
const filePath = path.join(dirPath, "cmd.ts");
|
|
81
|
+
if (await fs.pathExists(filePath) && !args.overwrite) {
|
|
82
|
+
relinka(
|
|
83
|
+
"warn",
|
|
84
|
+
`\u274C Command "${cmdName}" already exists. Use --overwrite to overwrite.`
|
|
85
|
+
);
|
|
86
|
+
continue;
|
|
87
|
+
}
|
|
88
|
+
await fs.ensureDir(dirPath);
|
|
89
|
+
const content = generateCommandTemplate(cmdName);
|
|
90
|
+
await fs.writeFile(filePath, content, "utf-8");
|
|
91
|
+
relinka("log", `\u2705 Created new command: ${filePath}`);
|
|
92
|
+
}
|
|
93
|
+
if (cliFilePath) {
|
|
94
|
+
relinka(
|
|
95
|
+
"info",
|
|
96
|
+
"\u{1F4E6} Make sure you have @reliverse/rempts installed: bun add @reliverse/rempts"
|
|
97
|
+
);
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
});
|
|
101
|
+
async function handleDlerConfig() {
|
|
102
|
+
const dlerConfigPath = path.resolve(".config/dler.ts");
|
|
103
|
+
let cmdsRoot = "src/app";
|
|
104
|
+
let cliFilePath = "";
|
|
105
|
+
try {
|
|
106
|
+
const jiti = createJiti(import.meta.url);
|
|
107
|
+
const dlerConfig = await jiti.import(dlerConfigPath, {
|
|
108
|
+
default: true
|
|
109
|
+
});
|
|
110
|
+
const coreIsCLI = dlerConfig?.coreIsCLI;
|
|
111
|
+
if (!coreIsCLI?.enabled || !coreIsCLI?.scripts) {
|
|
112
|
+
cliFilePath = await ensureCliFile("src/cli.ts");
|
|
113
|
+
cmdsRoot = "src/app";
|
|
114
|
+
} else {
|
|
115
|
+
const firstScript = Object.values(coreIsCLI.scripts)[0];
|
|
116
|
+
const scriptPath = path.resolve(firstScript);
|
|
117
|
+
if (await fs.pathExists(scriptPath)) {
|
|
118
|
+
const content = await fs.readFile(scriptPath, "utf-8");
|
|
119
|
+
if (content.includes("@reliverse/rempts")) {
|
|
120
|
+
if (content.includes("runMain")) {
|
|
121
|
+
const cmdsRootMatch = content.match(
|
|
122
|
+
/cmdsRootPath:\s*["']([^"']+)["']/
|
|
123
|
+
);
|
|
124
|
+
if (cmdsRootMatch?.[1]) {
|
|
125
|
+
cmdsRoot = path.resolve(cmdsRootMatch[1]);
|
|
126
|
+
}
|
|
127
|
+
}
|
|
128
|
+
} else {
|
|
129
|
+
relinka("warn", `\u274C ${scriptPath} doesn't use @reliverse/rempts`);
|
|
130
|
+
cmdsRoot = "src/app";
|
|
131
|
+
}
|
|
132
|
+
} else {
|
|
133
|
+
cliFilePath = await ensureCliFile(scriptPath);
|
|
134
|
+
cmdsRoot = "src/app";
|
|
135
|
+
}
|
|
136
|
+
}
|
|
137
|
+
} catch {
|
|
138
|
+
cliFilePath = await ensureCliFile("src/cli.ts");
|
|
139
|
+
cmdsRoot = "src/app";
|
|
140
|
+
}
|
|
141
|
+
return { cmdsRoot: path.resolve(cmdsRoot), cliFile: cliFilePath };
|
|
142
|
+
}
|
|
143
|
+
async function ensureCliFile(filePath) {
|
|
144
|
+
const resolvedPath = path.resolve(filePath);
|
|
145
|
+
if (!await fs.pathExists(resolvedPath)) {
|
|
146
|
+
await fs.ensureDir(path.dirname(resolvedPath));
|
|
147
|
+
await fs.writeFile(resolvedPath, cliTemplate, "utf-8");
|
|
148
|
+
relinka("log", `\u2705 Created CLI entry file: ${resolvedPath}`);
|
|
149
|
+
return resolvedPath;
|
|
150
|
+
}
|
|
151
|
+
return "";
|
|
152
|
+
}
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
export declare function generateCommandTemplate(cmdName: string): string;
|
|
2
|
+
export declare const cliTemplate = "import { defineCommand, runMain } from \"@reliverse/rempts\";\n \n await runMain(\n defineCommand({\n // empty object activates file-based\n // commands in the src/app directory\n }),\n );\n ";
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
export function generateCommandTemplate(cmdName) {
|
|
2
|
+
return `import { defineCommand, defineArgs } from "@reliverse/rempts";
|
|
3
|
+
export default defineCommand({
|
|
4
|
+
meta: {
|
|
5
|
+
name: "${cmdName}",
|
|
6
|
+
version: "1.0.0",
|
|
7
|
+
description: "Describe what ${cmdName} command does.",
|
|
8
|
+
},
|
|
9
|
+
args: defineArgs({
|
|
10
|
+
exampleArg: {
|
|
11
|
+
type: "string",
|
|
12
|
+
default: "defaultValue",
|
|
13
|
+
description: "An example argument",
|
|
14
|
+
},
|
|
15
|
+
}),
|
|
16
|
+
async run({ args }) {
|
|
17
|
+
console.log("Command '${cmdName}' executed.");
|
|
18
|
+
console.log("Received args:", args);
|
|
19
|
+
},
|
|
20
|
+
});
|
|
21
|
+
`;
|
|
22
|
+
}
|
|
23
|
+
export const cliTemplate = `import { defineCommand, runMain } from "@reliverse/rempts";
|
|
24
|
+
await runMain(
|
|
25
|
+
defineCommand({
|
|
26
|
+
// empty object activates file-based
|
|
27
|
+
// commands in the src/app directory
|
|
28
|
+
}),
|
|
29
|
+
);
|
|
30
|
+
`;
|
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
import path from "@reliverse/pathkit";
|
|
2
2
|
import fs from "@reliverse/relifso";
|
|
3
3
|
import { relinka } from "@reliverse/relinka";
|
|
4
|
-
import { defineCommand } from "@reliverse/rempts";
|
|
4
|
+
import { defineArgs, defineCommand } from "@reliverse/rempts";
|
|
5
5
|
export default defineCommand({
|
|
6
6
|
meta: {
|
|
7
7
|
name: "cmds",
|
|
8
8
|
version: "1.0.0",
|
|
9
9
|
description: "Generate command exports file for cmd.ts files."
|
|
10
10
|
},
|
|
11
|
-
args: {
|
|
11
|
+
args: defineArgs({
|
|
12
12
|
outFile: {
|
|
13
13
|
type: "string",
|
|
14
14
|
description: "Output file path (relative to workspace root)",
|
|
@@ -16,23 +16,21 @@ export default defineCommand({
|
|
|
16
16
|
},
|
|
17
17
|
cmdDirs: {
|
|
18
18
|
type: "array",
|
|
19
|
-
description: "Command directories to scan (relative to src/app)"
|
|
20
|
-
default: [],
|
|
21
|
-
options: ["relifso", "inject", "rempts"]
|
|
19
|
+
description: "Command directories to scan (relative to src/app)"
|
|
22
20
|
},
|
|
23
|
-
|
|
21
|
+
overwrite: {
|
|
24
22
|
type: "boolean",
|
|
25
23
|
default: false,
|
|
26
|
-
description: "Overwrite existing file"
|
|
24
|
+
description: "Overwrite existing file (default: false)"
|
|
27
25
|
}
|
|
28
|
-
},
|
|
26
|
+
}),
|
|
29
27
|
async run({ args }) {
|
|
30
28
|
const root = path.resolve("src/app");
|
|
31
29
|
const outPath = path.resolve(args.outFile ?? "src/app/cmds.ts");
|
|
32
|
-
if (await fs.pathExists(outPath) && !args.
|
|
30
|
+
if (await fs.pathExists(outPath) && !args.overwrite) {
|
|
33
31
|
relinka(
|
|
34
32
|
"warn",
|
|
35
|
-
`\u274C File "${outPath}" already exists. Use --
|
|
33
|
+
`\u274C File "${outPath}" already exists. Use --overwrite to overwrite.`
|
|
36
34
|
);
|
|
37
35
|
return;
|
|
38
36
|
}
|
|
@@ -46,6 +44,25 @@ export default defineCommand({
|
|
|
46
44
|
await fs.writeFile(outPath, exports, "utf-8");
|
|
47
45
|
relinka("success", `\u2705 Generated command exports at: ${outPath}`);
|
|
48
46
|
relinka("log", `Found ${cmdDirs.length} command(s): ${cmdDirs.join(", ")}`);
|
|
47
|
+
relinka(
|
|
48
|
+
"log",
|
|
49
|
+
`Usage example:
|
|
50
|
+
import { getCmdName } from "../../cmds.js";
|
|
51
|
+
await runCmd(await getCmdName(), [
|
|
52
|
+
// String arguments
|
|
53
|
+
"--name=my-project",
|
|
54
|
+
"--path=./src",
|
|
55
|
+
// Boolean flags
|
|
56
|
+
"--force",
|
|
57
|
+
"--no-cache",
|
|
58
|
+
// Number values
|
|
59
|
+
"--port=3000",
|
|
60
|
+
// Array values
|
|
61
|
+
"--files=file1.ts,file2.ts",
|
|
62
|
+
// Positional arguments (must come last)
|
|
63
|
+
"--build=src/1.ts src/2.ts",
|
|
64
|
+
]);`
|
|
65
|
+
);
|
|
49
66
|
}
|
|
50
67
|
});
|
|
51
68
|
async function findCommandDirs(root) {
|
|
@@ -58,9 +75,8 @@ async function findCommandDirs(root) {
|
|
|
58
75
|
if (await fs.pathExists(path.join(fullPath, "cmd.ts"))) {
|
|
59
76
|
const relPath = path.relative(root, fullPath);
|
|
60
77
|
cmdDirs.push(relPath);
|
|
61
|
-
} else {
|
|
62
|
-
await scan(fullPath);
|
|
63
78
|
}
|
|
79
|
+
await scan(fullPath);
|
|
64
80
|
}
|
|
65
81
|
}
|
|
66
82
|
}
|
|
@@ -74,7 +90,8 @@ function generateExports(cmdDirs) {
|
|
|
74
90
|
return (await import("./${dir}/cmd")).default;
|
|
75
91
|
}`;
|
|
76
92
|
});
|
|
77
|
-
return `//
|
|
93
|
+
return `// this file is auto-generated by
|
|
94
|
+
// dler rempts cmdsTs --overwrite
|
|
78
95
|
${imports.join("\n\n")}
|
|
79
96
|
`;
|
|
80
97
|
}
|
package/bin/cli.js
CHANGED
|
@@ -8,7 +8,7 @@ import {
|
|
|
8
8
|
runCmd
|
|
9
9
|
} from "@reliverse/rempts";
|
|
10
10
|
import { promptAggCommand } from "./app/agg/run.js";
|
|
11
|
-
import {
|
|
11
|
+
import { getCmdBuild, getCmdPub } from "./app/cmds.js";
|
|
12
12
|
import { showEndPrompt, showStartPrompt } from "./init/info.js";
|
|
13
13
|
const INTERACTIVE_CMDS = ["agg", "build", "pub"];
|
|
14
14
|
const main = defineCommand({
|
|
@@ -48,10 +48,10 @@ Available interactive commands: ${INTERACTIVE_CMDS.join(", ")}`
|
|
|
48
48
|
await promptAggCommand();
|
|
49
49
|
}
|
|
50
50
|
if (cmdToRun === "build") {
|
|
51
|
-
await runCmd(await
|
|
51
|
+
await runCmd(await getCmdBuild(), [`--dev=${args.dev}`]);
|
|
52
52
|
}
|
|
53
53
|
if (cmdToRun === "pub") {
|
|
54
|
-
await runCmd(await
|
|
54
|
+
await runCmd(await getCmdPub(), [`--dev=${args.dev}`]);
|
|
55
55
|
}
|
|
56
56
|
relinka("log", " ");
|
|
57
57
|
await showEndPrompt();
|
package/bin/init/info.js
CHANGED
package/bin/init/load.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { DlerConfig } from "../libs/sdk/sdk-types.js";
|
|
2
2
|
/**
|
|
3
3
|
* Searches for and loads the configuration file `.config/dler.ts`.
|
|
4
4
|
* Falls back to default configuration if the file is not found.
|
|
5
5
|
*/
|
|
6
|
-
export declare function loadConfig(): Promise<
|
|
6
|
+
export declare function loadConfig(): Promise<DlerConfig>;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { DlerConfig } from "./sdk-types.js";
|
|
2
2
|
/**
|
|
3
3
|
* Default configuration for the build and publish logic.
|
|
4
4
|
*/
|
|
5
|
-
export declare const DEFAULT_CONFIG:
|
|
5
|
+
export declare const DEFAULT_CONFIG: DlerConfig;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { PerfTimer } from "../../sdk-types.js";
|
|
2
|
-
import type { BundlerName,
|
|
2
|
+
import type { BundlerName, DlerConfig, Esbuild, LibConfig, NpmOutExt, Sourcemap, transpileFormat, transpileTarget } from "../../sdk-types.js";
|
|
3
3
|
/** Options specific to the NPM build target */
|
|
4
4
|
type NpmBuildOptions = {
|
|
5
5
|
npmOutDir: string;
|
|
@@ -13,7 +13,7 @@ type JsrBuildOptions = {
|
|
|
13
13
|
distJsrOutFilesExt: NpmOutExt;
|
|
14
14
|
};
|
|
15
15
|
/** Consolidated options for the main library build function */
|
|
16
|
-
export type LibraryBuildOptions =
|
|
16
|
+
export type LibraryBuildOptions = DlerConfig & {
|
|
17
17
|
effectivePubRegistry: "npm" | "jsr" | "npm-jsr" | undefined;
|
|
18
18
|
npm?: NpmBuildOptions;
|
|
19
19
|
jsr?: JsrBuildOptions;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { BundlerName, NpmOutExt, Sourcemap, transpileFormat, transpileTarget,
|
|
1
|
+
import type { BundlerName, NpmOutExt, Sourcemap, transpileFormat, transpileTarget, DlerConfig, PerfTimer } from "../../sdk-types.js";
|
|
2
2
|
/**
|
|
3
3
|
* Builds a regular JSR distribution.
|
|
4
4
|
* - Copies the entire source directory if `distJsrBuilder` = "jsr"
|
|
@@ -7,13 +7,13 @@ import type { BundlerName, NpmOutExt, Sourcemap, transpileFormat, transpileTarge
|
|
|
7
7
|
export declare function regular_buildJsrDist(isDev: boolean, isJsr: boolean, coreIsCLI: {
|
|
8
8
|
enabled: boolean;
|
|
9
9
|
scripts: Record<string, string>;
|
|
10
|
-
}, coreEntrySrcDir: string, distJsrDirName: string, distJsrBuilder: BundlerName, coreEntryFile: string, transpileTarget: transpileTarget, transpileFormat: transpileFormat, transpileSplitting: boolean, transpileMinify: boolean, transpileSourcemap: Sourcemap, transpilePublicPath: string, unifiedBundlerOutExt: NpmOutExt, config:
|
|
10
|
+
}, coreEntrySrcDir: string, distJsrDirName: string, distJsrBuilder: BundlerName, coreEntryFile: string, transpileTarget: transpileTarget, transpileFormat: transpileFormat, transpileSplitting: boolean, transpileMinify: boolean, transpileSourcemap: Sourcemap, transpilePublicPath: string, unifiedBundlerOutExt: NpmOutExt, config: DlerConfig, timer: PerfTimer, transpileStub: boolean, transpileWatch: boolean, distJsrGenTsconfig: boolean, coreDeclarations: boolean): Promise<void>;
|
|
11
11
|
/**
|
|
12
12
|
* Builds a regular NPM distribution.
|
|
13
13
|
* - Copies entire src dir if "jsr"
|
|
14
14
|
* - Otherwise uses Bun or a unified builder
|
|
15
15
|
*/
|
|
16
|
-
export declare function regular_buildNpmDist(isDev: boolean, coreEntrySrcDir: string, distNpmDirName: string, distNpmBuilder: BundlerName, coreEntryFile: string, unifiedBundlerOutExt: NpmOutExt, config:
|
|
16
|
+
export declare function regular_buildNpmDist(isDev: boolean, coreEntrySrcDir: string, distNpmDirName: string, distNpmBuilder: BundlerName, coreEntryFile: string, unifiedBundlerOutExt: NpmOutExt, config: DlerConfig, coreIsCLI: {
|
|
17
17
|
enabled: boolean;
|
|
18
18
|
scripts: Record<string, string>;
|
|
19
19
|
}, transpileTarget: transpileTarget, transpileFormat: transpileFormat, transpileSplitting: boolean, transpileMinify: boolean, transpileSourcemap: Sourcemap, transpilePublicPath: string, transpileStub: boolean, transpileWatch: boolean, timer: PerfTimer, coreDeclarations: boolean): Promise<void>;
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import type { BundlerName, Esbuild, LibConfig, NpmOutExt, Sourcemap, transpileFormat, transpileTarget,
|
|
1
|
+
import type { BundlerName, Esbuild, LibConfig, NpmOutExt, Sourcemap, transpileFormat, transpileTarget, DlerConfig, PerfTimer } from "../sdk-types.js";
|
|
2
2
|
/**
|
|
3
3
|
* Processes libraries based on build mode.
|
|
4
4
|
*/
|
|
5
|
-
export declare function processLibraryFlow(timer: PerfTimer, isDev: boolean, config:
|
|
5
|
+
export declare function processLibraryFlow(timer: PerfTimer, isDev: boolean, config: DlerConfig): Promise<void>;
|
|
6
6
|
/**
|
|
7
7
|
* Processes all libs defined in config.libsList.
|
|
8
8
|
* Builds and optionally publishes each library based on configuration.
|
|
@@ -15,4 +15,4 @@ export declare function libraries_buildPublish(isDev: boolean, timer: PerfTimer,
|
|
|
15
15
|
npm: string[];
|
|
16
16
|
jsr: string[];
|
|
17
17
|
}>;
|
|
18
|
-
}, transpileEsbuild: Esbuild, transpileTarget: transpileTarget, transpileFormat: transpileFormat, transpileSplitting: boolean, transpileSourcemap: Sourcemap, transpilePublicPath: string, distJsrBuilder: BundlerName, transpileStub: boolean, transpileWatch: boolean, distJsrOutFilesExt: NpmOutExt, distJsrAllowDirty: boolean, distJsrSlowTypes: boolean, config:
|
|
18
|
+
}, transpileEsbuild: Esbuild, transpileTarget: transpileTarget, transpileFormat: transpileFormat, transpileSplitting: boolean, transpileSourcemap: Sourcemap, transpilePublicPath: string, distJsrBuilder: BundlerName, transpileStub: boolean, transpileWatch: boolean, distJsrOutFilesExt: NpmOutExt, distJsrAllowDirty: boolean, distJsrSlowTypes: boolean, config: DlerConfig): Promise<void>;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { DlerConfig, PerfTimer } from "../sdk-types.js";
|
|
2
2
|
/**
|
|
3
3
|
* Processes the main project based on build mode and commonPubRegistry.
|
|
4
4
|
*/
|
|
5
|
-
export declare function processRegularFlow(timer: PerfTimer, isDev: boolean, config:
|
|
5
|
+
export declare function processRegularFlow(timer: PerfTimer, isDev: boolean, config: DlerConfig): Promise<void>;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { DlerConfig } from "../../sdk-types.js";
|
|
2
2
|
/**
|
|
3
3
|
* Filters out development dependencies from a dependency record.
|
|
4
4
|
*/
|
|
5
|
-
export declare function filterDeps(deps: Record<string, string> | undefined, clearUnused: boolean, outDirBin: string, isJsr: boolean, config:
|
|
5
|
+
export declare function filterDeps(deps: Record<string, string> | undefined, clearUnused: boolean, outDirBin: string, isJsr: boolean, config: DlerConfig, libName?: string): Promise<Record<string, string>>;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import type { NpmOutExt,
|
|
1
|
+
import type { NpmOutExt, DlerConfig, LibConfig } from "../../sdk-types.js";
|
|
2
2
|
/**
|
|
3
3
|
* Creates a package.json for a lib distribution.
|
|
4
4
|
*/
|
|
5
|
-
export declare function library_createPackageJSON(libName: string, npmOutDir: string, jsrOutDir: string, effectivePubRegistry: "npm" | "jsr" | "npm-jsr" | undefined, libsList: Record<string, LibConfig>, config:
|
|
5
|
+
export declare function library_createPackageJSON(libName: string, npmOutDir: string, jsrOutDir: string, effectivePubRegistry: "npm" | "jsr" | "npm-jsr" | undefined, libsList: Record<string, LibConfig>, config: DlerConfig, unifiedBundlerOutExt: NpmOutExt): Promise<void>;
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import type { NpmOutExt,
|
|
1
|
+
import type { NpmOutExt, DlerConfig } from "../../sdk-types.js";
|
|
2
2
|
/**
|
|
3
3
|
* Creates a package.json for the main distribution.
|
|
4
4
|
*/
|
|
5
5
|
export declare function regular_createPackageJSON(outDirRoot: string, isJsr: boolean, coreIsCLI: {
|
|
6
6
|
enabled: boolean;
|
|
7
7
|
scripts: Record<string, string>;
|
|
8
|
-
}, unifiedBundlerOutExt: NpmOutExt, config:
|
|
8
|
+
}, unifiedBundlerOutExt: NpmOutExt, config: DlerConfig, coreDescription: string, coreBuildOutDir?: string): Promise<void>;
|
|
@@ -10,7 +10,7 @@ import type { Schema } from "untyped";
|
|
|
10
10
|
* build settings, publishing options, libraries-dler-plugin built-in plugin, and more.
|
|
11
11
|
* It customizes the build and publish pipeline for both NPM and JSR registries.
|
|
12
12
|
*/
|
|
13
|
-
export type
|
|
13
|
+
export type DlerConfig = {
|
|
14
14
|
/**
|
|
15
15
|
* When `true`, disables version bumping.
|
|
16
16
|
* Useful when retrying a failed publish with an already bumped version.
|
package/bin/mod.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import type {
|
|
2
|
-
export declare const defineConfig: (userConfig?: Partial<
|
|
1
|
+
import type { DlerConfig } from "./libs/sdk/sdk-types.js";
|
|
2
|
+
export declare const defineConfig: (userConfig?: Partial<DlerConfig>) => any;
|
package/package.json
CHANGED
|
@@ -15,7 +15,7 @@
|
|
|
15
15
|
"@rollup/pluginutils": "^5.1.4",
|
|
16
16
|
"chalk": "^5.4.1",
|
|
17
17
|
"defu": "^6.1.4",
|
|
18
|
-
"esbuild": "^0.25.
|
|
18
|
+
"esbuild": "^0.25.5",
|
|
19
19
|
"execa": "^9.6.0",
|
|
20
20
|
"fix-dts-default-cjs-exports": "^1.0.1",
|
|
21
21
|
"glob": "^11.0.2",
|
|
@@ -41,7 +41,7 @@
|
|
|
41
41
|
"license": "MIT",
|
|
42
42
|
"name": "@reliverse/dler",
|
|
43
43
|
"type": "module",
|
|
44
|
-
"version": "1.6.
|
|
44
|
+
"version": "1.6.2",
|
|
45
45
|
"keywords": [
|
|
46
46
|
"reliverse",
|
|
47
47
|
"cli",
|
package/bin/app/mono/cmd.d.ts
DELETED
|
File without changes
|
package/bin/app/mono/cmd.js
DELETED
|
File without changes
|
|
@@ -1,67 +0,0 @@
|
|
|
1
|
-
import path from "@reliverse/pathkit";
|
|
2
|
-
import fs from "@reliverse/relifso";
|
|
3
|
-
import { relinka } from "@reliverse/relinka";
|
|
4
|
-
import { defineCommand } from "@reliverse/rempts";
|
|
5
|
-
export default defineCommand({
|
|
6
|
-
meta: {
|
|
7
|
-
name: "init",
|
|
8
|
-
version: "1.0.0",
|
|
9
|
-
description: "Scaffold new CLI commands quickly."
|
|
10
|
-
},
|
|
11
|
-
args: {
|
|
12
|
-
cmd: {
|
|
13
|
-
type: "array",
|
|
14
|
-
required: true,
|
|
15
|
-
description: "Names of commands to initialize",
|
|
16
|
-
options: ["cmd1", "cmd2", "cmd3"]
|
|
17
|
-
},
|
|
18
|
-
force: {
|
|
19
|
-
type: "boolean",
|
|
20
|
-
default: false,
|
|
21
|
-
description: "Overwrite existing commands"
|
|
22
|
-
}
|
|
23
|
-
},
|
|
24
|
-
async run({ args }) {
|
|
25
|
-
const root = path.resolve("src/app");
|
|
26
|
-
for (const cmdName of args.cmd) {
|
|
27
|
-
const dirPath = path.join(root, cmdName);
|
|
28
|
-
const filePath = path.join(dirPath, "index.ts");
|
|
29
|
-
if (await fs.pathExists(filePath) && !args.force) {
|
|
30
|
-
relinka(
|
|
31
|
-
"warn",
|
|
32
|
-
`\u274C Command "${cmdName}" already exists. Use --force to overwrite.`
|
|
33
|
-
);
|
|
34
|
-
continue;
|
|
35
|
-
}
|
|
36
|
-
fs.mkdirSync(dirPath, {
|
|
37
|
-
recursive: true
|
|
38
|
-
});
|
|
39
|
-
const content = generateCommandTemplate(cmdName);
|
|
40
|
-
fs.writeFileSync(filePath, content, "utf-8");
|
|
41
|
-
relinka("log", `\u2705 Created new command: ${filePath}`);
|
|
42
|
-
}
|
|
43
|
-
}
|
|
44
|
-
});
|
|
45
|
-
function generateCommandTemplate(cmdName) {
|
|
46
|
-
return `import { relinka } from "@reliverse/relinka";
|
|
47
|
-
import { defineCommand } from "@reliverse/rempts";
|
|
48
|
-
export default defineCommand({
|
|
49
|
-
meta: {
|
|
50
|
-
name: "${cmdName}",
|
|
51
|
-
version: "1.0.0",
|
|
52
|
-
description: "Describe what ${cmdName} command does.",
|
|
53
|
-
},
|
|
54
|
-
args: {
|
|
55
|
-
exampleArg: {
|
|
56
|
-
type: "string",
|
|
57
|
-
default: "defaultValue",
|
|
58
|
-
description: "An example argument",
|
|
59
|
-
},
|
|
60
|
-
},
|
|
61
|
-
async run({ args }) {
|
|
62
|
-
relinka("log", "Command '${cmdName}' executed.");
|
|
63
|
-
relinka("log", "Received args:", args);
|
|
64
|
-
},
|
|
65
|
-
});
|
|
66
|
-
`;
|
|
67
|
-
}
|