@icebreakers/monorepo-templates 0.1.1 → 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.
- package/assets/package.json +1 -1
- package/dist/index.d.mts +35 -7
- package/dist/index.mjs +80 -1
- package/package.json +2 -2
- package/templates/vue-lib/eslint.config.js +0 -3
- package/templates/vue-lib/package.json +2 -8
- package/templates/vue-lib/{lib → src}/HelloWorld.vue +7 -6
- package/templates/vue-lib/{lib → src}/index.ts +3 -1
- package/templates/vue-lib/src/vite-env.d.ts +0 -1
- package/templates/vue-lib/test/index.test.ts +1 -1
- package/templates/vue-lib/tsconfig.app.json +1 -8
- package/templates/vue-lib/tsconfig.test.json +0 -3
- package/templates/vue-lib/vite.config.ts +2 -12
- package/templates/vue-lib/vite.shared.config.ts +0 -1
- package/templates/vue-lib/index.html +0 -13
- package/templates/vue-lib/src/App.vue +0 -9
- package/templates/vue-lib/src/main.ts +0 -8
- package/templates/vue-lib/src/pages/index.vue +0 -7
- package/templates/vue-lib/src/router/index.ts +0 -11
- package/templates/vue-lib/src/style.css +0 -1
package/assets/package.json
CHANGED
package/dist/index.d.mts
CHANGED
|
@@ -4,6 +4,18 @@ import input from "@inquirer/input";
|
|
|
4
4
|
import select from "@inquirer/select";
|
|
5
5
|
import { Command, program } from "commander";
|
|
6
6
|
|
|
7
|
+
//#region src/types.d.ts
|
|
8
|
+
interface TemplateChoice {
|
|
9
|
+
key: string;
|
|
10
|
+
label: string;
|
|
11
|
+
source: string;
|
|
12
|
+
target: string;
|
|
13
|
+
}
|
|
14
|
+
interface TemplateDefinition {
|
|
15
|
+
source: string;
|
|
16
|
+
target: string;
|
|
17
|
+
}
|
|
18
|
+
//#endregion
|
|
7
19
|
//#region src/paths.d.ts
|
|
8
20
|
declare const packageDir: string;
|
|
9
21
|
declare const templatesDir: string;
|
|
@@ -17,6 +29,28 @@ interface PrepareAssetsOptions {
|
|
|
17
29
|
}
|
|
18
30
|
declare function prepareAssets(options?: PrepareAssetsOptions): Promise<void>;
|
|
19
31
|
//#endregion
|
|
32
|
+
//#region src/scaffold.d.ts
|
|
33
|
+
type TargetMode = 'prepare' | 'ensure' | 'skip';
|
|
34
|
+
interface ScaffoldTemplateOptions {
|
|
35
|
+
sourceDir: string;
|
|
36
|
+
targetDir: string;
|
|
37
|
+
ensureTargetDir?: boolean;
|
|
38
|
+
filter?: (src: string) => boolean;
|
|
39
|
+
renameEntry?: (name: string) => string;
|
|
40
|
+
skipRootBasenames?: string[];
|
|
41
|
+
}
|
|
42
|
+
interface ScaffoldWorkspaceOptions {
|
|
43
|
+
targetDir: string;
|
|
44
|
+
templateKeys?: string[];
|
|
45
|
+
assetsDir?: string;
|
|
46
|
+
templatesDir?: string;
|
|
47
|
+
includeAssets?: boolean;
|
|
48
|
+
targetMode?: TargetMode;
|
|
49
|
+
force?: boolean;
|
|
50
|
+
}
|
|
51
|
+
declare function scaffoldTemplate(options: ScaffoldTemplateOptions): Promise<void>;
|
|
52
|
+
declare function scaffoldWorkspace(options: ScaffoldWorkspaceOptions): Promise<void>;
|
|
53
|
+
//#endregion
|
|
20
54
|
//#region src/utils/command.d.ts
|
|
21
55
|
interface RunCommandOptions {
|
|
22
56
|
cwd?: string;
|
|
@@ -33,12 +67,6 @@ declare function shouldSkipTemplatePath(rootDir: string, targetPath: string): bo
|
|
|
33
67
|
declare function createTemplateCopyFilter(rootDir: string): (src: string) => boolean;
|
|
34
68
|
//#endregion
|
|
35
69
|
//#region src/index.d.ts
|
|
36
|
-
interface TemplateChoice {
|
|
37
|
-
key: string;
|
|
38
|
-
label: string;
|
|
39
|
-
source: string;
|
|
40
|
-
target: string;
|
|
41
|
-
}
|
|
42
70
|
declare const templateChoices: TemplateChoice[];
|
|
43
71
|
declare const assetTargets: string[];
|
|
44
72
|
declare const getAssetTargets: (core?: boolean) => string[];
|
|
@@ -46,4 +74,4 @@ declare const templateSourceMap: Record<string, string>;
|
|
|
46
74
|
declare const templateTargetMap: Record<string, string>;
|
|
47
75
|
declare const templateMap: Record<string, string>;
|
|
48
76
|
//#endregion
|
|
49
|
-
export { Command, TemplateChoice, assetTargets, assetsDir, checkbox, createTemplateCopyFilter, execaCommand, getAssetTargets, input, isGitignoreFile, packageDir, prepareAssets, program, runCommand, select, shouldSkipTemplatePath, skeletonDir, templateChoices, templateMap, templateSourceMap, templateTargetMap, templatesDir, toPublishGitignorePath, toWorkspaceGitignorePath };
|
|
77
|
+
export { Command, type TemplateChoice, type TemplateDefinition, assetTargets, assetsDir, checkbox, createTemplateCopyFilter, execaCommand, getAssetTargets, input, isGitignoreFile, packageDir, prepareAssets, program, runCommand, scaffoldTemplate, scaffoldWorkspace, select, shouldSkipTemplatePath, skeletonDir, templateChoices, templateMap, templateSourceMap, templateTargetMap, templatesDir, toPublishGitignorePath, toWorkspaceGitignorePath };
|
package/dist/index.mjs
CHANGED
|
@@ -151,6 +151,7 @@ const skipDirs = new Set([
|
|
|
151
151
|
]);
|
|
152
152
|
const skipFiles = new Set([
|
|
153
153
|
".DS_Store",
|
|
154
|
+
"CHANGELOG.md",
|
|
154
155
|
"typed-router.d.ts",
|
|
155
156
|
"worker-configuration.d.ts"
|
|
156
157
|
]);
|
|
@@ -254,6 +255,84 @@ async function prepareAssets(options = {}) {
|
|
|
254
255
|
await copyTemplates(repoRoot, overwriteExisting);
|
|
255
256
|
}
|
|
256
257
|
|
|
258
|
+
//#endregion
|
|
259
|
+
//#region src/scaffold.ts
|
|
260
|
+
async function isEmptyDir(dir) {
|
|
261
|
+
try {
|
|
262
|
+
return (await fs.readdir(dir)).length === 0;
|
|
263
|
+
} catch (error) {
|
|
264
|
+
if (error && error.code === "ENOENT") return true;
|
|
265
|
+
throw error;
|
|
266
|
+
}
|
|
267
|
+
}
|
|
268
|
+
async function prepareTargetDir(dir, options = {}) {
|
|
269
|
+
if (await isEmptyDir(dir)) {
|
|
270
|
+
await fs.mkdir(dir, { recursive: true });
|
|
271
|
+
return;
|
|
272
|
+
}
|
|
273
|
+
if (!options.force) throw new Error(`Target directory ${dir} is not empty. Pass --force to overwrite.`);
|
|
274
|
+
await fs.rm(dir, {
|
|
275
|
+
recursive: true,
|
|
276
|
+
force: true
|
|
277
|
+
});
|
|
278
|
+
await fs.mkdir(dir, { recursive: true });
|
|
279
|
+
}
|
|
280
|
+
async function copyDirContents(sourceDir, targetDir, options = {}) {
|
|
281
|
+
const rootDir = options.rootDir ?? sourceDir;
|
|
282
|
+
const filter = options.filter ?? ((src) => !shouldSkipTemplatePath(rootDir, src));
|
|
283
|
+
const renameEntry = options.renameEntry ?? toWorkspaceGitignorePath;
|
|
284
|
+
const skipRoot = new Set(options.skipRootBasenames ?? []);
|
|
285
|
+
await fs.mkdir(targetDir, { recursive: true });
|
|
286
|
+
const entries = await fs.readdir(sourceDir, { withFileTypes: true });
|
|
287
|
+
for (const entry of entries) {
|
|
288
|
+
if (sourceDir === rootDir && skipRoot.has(entry.name)) continue;
|
|
289
|
+
const from = path.join(sourceDir, entry.name);
|
|
290
|
+
if (!filter(from)) continue;
|
|
291
|
+
const targetName = renameEntry(entry.name);
|
|
292
|
+
const to = path.join(targetDir, targetName);
|
|
293
|
+
if (entry.isDirectory()) {
|
|
294
|
+
await copyDirContents(from, to, {
|
|
295
|
+
rootDir,
|
|
296
|
+
filter,
|
|
297
|
+
renameEntry,
|
|
298
|
+
skipRootBasenames: options.skipRootBasenames
|
|
299
|
+
});
|
|
300
|
+
continue;
|
|
301
|
+
}
|
|
302
|
+
if (entry.isSymbolicLink()) {
|
|
303
|
+
const link = await fs.readlink(from);
|
|
304
|
+
await fs.symlink(link, to);
|
|
305
|
+
continue;
|
|
306
|
+
}
|
|
307
|
+
await fs.cp(from, to);
|
|
308
|
+
}
|
|
309
|
+
}
|
|
310
|
+
async function scaffoldTemplate(options) {
|
|
311
|
+
const { sourceDir, targetDir, ensureTargetDir = true, filter, renameEntry, skipRootBasenames } = options;
|
|
312
|
+
if (ensureTargetDir) await fs.mkdir(targetDir, { recursive: true });
|
|
313
|
+
await copyDirContents(sourceDir, targetDir, {
|
|
314
|
+
rootDir: sourceDir,
|
|
315
|
+
filter,
|
|
316
|
+
renameEntry,
|
|
317
|
+
skipRootBasenames
|
|
318
|
+
});
|
|
319
|
+
}
|
|
320
|
+
async function scaffoldWorkspace(options) {
|
|
321
|
+
const { targetDir, templateKeys = [], assetsDir: assetsDir$1 = assetsDir, templatesDir: templatesDir$1 = templatesDir, includeAssets = true, targetMode = "prepare", force = false } = options;
|
|
322
|
+
if (targetMode === "prepare") await prepareTargetDir(targetDir, { force });
|
|
323
|
+
else if (targetMode === "ensure") await fs.mkdir(targetDir, { recursive: true });
|
|
324
|
+
if (includeAssets) await copyDirContents(assetsDir$1, targetDir, { rootDir: assetsDir$1 });
|
|
325
|
+
if (!templateKeys.length) return;
|
|
326
|
+
const selections = new Set(templateKeys);
|
|
327
|
+
for (const template of templateChoices$1) {
|
|
328
|
+
if (!selections.has(template.key)) continue;
|
|
329
|
+
await scaffoldTemplate({
|
|
330
|
+
sourceDir: path.join(templatesDir$1, template.source),
|
|
331
|
+
targetDir: path.join(targetDir, template.target)
|
|
332
|
+
});
|
|
333
|
+
}
|
|
334
|
+
}
|
|
335
|
+
|
|
257
336
|
//#endregion
|
|
258
337
|
//#region src/utils/command.ts
|
|
259
338
|
async function runCommand(command, args, options = {}) {
|
|
@@ -273,4 +352,4 @@ const templateTargetMap = Object.fromEntries(templateChoices.map((item) => [item
|
|
|
273
352
|
const templateMap = templateSourceMap;
|
|
274
353
|
|
|
275
354
|
//#endregion
|
|
276
|
-
export { Command, assetTargets, assetsDir, checkbox, createTemplateCopyFilter, execaCommand, getAssetTargets, input, isGitignoreFile, packageDir, prepareAssets, program, runCommand, select, shouldSkipTemplatePath, skeletonDir, templateChoices, templateMap, templateSourceMap, templateTargetMap, templatesDir, toPublishGitignorePath, toWorkspaceGitignorePath };
|
|
355
|
+
export { Command, assetTargets, assetsDir, checkbox, createTemplateCopyFilter, execaCommand, getAssetTargets, input, isGitignoreFile, packageDir, prepareAssets, program, runCommand, scaffoldTemplate, scaffoldWorkspace, select, shouldSkipTemplatePath, skeletonDir, templateChoices, templateMap, templateSourceMap, templateTargetMap, templatesDir, toPublishGitignorePath, toWorkspaceGitignorePath };
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@icebreakers/monorepo-templates",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "0.1.
|
|
4
|
+
"version": "0.1.2",
|
|
5
5
|
"description": "Template assets for icebreaker monorepo scaffolding",
|
|
6
6
|
"author": "ice breaker <1324318532@qq.com>",
|
|
7
7
|
"license": "MIT",
|
|
@@ -52,7 +52,7 @@
|
|
|
52
52
|
"dev": "tsdown --watch --sourcemap",
|
|
53
53
|
"build": "tsdown",
|
|
54
54
|
"typecheck": "tsc -p tsconfig.json",
|
|
55
|
-
"sync:assets": "node scripts/sync-assets.mjs",
|
|
55
|
+
"sync:assets": "pnpm run build && node scripts/sync-assets.mjs",
|
|
56
56
|
"lint": "eslint ."
|
|
57
57
|
}
|
|
58
58
|
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@icebreakers/vue-lib-template",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "0.0.
|
|
4
|
+
"version": "0.0.1",
|
|
5
5
|
"description": "vue lib vite lib mode template",
|
|
6
6
|
"author": "ice breaker <1324318532@qq.com>",
|
|
7
7
|
"license": "ISC",
|
|
@@ -16,15 +16,13 @@
|
|
|
16
16
|
"keywords": [],
|
|
17
17
|
"sideEffects": false,
|
|
18
18
|
"exports": {
|
|
19
|
-
".": "./
|
|
19
|
+
".": "./src/index.ts"
|
|
20
20
|
},
|
|
21
21
|
"files": [
|
|
22
22
|
"dist"
|
|
23
23
|
],
|
|
24
24
|
"scripts": {
|
|
25
|
-
"dev": "vite",
|
|
26
25
|
"build": "vue-tsc -b && vite build",
|
|
27
|
-
"preview": "vite preview",
|
|
28
26
|
"test": "vitest run",
|
|
29
27
|
"test:dev": "vitest",
|
|
30
28
|
"release": "pnpm publish",
|
|
@@ -45,17 +43,13 @@
|
|
|
45
43
|
"types": "./dist/index.d.ts"
|
|
46
44
|
},
|
|
47
45
|
"devDependencies": {
|
|
48
|
-
"@tailwindcss/vite": "^4.1.18",
|
|
49
46
|
"@vitejs/plugin-vue": "^6.0.3",
|
|
50
47
|
"@vue/test-utils": "^2.4.6",
|
|
51
48
|
"@vue/tsconfig": "^0.8.1",
|
|
52
49
|
"jsdom": "^27.4.0",
|
|
53
|
-
"tailwindcss": "^4.1.18",
|
|
54
|
-
"unplugin-vue-router": "^0.19.2",
|
|
55
50
|
"vite": "^7.3.1",
|
|
56
51
|
"vite-plugin-dts": "^4.5.4",
|
|
57
52
|
"vue": "^3.5.26",
|
|
58
|
-
"vue-router": "^4.6.4",
|
|
59
53
|
"vue-tsc": "^3.2.2"
|
|
60
54
|
}
|
|
61
55
|
}
|
|
@@ -7,15 +7,16 @@ withDefaults(defineProps<{
|
|
|
7
7
|
</script>
|
|
8
8
|
|
|
9
9
|
<template>
|
|
10
|
-
<div class="
|
|
11
|
-
|
|
12
|
-
{{ msg }}
|
|
13
|
-
</div>
|
|
10
|
+
<div class="hello-world">
|
|
11
|
+
{{ msg }}
|
|
14
12
|
</div>
|
|
15
13
|
</template>
|
|
16
14
|
|
|
17
15
|
<style scoped>
|
|
18
|
-
.
|
|
19
|
-
|
|
16
|
+
.hello-world {
|
|
17
|
+
padding: 8px;
|
|
18
|
+
color: #222;
|
|
19
|
+
background: #f5f5f5;
|
|
20
|
+
border-radius: 12px;
|
|
20
21
|
}
|
|
21
22
|
</style>
|
|
@@ -5,9 +5,6 @@
|
|
|
5
5
|
"paths": {
|
|
6
6
|
"@/*": [
|
|
7
7
|
"./src/*"
|
|
8
|
-
],
|
|
9
|
-
"~/*": [
|
|
10
|
-
"./lib/*"
|
|
11
8
|
]
|
|
12
9
|
},
|
|
13
10
|
/* Linting */
|
|
@@ -19,12 +16,8 @@
|
|
|
19
16
|
"noUncheckedSideEffectImports": true
|
|
20
17
|
},
|
|
21
18
|
"include": [
|
|
22
|
-
"lib/**/*.ts",
|
|
23
|
-
"lib/**/*.tsx",
|
|
24
|
-
"lib/**/*.vue",
|
|
25
19
|
"src/**/*.ts",
|
|
26
20
|
"src/**/*.tsx",
|
|
27
|
-
"src/**/*.vue"
|
|
28
|
-
"types"
|
|
21
|
+
"src/**/*.vue"
|
|
29
22
|
]
|
|
30
23
|
}
|
|
@@ -1,8 +1,6 @@
|
|
|
1
1
|
import type { PluginOption, UserConfig } from 'vite'
|
|
2
|
-
import Tailwindcss from '@tailwindcss/vite'
|
|
3
2
|
import Vue from '@vitejs/plugin-vue'
|
|
4
3
|
import path from 'pathe'
|
|
5
|
-
import VueRouter from 'unplugin-vue-router/vite'
|
|
6
4
|
import { mergeConfig } from 'vite'
|
|
7
5
|
import DTS from 'vite-plugin-dts'
|
|
8
6
|
import { sharedConfig } from './vite.shared.config'
|
|
@@ -12,28 +10,20 @@ const ensureVitePlugin = <T>(plugin: T) => plugin as unknown as PluginOption
|
|
|
12
10
|
|
|
13
11
|
export default mergeConfig(sharedConfig, {
|
|
14
12
|
plugins: [
|
|
15
|
-
ensureVitePlugin(
|
|
16
|
-
VueRouter(
|
|
17
|
-
{
|
|
18
|
-
dts: path.relative(import.meta.dirname, './types/typed-router.d.ts'),
|
|
19
|
-
},
|
|
20
|
-
),
|
|
21
|
-
),
|
|
22
13
|
ensureVitePlugin(Vue()),
|
|
23
14
|
ensureVitePlugin(
|
|
24
15
|
DTS(
|
|
25
16
|
{
|
|
26
17
|
tsconfigPath: './tsconfig.app.json',
|
|
27
|
-
entryRoot: './
|
|
18
|
+
entryRoot: './src',
|
|
28
19
|
},
|
|
29
20
|
),
|
|
30
21
|
),
|
|
31
|
-
ensureVitePlugin(Tailwindcss()),
|
|
32
22
|
],
|
|
33
23
|
// https://vite.dev/guide/build.html#library-mode
|
|
34
24
|
build: {
|
|
35
25
|
lib: {
|
|
36
|
-
entry: path.resolve(import.meta.dirname, '
|
|
26
|
+
entry: path.resolve(import.meta.dirname, 'src/index'),
|
|
37
27
|
name: 'icebreaker',
|
|
38
28
|
// the proper extensions will be added
|
|
39
29
|
fileName: 'index',
|
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
<!doctype html>
|
|
2
|
-
<html lang="en">
|
|
3
|
-
<head>
|
|
4
|
-
<meta charset="UTF-8" />
|
|
5
|
-
<link rel="icon" type="image/svg+xml" href="/vite.svg" />
|
|
6
|
-
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
|
7
|
-
<title>Vite + Vue + TS</title>
|
|
8
|
-
</head>
|
|
9
|
-
<body>
|
|
10
|
-
<div id="app"></div>
|
|
11
|
-
<script type="module" src="/src/main.ts"></script>
|
|
12
|
-
</body>
|
|
13
|
-
</html>
|
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
import { createRouter, createWebHistory } from 'vue-router'
|
|
2
|
-
import { handleHotUpdate, routes } from 'vue-router/auto-routes'
|
|
3
|
-
|
|
4
|
-
export const router = createRouter({
|
|
5
|
-
history: createWebHistory(),
|
|
6
|
-
routes,
|
|
7
|
-
})
|
|
8
|
-
|
|
9
|
-
if (import.meta.hot) {
|
|
10
|
-
handleHotUpdate(router)
|
|
11
|
-
}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
@import 'tailwindcss';
|