-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
10 changed files
with
146 additions
and
13 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
interface BaseObj<T = string | number> { | ||
[key: string]: T | ||
} |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
{ | ||
"name": "local-cli", | ||
"version": "1.0.0", | ||
"description": "本地执行脚手架,通过脚手架来设置一些东西", | ||
"main": "index.js", | ||
"author": "lammu", | ||
"type": "module", | ||
"bin": { | ||
"local-cli": "./dist/index.esm.js" | ||
}, | ||
"dependencies": { | ||
"fs-extra": "^10.0.0", | ||
"js-yaml": "^4.1.0", | ||
"zod": "^3.22.4" | ||
}, | ||
"devDependencies": { | ||
"@rollup/plugin-commonjs": "^25.0.2", | ||
"@rollup/plugin-node-resolve": "^15.1.0", | ||
"@rollup/plugin-typescript": "^11.1.1", | ||
"@types/fs-extra": "^9.0.13", | ||
"@types/js-yaml": "^4.0.9", | ||
"@types/node": "^20.10.0", | ||
"rollup": "^3.25.2", | ||
"rollup-plugin-cleanup": "^3.2.1", | ||
"rollup-plugin-terser": "^7.0.2", | ||
"tslib": "^2.5.3", | ||
"typescript": "^5.1.3" | ||
}, | ||
"license": "MIT", | ||
"scripts": { | ||
"dev": "rollup -w -c", | ||
"build:lib": "tsc -b ./tsconfig.lib.json", | ||
"build": "rollup -c" | ||
} | ||
} |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
import resolve from "@rollup/plugin-node-resolve"; | ||
import commonjs from "@rollup/plugin-commonjs"; | ||
import typescript from "@rollup/plugin-typescript"; | ||
import { terser } from "rollup-plugin-terser"; | ||
import cleanup from "rollup-plugin-cleanup"; | ||
|
||
export default [ | ||
{ | ||
input: "./src/index.ts", | ||
output: { | ||
dir: "dist", | ||
format: "cjs", | ||
entryFileNames: "[name].cjs.js", | ||
}, | ||
plugins: [resolve(), commonjs(), typescript(), terser(), cleanup()], | ||
}, | ||
{ | ||
input: "./src/index.ts", | ||
output: { | ||
dir: "dist", | ||
format: "esm", | ||
entryFileNames: "[name].esm.js", | ||
}, | ||
plugins: [resolve(), commonjs(), typescript(), terser(), cleanup()], | ||
}, | ||
]; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
#!/usr/bin/env node | ||
import * as yaml from 'js-yaml'; | ||
import * as fs from 'fs'; | ||
import * as fse from 'fs-extra'; | ||
import { ConfigDto, ConfigZod } from './types'; | ||
|
||
// process.cwd() | ||
|
||
function main(config: ConfigDto) { | ||
/** | ||
* 设置软链接 | ||
*/ | ||
if (config.symlink) { | ||
for (let i = 0; i < config.symlink.length; i++) { | ||
const link = config.symlink[i]; | ||
fse.ensureSymlinkSync(link.from, link.to); | ||
} | ||
} | ||
/** | ||
* 设置硬链接 | ||
*/ | ||
} | ||
|
||
try { | ||
console.log('>>> local-cli脚手架启动'); | ||
const config = yaml.load(fs.readFileSync('./monorepo.yaml', 'utf8')) as ConfigDto; | ||
main(ConfigZod.parse(config)); | ||
console.log('>>> local-cli脚手架结束'); | ||
} catch (e) { | ||
console.log(e); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
import { z } from 'zod'; | ||
|
||
/** 链接配置 */ | ||
const linkZod = z.object({ | ||
/** 源目录 */ | ||
from: z.string(), | ||
/** 目标目录 */ | ||
to: z.string(), | ||
}) | ||
|
||
export const ConfigZod = z.object({ | ||
/** 软链接配置 */ | ||
symlink: z.array(linkZod).optional(), | ||
/** 硬链接配置 */ | ||
hardlink: z.array(linkZod).optional(), | ||
}) | ||
export type ConfigDto = z.infer<typeof ConfigZod>; | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
{ | ||
"compilerOptions": { | ||
"module": "esnext", // esnext, es2020 | ||
"target": "es5", | ||
"lib": ["esnext", "dom"], | ||
"outDir": "dist", | ||
"strict": true, | ||
"sourceMap": false, | ||
"declaration": true, | ||
"declarationDir": "dist/types", | ||
"skipLibCheck": true, | ||
"moduleResolution": "Node", | ||
"baseUrl": "./", | ||
"paths": {}, | ||
}, | ||
"include": ["src/**/*.ts"], | ||
"exclude": ["node_modules"], | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
{ | ||
"compilerOptions": { | ||
"module": "esnext", // esnext, es2020 | ||
"target": "es5", | ||
"strict": true, | ||
"lib": ["esnext", "dom"], | ||
"outDir": "lib", | ||
"sourceMap": false, | ||
"declaration": true, | ||
"skipLibCheck": true | ||
}, | ||
"include": ["src/**/*.ts"], | ||
"exclude": ["node_modules"] | ||
} |