create-icebreaker 1.0.2 → 1.0.4

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.
Files changed (2) hide show
  1. package/dist/index.mjs +39 -0
  2. package/package.json +12 -2
package/dist/index.mjs CHANGED
@@ -101,6 +101,44 @@ async function scaffoldFromNpm(targetDir, selectedTemplates, force = false) {
101
101
  });
102
102
  }
103
103
  //#endregion
104
+ //#region src/tsconfig.ts
105
+ const workspaceRoots = [
106
+ "apps",
107
+ "packages",
108
+ "templates"
109
+ ];
110
+ async function pathExists(targetPath) {
111
+ try {
112
+ await fs.access(targetPath);
113
+ return true;
114
+ } catch {
115
+ return false;
116
+ }
117
+ }
118
+ async function readWorkspaceReferences(targetDir, workspaceRoot) {
119
+ const rootDir = path.join(targetDir, workspaceRoot);
120
+ if (!await pathExists(rootDir)) return [];
121
+ const entries = await fs.readdir(rootDir, { withFileTypes: true });
122
+ const references = [];
123
+ for (const entry of entries) {
124
+ if (!entry.isDirectory()) continue;
125
+ const workspaceDir = path.join(rootDir, entry.name);
126
+ const [hasPackageJson, hasTsconfig] = await Promise.all([pathExists(path.join(workspaceDir, "package.json")), pathExists(path.join(workspaceDir, "tsconfig.json"))]);
127
+ if (hasPackageJson && hasTsconfig) references.push({ path: `./${workspaceRoot}/${entry.name}` });
128
+ }
129
+ return references;
130
+ }
131
+ async function updateRootTsconfigReferences(targetDir) {
132
+ const tsconfigPath = path.join(targetDir, "tsconfig.json");
133
+ const raw = await fs.readFile(tsconfigPath, "utf8");
134
+ const tsconfig = JSON.parse(raw);
135
+ const references = (await Promise.all(workspaceRoots.map((workspaceRoot) => readWorkspaceReferences(targetDir, workspaceRoot)))).flat();
136
+ tsconfig.extends = tsconfig.extends ?? "repoctl/tsconfig.json";
137
+ tsconfig.files = [];
138
+ tsconfig.references = references;
139
+ await fs.writeFile(tsconfigPath, `${JSON.stringify(tsconfig, null, 2)}\n`, "utf8");
140
+ }
141
+ //#endregion
104
142
  //#region src/index.ts
105
143
  function printNextSteps(targetDir) {
106
144
  process.stdout.write(formatNextSteps(targetDir));
@@ -119,6 +157,7 @@ async function runCreate(targetDirInput, options) {
119
157
  const projectName = path.basename(targetDir) || targetInput;
120
158
  await scaffoldFromNpm(targetDir, selectedTemplates, Boolean(options.force));
121
159
  await updateRootPackageJson(targetDir, projectName);
160
+ await updateRootTsconfigReferences(targetDir);
122
161
  printNextSteps(targetDir);
123
162
  }
124
163
  const program = new Command();
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "create-icebreaker",
3
3
  "type": "module",
4
- "version": "1.0.2",
4
+ "version": "1.0.4",
5
5
  "description": "Bootstrap the icebreaker monorepo template via npm create/pnpm create with optional cleanup",
6
6
  "author": "ice breaker <hi@sonofmagic.top>",
7
7
  "license": "MIT",
@@ -20,6 +20,16 @@
20
20
  "scaffold"
21
21
  ],
22
22
  "sideEffects": false,
23
+ "exports": {
24
+ ".": {
25
+ "types": "./dist/index.d.mts",
26
+ "default": "./dist/index.mjs"
27
+ },
28
+ "./package.json": "./package.json"
29
+ },
30
+ "main": "./dist/index.mjs",
31
+ "module": "./dist/index.mjs",
32
+ "types": "./dist/index.d.mts",
23
33
  "bin": {
24
34
  "create-icebreaker": "bin/create-icebreaker.js"
25
35
  },
@@ -31,7 +41,7 @@
31
41
  "node": ">=18.0.0"
32
42
  },
33
43
  "dependencies": {
34
- "@icebreakers/monorepo-templates": "1.0.2"
44
+ "@icebreakers/monorepo-templates": "1.0.4"
35
45
  },
36
46
  "publishConfig": {
37
47
  "access": "public"