@icebreakers/monorepo-templates 0.1.1 → 0.1.3

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.
@@ -3,7 +3,7 @@
3
3
  "type": "module",
4
4
  "version": "0.0.0",
5
5
  "private": true,
6
- "packageManager": "pnpm@10.28.0",
6
+ "packageManager": "pnpm@10.28.1",
7
7
  "author": "ice breaker <1324318532@qq.com>",
8
8
  "repository": {
9
9
  "type": "git",
@@ -49,9 +49,9 @@
49
49
  "@commitlint/cli": "^20.3.1",
50
50
  "@icebreakers/changelog-github": "^0.1.0",
51
51
  "@icebreakers/commitlint-config": "^1.2.5",
52
- "@icebreakers/eslint-config": "^1.6.13",
52
+ "@icebreakers/eslint-config": "^1.6.14",
53
53
  "@icebreakers/monorepo": "workspace:*",
54
- "@icebreakers/stylelint-config": "^1.2.5",
54
+ "@icebreakers/stylelint-config": "^1.2.6",
55
55
  "@types/fs-extra": "^11.0.4",
56
56
  "@types/node": "^25.0.9",
57
57
  "@types/semver": "^7.7.1",
@@ -74,7 +74,7 @@
74
74
  "tslib": "^2.8.1",
75
75
  "tsup": "^8.5.1",
76
76
  "tsx": "^4.21.0",
77
- "turbo": "^2.7.4",
77
+ "turbo": "^2.7.5",
78
78
  "type-fest": "^5.4.1",
79
79
  "typescript": "^5.9.3",
80
80
  "unbuild": "^3.6.1",
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.1",
4
+ "version": "0.1.3",
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
  }
@@ -15,7 +15,7 @@
15
15
  },
16
16
  "dependencies": {
17
17
  "@faker-js/faker": "^10.2.0",
18
- "@tanstack/vue-query": "^5.92.7",
18
+ "@tanstack/vue-query": "^5.92.8",
19
19
  "@tanstack/vue-query-devtools": "^6.1.3",
20
20
  "@tanstack/vue-table": "^8.21.3",
21
21
  "@tanstack/vue-virtual": "^3.13.18",
@@ -24,7 +24,7 @@
24
24
  "pinia": "^3.0.4",
25
25
  "tailwind-merge": "^3.4.0",
26
26
  "tailwind-variants": "^3.2.2",
27
- "vue": "^3.5.26",
27
+ "vue": "^3.5.27",
28
28
  "vue-i18n": "^11.2.8",
29
29
  "vue-router": "^4.6.4"
30
30
  },
@@ -6,4 +6,5 @@ export default defineConfig({
6
6
  dts: true,
7
7
  clean: true,
8
8
  target: 'node18',
9
+ failOnWarn: false,
9
10
  })
@@ -22,7 +22,7 @@
22
22
  "lint:fix": "eslint . --fix"
23
23
  },
24
24
  "dependencies": {
25
- "vue": "^3.5.26"
25
+ "vue": "^3.5.27"
26
26
  },
27
27
  "devDependencies": {
28
28
  "@braintree/sanitize-url": "^7.1.1",
@@ -4,9 +4,6 @@ export default icebreaker(
4
4
  {
5
5
  vue: true,
6
6
  typescript: true,
7
- tailwindcss: {
8
- entryPoint: 'src/style.css',
9
- },
10
7
  ignores: ['**/fixtures/**'],
11
8
  },
12
9
  )
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@icebreakers/vue-lib-template",
3
3
  "type": "module",
4
- "version": "0.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
- ".": "./lib/index.ts"
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
- "vue": "^3.5.26",
58
- "vue-router": "^4.6.4",
52
+ "vue": "^3.5.27",
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="p-2">
11
- <div class="rounded-2xl p-2">
12
- {{ msg }}
13
- </div>
10
+ <div class="hello-world">
11
+ {{ msg }}
14
12
  </div>
15
13
  </template>
16
14
 
17
15
  <style scoped>
18
- .a {
19
- color: aliceblue;
16
+ .hello-world {
17
+ padding: 8px;
18
+ color: #222;
19
+ background: #f5f5f5;
20
+ border-radius: 12px;
20
21
  }
21
22
  </style>
@@ -1,3 +1,5 @@
1
1
  import HelloWorld from './HelloWorld.vue'
2
2
 
3
- export { HelloWorld }
3
+ export {
4
+ HelloWorld,
5
+ }
@@ -1,2 +1 @@
1
1
  /// <reference types="vite/client" />
2
- /// <reference types="unplugin-vue-router/client" />
@@ -1,5 +1,5 @@
1
1
  import { mount } from '@vue/test-utils'
2
- import HelloWorld from '../lib/HelloWorld.vue'
2
+ import HelloWorld from '../src/HelloWorld.vue'
3
3
 
4
4
  it('displays message', () => {
5
5
  const wrapper = mount(HelloWorld, {
@@ -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
  }
@@ -14,9 +14,6 @@
14
14
  "paths": {
15
15
  "@/*": [
16
16
  "./src"
17
- ],
18
- "~/*": [
19
- "./lib"
20
17
  ]
21
18
  },
22
19
  "types": [
@@ -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: './lib',
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, 'lib/index'),
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',
@@ -7,7 +7,6 @@ export const sharedConfig = defineConfig({
7
7
  resolve: {
8
8
  alias: {
9
9
  '@': path.resolve(import.meta.dirname, 'src'),
10
- '~': path.resolve(import.meta.dirname, 'lib'),
11
10
  },
12
11
  },
13
12
  })
@@ -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,9 +0,0 @@
1
- <script setup lang="ts">
2
-
3
- </script>
4
-
5
- <template>
6
- <RouterView />
7
- </template>
8
-
9
- <style scoped></style>
@@ -1,8 +0,0 @@
1
- import { createApp } from 'vue'
2
- import App from './App.vue'
3
- import { router } from './router'
4
- import './style.css'
5
-
6
- const app = createApp(App)
7
- app.use(router)
8
- app.mount('#app')
@@ -1,7 +0,0 @@
1
- <script setup lang="ts">
2
- import { HelloWorld } from '~/index'
3
- </script>
4
-
5
- <template>
6
- <HelloWorld msg="Vite + Vue" />
7
- </template>
@@ -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';