@reliverse/dler 2.1.5 → 2.1.7
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/cli.d.ts +0 -1
- package/dist/cli.js +0 -1
- package/dist/cmds/{init → escape}/cmd.d.ts +0 -1
- package/dist/cmds/escape/cmd.js +81 -0
- package/dist/cmds/publish/cmd.d.ts +0 -1
- package/dist/cmds/publish/cmd.js +0 -1
- package/dist/cmds/shell/cmd.d.ts +0 -1
- package/dist/cmds/shell/cmd.js +0 -1
- package/package.json +12 -11
- package/dist/cmds/init/cmd.js +0 -51
- package/dist/cmds/init/impl/config.d.ts +0 -45
- package/dist/cmds/init/impl/config.js +0 -99
- package/dist/cmds/init/impl/generators.d.ts +0 -6
- package/dist/cmds/init/impl/generators.js +0 -178
- package/dist/cmds/init/impl/prompts.d.ts +0 -2
- package/dist/cmds/init/impl/prompts.js +0 -98
- package/dist/cmds/init/impl/types.d.ts +0 -22
- package/dist/cmds/init/impl/types.js +0 -0
- package/dist/cmds/init/impl/utils.d.ts +0 -4
- package/dist/cmds/init/impl/utils.js +0 -11
- package/dist/cmds/init/impl/validators.d.ts +0 -4
- package/dist/cmds/init/impl/validators.js +0 -42
- package/dist/cmds/integrate/cmd.d.ts +0 -3
- package/dist/cmds/integrate/cmd.js +0 -67
- package/dist/cmds/integrate/impl.d.ts +0 -7
- package/dist/cmds/integrate/impl.js +0 -127
- package/dist/cmds/integrate/integrations/base.d.ts +0 -13
- package/dist/cmds/integrate/integrations/base.js +0 -41
- package/dist/cmds/integrate/integrations/nextjs.d.ts +0 -16
- package/dist/cmds/integrate/integrations/nextjs.js +0 -166
- package/dist/cmds/integrate/integrations/registry.d.ts +0 -7
- package/dist/cmds/integrate/integrations/registry.js +0 -31
- package/dist/cmds/integrate/integrations/ultracite.d.ts +0 -11
- package/dist/cmds/integrate/integrations/ultracite.js +0 -40
- package/dist/cmds/integrate/types.d.ts +0 -39
- package/dist/cmds/integrate/types.js +0 -0
- package/dist/cmds/integrate/utils/biome.d.ts +0 -4
- package/dist/cmds/integrate/utils/biome.js +0 -140
- package/dist/cmds/integrate/utils/context.d.ts +0 -3
- package/dist/cmds/integrate/utils/context.js +0 -116
- package/dist/cmds/integrate/utils/temp.d.ts +0 -3
- package/dist/cmds/integrate/utils/temp.js +0 -36
package/dist/cli.d.ts
CHANGED
package/dist/cli.js
CHANGED
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
import { existsSync, statSync } from "node:fs";
|
|
2
|
+
import { resolve } from "node:path";
|
|
3
|
+
import {
|
|
4
|
+
convertFile,
|
|
5
|
+
findEscapedFiles,
|
|
6
|
+
findFiles,
|
|
7
|
+
getOutputPath,
|
|
8
|
+
getUnescapeOutputPath,
|
|
9
|
+
parseMap,
|
|
10
|
+
unconvertFile
|
|
11
|
+
} from "@reliverse/dler-escaper";
|
|
12
|
+
import { defineArgs, defineCommand } from "@reliverse/dler-launcher";
|
|
13
|
+
import { logger } from "@reliverse/dler-logger";
|
|
14
|
+
export default defineCommand({
|
|
15
|
+
meta: {
|
|
16
|
+
name: "escape",
|
|
17
|
+
description: "Convert files (.md, .mdc, .mdx, .json, .jsonc, .toml) to TypeScript with proper escaping",
|
|
18
|
+
examples: [
|
|
19
|
+
'escape --input "path/to/file.md"',
|
|
20
|
+
'escape --input "path/to/dir"',
|
|
21
|
+
'escape --input "path/to/dir" --map "md:.rules,path/to/file json:*.markdown"',
|
|
22
|
+
'escape --input "path/to/dir-escaped" --unescape'
|
|
23
|
+
]
|
|
24
|
+
},
|
|
25
|
+
args: defineArgs({
|
|
26
|
+
input: {
|
|
27
|
+
type: "string",
|
|
28
|
+
required: true,
|
|
29
|
+
description: "Path to file or directory to process"
|
|
30
|
+
},
|
|
31
|
+
map: {
|
|
32
|
+
type: "string",
|
|
33
|
+
description: 'Custom file mapping format: "md:.rules,path/to/file json:*.jsonc"'
|
|
34
|
+
},
|
|
35
|
+
recursive: {
|
|
36
|
+
type: "boolean",
|
|
37
|
+
description: "Process directories recursively (default: true)"
|
|
38
|
+
},
|
|
39
|
+
unescape: {
|
|
40
|
+
type: "boolean",
|
|
41
|
+
description: "Reverse the escape operation (convert .ts files back to original format)"
|
|
42
|
+
}
|
|
43
|
+
}),
|
|
44
|
+
run: async ({ args }) => {
|
|
45
|
+
const inputPath = resolve(args.input);
|
|
46
|
+
if (!existsSync(inputPath)) {
|
|
47
|
+
throw new Error(`Input path does not exist: ${inputPath}`);
|
|
48
|
+
}
|
|
49
|
+
const inputStat = statSync(inputPath);
|
|
50
|
+
const isDirectory = inputStat.isDirectory();
|
|
51
|
+
const recursive = args.recursive ?? true;
|
|
52
|
+
if (args.unescape) {
|
|
53
|
+
const files = await findEscapedFiles(inputPath, recursive);
|
|
54
|
+
if (files.length === 0) {
|
|
55
|
+
logger.warn("No escaped files found to process");
|
|
56
|
+
return;
|
|
57
|
+
}
|
|
58
|
+
logger.info(`Processing ${files.length} file(s)...`);
|
|
59
|
+
for (const file of files) {
|
|
60
|
+
const outputPath = getUnescapeOutputPath(inputPath, file, isDirectory);
|
|
61
|
+
await unconvertFile(file, outputPath);
|
|
62
|
+
logger.info(`Unescaped: ${file} \u2192 ${outputPath}`);
|
|
63
|
+
}
|
|
64
|
+
logger.info("Unescape complete!");
|
|
65
|
+
} else {
|
|
66
|
+
const mappings = args.map ? parseMap(args.map) : null;
|
|
67
|
+
const files = await findFiles(inputPath, mappings, recursive);
|
|
68
|
+
if (files.length === 0) {
|
|
69
|
+
logger.warn("No files found to process");
|
|
70
|
+
return;
|
|
71
|
+
}
|
|
72
|
+
logger.info(`Processing ${files.length} file(s)...`);
|
|
73
|
+
for (const file of files) {
|
|
74
|
+
const outputPath = getOutputPath(inputPath, file, isDirectory);
|
|
75
|
+
await convertFile(file, outputPath);
|
|
76
|
+
logger.info(`Converted: ${file} \u2192 ${outputPath}`);
|
|
77
|
+
}
|
|
78
|
+
logger.info("Conversion complete!");
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
});
|
package/dist/cmds/publish/cmd.js
CHANGED
package/dist/cmds/shell/cmd.d.ts
CHANGED
package/dist/cmds/shell/cmd.js
CHANGED
package/package.json
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
"name": "@reliverse/dler",
|
|
3
3
|
"description": "@reliverse/dler is a framework which helps TypeScript and JavaScript developers create their libraries and CLI tools. It provides ready-to-use primitives, so you don't have to write them from scratch.",
|
|
4
4
|
"author": "reliverse",
|
|
5
|
-
"version": "2.1.
|
|
5
|
+
"version": "2.1.7",
|
|
6
6
|
"private": false,
|
|
7
7
|
"type": "module",
|
|
8
8
|
"bin": {
|
|
@@ -13,16 +13,17 @@
|
|
|
13
13
|
"semver": "^7.7.3",
|
|
14
14
|
"lookpath": "^1.2.3",
|
|
15
15
|
"clipboardy": "^5.0.0",
|
|
16
|
-
"@reliverse/dler-
|
|
17
|
-
"@reliverse/dler-
|
|
18
|
-
"@reliverse/dler-
|
|
19
|
-
"@reliverse/dler-
|
|
20
|
-
"@reliverse/dler-
|
|
21
|
-
"@reliverse/dler-
|
|
22
|
-
"@reliverse/dler-
|
|
23
|
-
"@reliverse/dler-
|
|
24
|
-
"@reliverse/dler-
|
|
25
|
-
"@reliverse/dler-
|
|
16
|
+
"@reliverse/dler-escaper": "2.1.7",
|
|
17
|
+
"@reliverse/dler-publish": "2.1.7",
|
|
18
|
+
"@reliverse/dler-bump": "2.1.7",
|
|
19
|
+
"@reliverse/dler-build": "2.1.7",
|
|
20
|
+
"@reliverse/dler-logger": "2.1.7",
|
|
21
|
+
"@reliverse/dler-matcher": "2.1.7",
|
|
22
|
+
"@reliverse/dler-launcher": "2.1.7",
|
|
23
|
+
"@reliverse/dler-prompt": "2.1.7",
|
|
24
|
+
"@reliverse/dler-helpers": "2.1.7",
|
|
25
|
+
"@reliverse/dler-pkg-tsc": "2.1.7",
|
|
26
|
+
"@reliverse/dler-mapper": "2.1.7"
|
|
26
27
|
},
|
|
27
28
|
"keywords": [
|
|
28
29
|
"dler",
|
package/dist/cmds/init/cmd.js
DELETED
|
@@ -1,51 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env bun
|
|
2
|
-
import { defineArgs, defineCommand } from "@reliverse/dler-launcher";
|
|
3
|
-
import { logger } from "@reliverse/dler-logger";
|
|
4
|
-
import { $ } from "bun";
|
|
5
|
-
import {
|
|
6
|
-
generateAllPackages,
|
|
7
|
-
generateRootFiles,
|
|
8
|
-
generateRootPackageJson
|
|
9
|
-
} from "./impl/generators.js";
|
|
10
|
-
import { promptMonorepoConfig } from "./impl/prompts.js";
|
|
11
|
-
function getCurrentWorkingDirectory() {
|
|
12
|
-
return process.cwd();
|
|
13
|
-
}
|
|
14
|
-
export default defineCommand({
|
|
15
|
-
meta: {
|
|
16
|
-
name: "init",
|
|
17
|
-
description: "Initialize a new monorepo"
|
|
18
|
-
},
|
|
19
|
-
args: defineArgs({
|
|
20
|
-
name: {
|
|
21
|
-
type: "string",
|
|
22
|
-
description: "Current working directory",
|
|
23
|
-
default: getCurrentWorkingDirectory()
|
|
24
|
-
}
|
|
25
|
-
}),
|
|
26
|
-
run: async () => {
|
|
27
|
-
try {
|
|
28
|
-
const config = await promptMonorepoConfig();
|
|
29
|
-
logger.info("\n\u{1F528} Generating monorepo structure...\n");
|
|
30
|
-
await generateRootPackageJson(config);
|
|
31
|
-
await generateRootFiles(config);
|
|
32
|
-
await generateAllPackages(config);
|
|
33
|
-
logger.info("\n\u{1F4E6} Installing dependencies...\n");
|
|
34
|
-
await $`bun install`.cwd(config.rootPath);
|
|
35
|
-
logger.success("\n\u2705 Monorepo created successfully!");
|
|
36
|
-
logger.success(`
|
|
37
|
-
\u{1F4C1} Location: ${config.rootPath}`);
|
|
38
|
-
logger.success("\nTo get started:");
|
|
39
|
-
logger.log(` cd ${config.rootPath}`);
|
|
40
|
-
logger.log(" bun --filter '*' dev\n");
|
|
41
|
-
} catch (error) {
|
|
42
|
-
logger.error("\n\u274C Error creating monorepo:");
|
|
43
|
-
if (error instanceof Error) {
|
|
44
|
-
logger.error(error.message);
|
|
45
|
-
} else {
|
|
46
|
-
logger.error(String(error));
|
|
47
|
-
}
|
|
48
|
-
process.exit(1);
|
|
49
|
-
}
|
|
50
|
-
}
|
|
51
|
-
});
|
|
@@ -1,45 +0,0 @@
|
|
|
1
|
-
import type { CatalogDependency } from "./types.js";
|
|
2
|
-
export declare const DEFAULT_VERSION = "0.1.0";
|
|
3
|
-
export declare const DEFAULT_LICENSE = "MIT";
|
|
4
|
-
export declare const WORKSPACES: {
|
|
5
|
-
readonly PACKAGES: "packages";
|
|
6
|
-
readonly TSCONFIG: "packages/tsconfig";
|
|
7
|
-
};
|
|
8
|
-
export declare const DEFAULT_CATALOG: readonly CatalogDependency[];
|
|
9
|
-
export declare const TSCONFIG_PRESETS: {
|
|
10
|
-
readonly base: {
|
|
11
|
-
readonly $schema: "https://json.schemastore.org/tsconfig";
|
|
12
|
-
readonly compilerOptions: {
|
|
13
|
-
readonly lib: readonly ["ESNext"];
|
|
14
|
-
readonly target: "ESNext";
|
|
15
|
-
readonly module: "ESNext";
|
|
16
|
-
readonly moduleDetection: "force";
|
|
17
|
-
readonly allowJs: true;
|
|
18
|
-
readonly moduleResolution: "Bundler";
|
|
19
|
-
readonly allowImportingTsExtensions: true;
|
|
20
|
-
readonly verbatimModuleSyntax: true;
|
|
21
|
-
readonly noEmit: true;
|
|
22
|
-
readonly strict: true;
|
|
23
|
-
readonly skipLibCheck: true;
|
|
24
|
-
readonly noFallthroughCasesInSwitch: true;
|
|
25
|
-
readonly noUnusedLocals: false;
|
|
26
|
-
readonly noUnusedParameters: false;
|
|
27
|
-
readonly noPropertyAccessFromIndexSignature: false;
|
|
28
|
-
readonly esModuleInterop: true;
|
|
29
|
-
readonly isolatedModules: true;
|
|
30
|
-
};
|
|
31
|
-
};
|
|
32
|
-
readonly strict: {
|
|
33
|
-
readonly $schema: "https://json.schemastore.org/tsconfig";
|
|
34
|
-
readonly extends: "./base.json";
|
|
35
|
-
readonly compilerOptions: {
|
|
36
|
-
readonly noUncheckedIndexedAccess: true;
|
|
37
|
-
readonly noUnusedLocals: true;
|
|
38
|
-
readonly noUnusedParameters: true;
|
|
39
|
-
};
|
|
40
|
-
};
|
|
41
|
-
};
|
|
42
|
-
export declare const ROOT_FILES: {
|
|
43
|
-
readonly GITIGNORE: "# Dependencies\nnode_modules/\n\n# Build outputs\ndist/\nout/\n*.tsbuildinfo\n\n# Environment\n.env\n.env*.local\n\n# IDE\n.vscode/\n.idea/\n*.swp\n*.swo\n*~\n\n# OS\n.DS_Store\nThumbs.db\n\n# Logs\n*.log\n";
|
|
44
|
-
readonly README: (name: string) => string;
|
|
45
|
-
};
|
|
@@ -1,99 +0,0 @@
|
|
|
1
|
-
export const DEFAULT_VERSION = "0.1.0";
|
|
2
|
-
export const DEFAULT_LICENSE = "MIT";
|
|
3
|
-
export const WORKSPACES = {
|
|
4
|
-
PACKAGES: "packages",
|
|
5
|
-
TSCONFIG: "packages/tsconfig"
|
|
6
|
-
};
|
|
7
|
-
export const DEFAULT_CATALOG = [
|
|
8
|
-
{ name: "typescript", version: "^5.7.2" },
|
|
9
|
-
{ name: "@types/bun", version: "^1.3.0" }
|
|
10
|
-
];
|
|
11
|
-
export const TSCONFIG_PRESETS = {
|
|
12
|
-
base: {
|
|
13
|
-
$schema: "https://json.schemastore.org/tsconfig",
|
|
14
|
-
compilerOptions: {
|
|
15
|
-
lib: ["ESNext"],
|
|
16
|
-
target: "ESNext",
|
|
17
|
-
module: "ESNext",
|
|
18
|
-
moduleDetection: "force",
|
|
19
|
-
allowJs: true,
|
|
20
|
-
moduleResolution: "Bundler",
|
|
21
|
-
allowImportingTsExtensions: true,
|
|
22
|
-
verbatimModuleSyntax: true,
|
|
23
|
-
noEmit: true,
|
|
24
|
-
strict: true,
|
|
25
|
-
skipLibCheck: true,
|
|
26
|
-
noFallthroughCasesInSwitch: true,
|
|
27
|
-
noUnusedLocals: false,
|
|
28
|
-
noUnusedParameters: false,
|
|
29
|
-
noPropertyAccessFromIndexSignature: false,
|
|
30
|
-
esModuleInterop: true,
|
|
31
|
-
isolatedModules: true
|
|
32
|
-
}
|
|
33
|
-
},
|
|
34
|
-
strict: {
|
|
35
|
-
$schema: "https://json.schemastore.org/tsconfig",
|
|
36
|
-
extends: "./base.json",
|
|
37
|
-
compilerOptions: {
|
|
38
|
-
noUncheckedIndexedAccess: true,
|
|
39
|
-
noUnusedLocals: true,
|
|
40
|
-
noUnusedParameters: true
|
|
41
|
-
}
|
|
42
|
-
}
|
|
43
|
-
};
|
|
44
|
-
export const ROOT_FILES = {
|
|
45
|
-
GITIGNORE: `# Dependencies
|
|
46
|
-
node_modules/
|
|
47
|
-
|
|
48
|
-
# Build outputs
|
|
49
|
-
dist/
|
|
50
|
-
out/
|
|
51
|
-
*.tsbuildinfo
|
|
52
|
-
|
|
53
|
-
# Environment
|
|
54
|
-
.env
|
|
55
|
-
.env*.local
|
|
56
|
-
|
|
57
|
-
# IDE
|
|
58
|
-
.vscode/
|
|
59
|
-
.idea/
|
|
60
|
-
*.swp
|
|
61
|
-
*.swo
|
|
62
|
-
*~
|
|
63
|
-
|
|
64
|
-
# OS
|
|
65
|
-
.DS_Store
|
|
66
|
-
Thumbs.db
|
|
67
|
-
|
|
68
|
-
# Logs
|
|
69
|
-
*.log
|
|
70
|
-
`,
|
|
71
|
-
README: (name) => `# ${name}
|
|
72
|
-
|
|
73
|
-
A Bun monorepo created with the monorepo bootstrapper.
|
|
74
|
-
|
|
75
|
-
## Getting Started
|
|
76
|
-
|
|
77
|
-
\`\`\`bash
|
|
78
|
-
bun install
|
|
79
|
-
\`\`\`
|
|
80
|
-
|
|
81
|
-
## Workspaces
|
|
82
|
-
|
|
83
|
-
This monorepo was generated by dler init. It uses bun workspaces to manage multiple packages.
|
|
84
|
-
|
|
85
|
-
## Scripts
|
|
86
|
-
|
|
87
|
-
Run scripts across all workspaces:
|
|
88
|
-
|
|
89
|
-
\`\`\`bash
|
|
90
|
-
bun --filter '*' <script>
|
|
91
|
-
\`\`\`
|
|
92
|
-
|
|
93
|
-
Run scripts for specific packages:
|
|
94
|
-
|
|
95
|
-
\`\`\`bash
|
|
96
|
-
bun --filter <package-name> <script>
|
|
97
|
-
\`\`\`
|
|
98
|
-
`
|
|
99
|
-
};
|
|
@@ -1,6 +0,0 @@
|
|
|
1
|
-
import type { MonorepoConfig, PackageInfo } from "./types.js";
|
|
2
|
-
export declare const generateRootPackageJson: (config: MonorepoConfig) => Promise<void>;
|
|
3
|
-
export declare const generateRootFiles: (config: MonorepoConfig) => Promise<void>;
|
|
4
|
-
export declare const generateTsconfigPackage: (config: MonorepoConfig) => Promise<void>;
|
|
5
|
-
export declare const generatePackage: (config: MonorepoConfig, pkg: PackageInfo) => Promise<void>;
|
|
6
|
-
export declare const generateAllPackages: (config: MonorepoConfig) => Promise<void>;
|
|
@@ -1,178 +0,0 @@
|
|
|
1
|
-
import { writeJsonFile, writeTextFile } from "@reliverse/dler-helpers";
|
|
2
|
-
import { logger } from "@reliverse/dler-logger";
|
|
3
|
-
import {
|
|
4
|
-
DEFAULT_CATALOG,
|
|
5
|
-
ROOT_FILES,
|
|
6
|
-
TSCONFIG_PRESETS,
|
|
7
|
-
WORKSPACES
|
|
8
|
-
} from "./config.js";
|
|
9
|
-
import {
|
|
10
|
-
createFullPath,
|
|
11
|
-
ensureDir,
|
|
12
|
-
fileExists,
|
|
13
|
-
getWorkspaceScope
|
|
14
|
-
} from "./utils.js";
|
|
15
|
-
export const generateRootPackageJson = async (config) => {
|
|
16
|
-
const packageJsonPath = createFullPath(config.rootPath, "package.json");
|
|
17
|
-
const alreadyExists = await fileExists(packageJsonPath);
|
|
18
|
-
if (alreadyExists) {
|
|
19
|
-
logger.info("\u{1F4DD} Updating existing root package.json...");
|
|
20
|
-
const existingContent = await Bun.file(packageJsonPath).json();
|
|
21
|
-
const workspaces = /* @__PURE__ */ new Set([
|
|
22
|
-
...existingContent.workspaces?.packages || [],
|
|
23
|
-
...getWorkspacePatterns(config)
|
|
24
|
-
]);
|
|
25
|
-
const catalog = {
|
|
26
|
-
...existingContent.workspaces?.catalog || {},
|
|
27
|
-
...Object.fromEntries(
|
|
28
|
-
DEFAULT_CATALOG.map((dep) => [dep.name, dep.version])
|
|
29
|
-
)
|
|
30
|
-
};
|
|
31
|
-
const updatedPackageJson = {
|
|
32
|
-
...existingContent,
|
|
33
|
-
// Persist core metadata from current config (overwrite with user's latest answers)
|
|
34
|
-
name: config.name,
|
|
35
|
-
version: config.version,
|
|
36
|
-
description: config.description,
|
|
37
|
-
...config.author && { author: config.author },
|
|
38
|
-
...config.license && { license: config.license },
|
|
39
|
-
workspaces: {
|
|
40
|
-
...existingContent.workspaces,
|
|
41
|
-
packages: Array.from(workspaces).sort(),
|
|
42
|
-
catalog
|
|
43
|
-
}
|
|
44
|
-
};
|
|
45
|
-
await writeJsonFile(packageJsonPath, updatedPackageJson);
|
|
46
|
-
} else {
|
|
47
|
-
logger.info("\u{1F4DD} Creating root package.json...");
|
|
48
|
-
const packageJson = {
|
|
49
|
-
name: config.name,
|
|
50
|
-
version: config.version,
|
|
51
|
-
description: config.description,
|
|
52
|
-
private: true,
|
|
53
|
-
workspaces: {
|
|
54
|
-
packages: getWorkspacePatterns(config),
|
|
55
|
-
catalog: Object.fromEntries(
|
|
56
|
-
DEFAULT_CATALOG.map((dep) => [dep.name, dep.version])
|
|
57
|
-
)
|
|
58
|
-
},
|
|
59
|
-
scripts: {
|
|
60
|
-
check: "bun typecheck && bun lint && bun format",
|
|
61
|
-
typecheck: "tsc --noEmit",
|
|
62
|
-
lint: "biome check .",
|
|
63
|
-
"lint:fix": "biome check --write .",
|
|
64
|
-
format: "biome format --write ."
|
|
65
|
-
},
|
|
66
|
-
devDependencies: {
|
|
67
|
-
"@biomejs/biome": "catalog:",
|
|
68
|
-
typescript: "catalog:",
|
|
69
|
-
"@types/bun": "catalog:"
|
|
70
|
-
},
|
|
71
|
-
...config.author && { author: config.author },
|
|
72
|
-
...config.license && { license: config.license }
|
|
73
|
-
};
|
|
74
|
-
await writeJsonFile(packageJsonPath, packageJson);
|
|
75
|
-
}
|
|
76
|
-
};
|
|
77
|
-
const getWorkspacePatterns = (config) => {
|
|
78
|
-
const patterns = /* @__PURE__ */ new Set();
|
|
79
|
-
for (const pkg of config.packages) {
|
|
80
|
-
patterns.add(`${pkg.workspace}/*`);
|
|
81
|
-
}
|
|
82
|
-
return Array.from(patterns).sort();
|
|
83
|
-
};
|
|
84
|
-
export const generateRootFiles = async (config) => {
|
|
85
|
-
logger.info("\u{1F4C4} Creating root files...");
|
|
86
|
-
const gitignorePath = createFullPath(config.rootPath, ".gitignore");
|
|
87
|
-
if (!await fileExists(gitignorePath)) {
|
|
88
|
-
await writeTextFile(gitignorePath, ROOT_FILES.GITIGNORE);
|
|
89
|
-
}
|
|
90
|
-
const readmePath = createFullPath(config.rootPath, "README.md");
|
|
91
|
-
if (!await fileExists(readmePath)) {
|
|
92
|
-
await writeTextFile(readmePath, ROOT_FILES.README(config.name));
|
|
93
|
-
}
|
|
94
|
-
};
|
|
95
|
-
export const generateTsconfigPackage = async (config) => {
|
|
96
|
-
logger.info("\u{1F4E6} Creating tsconfig package...");
|
|
97
|
-
const tsconfigPath = createFullPath(config.rootPath, WORKSPACES.TSCONFIG);
|
|
98
|
-
await ensureDir(tsconfigPath);
|
|
99
|
-
const packageJsonPath = createFullPath(tsconfigPath, "package.json");
|
|
100
|
-
if (!await fileExists(packageJsonPath)) {
|
|
101
|
-
const scope = getWorkspaceScope(WORKSPACES.PACKAGES);
|
|
102
|
-
const packageJson = {
|
|
103
|
-
name: `${scope}tsconfig`,
|
|
104
|
-
version: "0.0.0",
|
|
105
|
-
private: true,
|
|
106
|
-
description: "Shared TypeScript configuration"
|
|
107
|
-
};
|
|
108
|
-
await writeJsonFile(packageJsonPath, packageJson);
|
|
109
|
-
}
|
|
110
|
-
for (const [name, content] of Object.entries(TSCONFIG_PRESETS)) {
|
|
111
|
-
const presetPath = createFullPath(tsconfigPath, `${name}.json`);
|
|
112
|
-
if (!await fileExists(presetPath)) {
|
|
113
|
-
await writeJsonFile(presetPath, content);
|
|
114
|
-
}
|
|
115
|
-
}
|
|
116
|
-
};
|
|
117
|
-
export const generatePackage = async (config, pkg) => {
|
|
118
|
-
const packagePath = createFullPath(config.rootPath, pkg.workspace, pkg.name);
|
|
119
|
-
logger.info(`\u{1F4E6} Creating package ${pkg.scope}${pkg.name}...`);
|
|
120
|
-
await ensureDir(packagePath);
|
|
121
|
-
const packageJsonPath = createFullPath(packagePath, "package.json");
|
|
122
|
-
if (!await fileExists(packageJsonPath)) {
|
|
123
|
-
const tsconfigScope = getWorkspaceScope(WORKSPACES.PACKAGES);
|
|
124
|
-
const packageJson = {
|
|
125
|
-
name: `${pkg.scope}${pkg.name}`,
|
|
126
|
-
version: "0.1.0",
|
|
127
|
-
private: true,
|
|
128
|
-
type: "module",
|
|
129
|
-
exports: {
|
|
130
|
-
".": {
|
|
131
|
-
types: "./src/mod.ts",
|
|
132
|
-
default: "./src/mod.ts"
|
|
133
|
-
}
|
|
134
|
-
},
|
|
135
|
-
scripts: {
|
|
136
|
-
dev: "bun src/mod.ts"
|
|
137
|
-
},
|
|
138
|
-
devDependencies: {
|
|
139
|
-
[`${tsconfigScope}tsconfig`]: "workspace:*",
|
|
140
|
-
typescript: "catalog:",
|
|
141
|
-
"@types/bun": "catalog:"
|
|
142
|
-
}
|
|
143
|
-
};
|
|
144
|
-
await writeJsonFile(packageJsonPath, packageJson);
|
|
145
|
-
}
|
|
146
|
-
const tsconfigPath = createFullPath(packagePath, "tsconfig.json");
|
|
147
|
-
if (!await fileExists(tsconfigPath)) {
|
|
148
|
-
const tsconfigScope = getWorkspaceScope(WORKSPACES.PACKAGES);
|
|
149
|
-
const tsconfig = {
|
|
150
|
-
extends: `${tsconfigScope}tsconfig/strict.json`,
|
|
151
|
-
compilerOptions: {
|
|
152
|
-
rootDir: ".",
|
|
153
|
-
outDir: "./dist"
|
|
154
|
-
},
|
|
155
|
-
include: ["src/**/*"],
|
|
156
|
-
exclude: ["node_modules", "dist"]
|
|
157
|
-
};
|
|
158
|
-
await writeJsonFile(tsconfigPath, tsconfig);
|
|
159
|
-
}
|
|
160
|
-
const srcPath = createFullPath(packagePath, "src");
|
|
161
|
-
await ensureDir(srcPath);
|
|
162
|
-
const indexPath = createFullPath(srcPath, "index.ts");
|
|
163
|
-
if (!await fileExists(indexPath)) {
|
|
164
|
-
const indexContent = `export const hello = (): string => {
|
|
165
|
-
return "Hello from ${pkg.scope}${pkg.name}!";
|
|
166
|
-
};
|
|
167
|
-
|
|
168
|
-
console.log(hello());
|
|
169
|
-
`;
|
|
170
|
-
await writeTextFile(indexPath, indexContent);
|
|
171
|
-
}
|
|
172
|
-
};
|
|
173
|
-
export const generateAllPackages = async (config) => {
|
|
174
|
-
await generateTsconfigPackage(config);
|
|
175
|
-
for (const pkg of config.packages) {
|
|
176
|
-
await generatePackage(config, pkg);
|
|
177
|
-
}
|
|
178
|
-
};
|
|
@@ -1,98 +0,0 @@
|
|
|
1
|
-
import { logger } from "@reliverse/dler-logger";
|
|
2
|
-
import { askQuestion } from "@reliverse/dler-prompt";
|
|
3
|
-
import { DEFAULT_LICENSE, DEFAULT_VERSION, WORKSPACES } from "./config.js";
|
|
4
|
-
import { createFullPath, fileExists, getWorkspaceScope } from "./utils.js";
|
|
5
|
-
import {
|
|
6
|
-
validateMonorepoName,
|
|
7
|
-
validatePackageName,
|
|
8
|
-
validateVersion
|
|
9
|
-
} from "./validators.js";
|
|
10
|
-
export const promptMonorepoConfig = async () => {
|
|
11
|
-
logger.info("\u{1F680} Bun Monorepo Bootstrapper\n");
|
|
12
|
-
const rootPath = process.cwd();
|
|
13
|
-
const rootPackageJsonPath = createFullPath(rootPath, "package.json");
|
|
14
|
-
const hasRootPackageJson = await fileExists(rootPackageJsonPath);
|
|
15
|
-
const existingRoot = hasRootPackageJson ? await Bun.file(rootPackageJsonPath).json().catch(() => null) : null;
|
|
16
|
-
let name = "";
|
|
17
|
-
let isValidName = false;
|
|
18
|
-
if (existingRoot && typeof existingRoot.name === "string") {
|
|
19
|
-
name = existingRoot.name;
|
|
20
|
-
isValidName = true;
|
|
21
|
-
} else {
|
|
22
|
-
while (!isValidName) {
|
|
23
|
-
name = await askQuestion("Monorepo name", "my-monorepo");
|
|
24
|
-
const validation = validateMonorepoName(name);
|
|
25
|
-
if (!validation.valid) {
|
|
26
|
-
logger.error(`\u274C ${validation.error}`);
|
|
27
|
-
continue;
|
|
28
|
-
}
|
|
29
|
-
isValidName = true;
|
|
30
|
-
}
|
|
31
|
-
}
|
|
32
|
-
const description = existingRoot && typeof existingRoot.description === "string" ? existingRoot.description : await askQuestion("Description", "A Bun monorepo project");
|
|
33
|
-
let version = "";
|
|
34
|
-
let isValidVersion = false;
|
|
35
|
-
if (existingRoot && typeof existingRoot.version === "string") {
|
|
36
|
-
version = existingRoot.version;
|
|
37
|
-
isValidVersion = true;
|
|
38
|
-
} else {
|
|
39
|
-
while (!isValidVersion) {
|
|
40
|
-
version = await askQuestion("Version", DEFAULT_VERSION);
|
|
41
|
-
const validation = validateVersion(version);
|
|
42
|
-
if (!validation.valid) {
|
|
43
|
-
logger.error(`\u274C ${validation.error}`);
|
|
44
|
-
continue;
|
|
45
|
-
}
|
|
46
|
-
isValidVersion = true;
|
|
47
|
-
}
|
|
48
|
-
}
|
|
49
|
-
const author = existingRoot && typeof existingRoot.author === "string" ? existingRoot.author : await askQuestion("Author", "");
|
|
50
|
-
const license = existingRoot && typeof existingRoot.license === "string" ? existingRoot.license : await askQuestion("License", DEFAULT_LICENSE);
|
|
51
|
-
const packages = await promptPackages();
|
|
52
|
-
return {
|
|
53
|
-
name,
|
|
54
|
-
description,
|
|
55
|
-
version,
|
|
56
|
-
author,
|
|
57
|
-
license,
|
|
58
|
-
packages,
|
|
59
|
-
rootPath
|
|
60
|
-
};
|
|
61
|
-
};
|
|
62
|
-
const promptPackages = async () => {
|
|
63
|
-
const packages = [];
|
|
64
|
-
logger.info("\n\u{1F4E6} Package Configuration");
|
|
65
|
-
logger.info(
|
|
66
|
-
"Enter package names (one per prompt). Press Enter with empty input to finish.\n"
|
|
67
|
-
);
|
|
68
|
-
let continueAdding = true;
|
|
69
|
-
let packageIndex = 1;
|
|
70
|
-
while (continueAdding) {
|
|
71
|
-
const packageName = await askQuestion(
|
|
72
|
-
`Package ${packageIndex} name (or press Enter to finish)`
|
|
73
|
-
);
|
|
74
|
-
if (!packageName) {
|
|
75
|
-
continueAdding = false;
|
|
76
|
-
continue;
|
|
77
|
-
}
|
|
78
|
-
const validation = validatePackageName(packageName);
|
|
79
|
-
if (!validation.valid) {
|
|
80
|
-
logger.error(`\u274C ${validation.error}`);
|
|
81
|
-
continue;
|
|
82
|
-
}
|
|
83
|
-
const workspace = await askQuestion(
|
|
84
|
-
"Workspace directory",
|
|
85
|
-
WORKSPACES.PACKAGES
|
|
86
|
-
);
|
|
87
|
-
const scope = getWorkspaceScope(workspace);
|
|
88
|
-
packages.push({
|
|
89
|
-
name: packageName,
|
|
90
|
-
workspace,
|
|
91
|
-
scope
|
|
92
|
-
});
|
|
93
|
-
logger.success(`\u2705 Added ${scope}${packageName}
|
|
94
|
-
`);
|
|
95
|
-
packageIndex++;
|
|
96
|
-
}
|
|
97
|
-
return packages;
|
|
98
|
-
};
|
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
export type PackageInfo = {
|
|
2
|
-
name: string;
|
|
3
|
-
workspace: string;
|
|
4
|
-
scope: string;
|
|
5
|
-
};
|
|
6
|
-
export type MonorepoConfig = {
|
|
7
|
-
name: string;
|
|
8
|
-
description: string;
|
|
9
|
-
version: string;
|
|
10
|
-
author: string;
|
|
11
|
-
license: string;
|
|
12
|
-
packages: PackageInfo[];
|
|
13
|
-
rootPath: string;
|
|
14
|
-
};
|
|
15
|
-
export type CatalogDependency = {
|
|
16
|
-
name: string;
|
|
17
|
-
version: string;
|
|
18
|
-
};
|
|
19
|
-
export type ValidationResult = {
|
|
20
|
-
valid: boolean;
|
|
21
|
-
error?: string;
|
|
22
|
-
};
|
|
File without changes
|
|
@@ -1,4 +0,0 @@
|
|
|
1
|
-
export declare const getWorkspaceScope: (workspace: string) => string;
|
|
2
|
-
export declare const ensureDir: (path: string) => Promise<void>;
|
|
3
|
-
export declare const fileExists: (path: string) => Promise<boolean>;
|
|
4
|
-
export declare const createFullPath: (...paths: string[]) => string;
|
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
import { exists, mkdir } from "node:fs/promises";
|
|
2
|
-
import { join } from "node:path";
|
|
3
|
-
export const getWorkspaceScope = (workspace) => `@${workspace.charAt(0)}/`;
|
|
4
|
-
export const ensureDir = async (path) => {
|
|
5
|
-
const dirExists = await exists(path);
|
|
6
|
-
if (!dirExists) {
|
|
7
|
-
await mkdir(path, { recursive: true });
|
|
8
|
-
}
|
|
9
|
-
};
|
|
10
|
-
export const fileExists = async (path) => exists(path);
|
|
11
|
-
export const createFullPath = (...paths) => join(...paths);
|