complete-cli 1.1.1 → 1.2.0

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.
@@ -24,7 +24,7 @@ export async function createProject(projectName, authorName, projectPath, create
24
24
  await createPackageMetadataJSON(projectPath);
25
25
  }
26
26
  await installNodeModules(projectPath, skipInstall, packageManager);
27
- await formatFiles(projectPath);
27
+ await formatFiles(projectPath, packageManager);
28
28
  // Only make the initial commit once all of the files have been copied and formatted.
29
29
  await initGitRepository(projectPath, gitRemoteURL);
30
30
  promptLog(`Successfully created project: ${chalk.green(projectName)}`);
@@ -113,14 +113,30 @@ function copyDynamicFiles(projectName, authorName, projectPath, packageManager)
113
113
  }
114
114
  }
115
115
  function copyPackageManagerSpecificFiles(projectPath, packageManager) {
116
- if (packageManager === PackageManager.pnpm) {
116
+ switch (packageManager) {
117
+ case PackageManager.npm: {
118
+ const npmrc = "save-exact=true\n";
119
+ const npmrcPath = path.join(projectPath, ".npmrc");
120
+ writeFile(npmrcPath, npmrc);
121
+ break;
122
+ }
117
123
  // `pnpm` requires the `shamefully-hoist` option to be enabled for "complete-lint" to work
118
124
  // correctly.
119
- const npmrc = `save-exact=true
120
- shamefully-hoist=true
121
- `;
122
- const npmrcPath = path.join(projectPath, ".npmrc");
123
- writeFile(npmrcPath, npmrc);
125
+ case PackageManager.pnpm: {
126
+ const npmrc = "save-exact=true\nshamefully-hoist=true\n";
127
+ const npmrcPath = path.join(projectPath, ".npmrc");
128
+ writeFile(npmrcPath, npmrc);
129
+ break;
130
+ }
131
+ case PackageManager.yarn: {
132
+ break;
133
+ }
134
+ case PackageManager.bun: {
135
+ const bunfig = "[install]\nexact = true\n";
136
+ const bunfigPath = path.join(projectPath, "bunfig.toml");
137
+ writeFile(bunfigPath, bunfig);
138
+ break;
139
+ }
124
140
  }
125
141
  }
126
142
  async function revertVersionsInPackageJSON(projectPath) {
@@ -167,7 +183,11 @@ async function installNodeModules(projectPath, skipInstall, packageManager) {
167
183
  promptError("Exiting.");
168
184
  }
169
185
  }
170
- async function formatFiles(projectPath) {
186
+ async function formatFiles(projectPath, packageManager) {
171
187
  const $$q = $q({ cwd: projectPath });
172
- await $$q `prettier --write .`;
188
+ // Execa does not work properly with Bun in this context. Invoking `bunx` directly fixes the
189
+ // problem.
190
+ await (packageManager === PackageManager.bun
191
+ ? $$q `bunx prettier --write .`
192
+ : $$q `prettier --write .`);
173
193
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "complete-cli",
3
- "version": "1.1.1",
3
+ "version": "1.2.0",
4
4
  "description": "A command line tool for bootstrapping TypeScript projects.",
5
5
  "keywords": [
6
6
  "typescript"
@@ -60,7 +60,7 @@ export async function createProject(
60
60
  }
61
61
 
62
62
  await installNodeModules(projectPath, skipInstall, packageManager);
63
- await formatFiles(projectPath);
63
+ await formatFiles(projectPath, packageManager);
64
64
 
65
65
  // Only make the initial commit once all of the files have been copied and formatted.
66
66
  await initGitRepository(projectPath, gitRemoteURL);
@@ -185,14 +185,33 @@ function copyPackageManagerSpecificFiles(
185
185
  projectPath: string,
186
186
  packageManager: PackageManager,
187
187
  ) {
188
- if (packageManager === PackageManager.pnpm) {
188
+ switch (packageManager) {
189
+ case PackageManager.npm: {
190
+ const npmrc = "save-exact=true\n";
191
+ const npmrcPath = path.join(projectPath, ".npmrc");
192
+ writeFile(npmrcPath, npmrc);
193
+ break;
194
+ }
195
+
189
196
  // `pnpm` requires the `shamefully-hoist` option to be enabled for "complete-lint" to work
190
197
  // correctly.
191
- const npmrc = `save-exact=true
192
- shamefully-hoist=true
193
- `;
194
- const npmrcPath = path.join(projectPath, ".npmrc");
195
- writeFile(npmrcPath, npmrc);
198
+ case PackageManager.pnpm: {
199
+ const npmrc = "save-exact=true\nshamefully-hoist=true\n";
200
+ const npmrcPath = path.join(projectPath, ".npmrc");
201
+ writeFile(npmrcPath, npmrc);
202
+ break;
203
+ }
204
+
205
+ case PackageManager.yarn: {
206
+ break;
207
+ }
208
+
209
+ case PackageManager.bun: {
210
+ const bunfig = "[install]\nexact = true\n";
211
+ const bunfigPath = path.join(projectPath, "bunfig.toml");
212
+ writeFile(bunfigPath, bunfig);
213
+ break;
214
+ }
196
215
  }
197
216
  }
198
217
 
@@ -253,7 +272,15 @@ async function installNodeModules(
253
272
  }
254
273
  }
255
274
 
256
- async function formatFiles(projectPath: string) {
275
+ async function formatFiles(
276
+ projectPath: string,
277
+ packageManager: PackageManager,
278
+ ) {
257
279
  const $$q = $q({ cwd: projectPath });
258
- await $$q`prettier --write .`;
280
+
281
+ // Execa does not work properly with Bun in this context. Invoking `bunx` directly fixes the
282
+ // problem.
283
+ await (packageManager === PackageManager.bun
284
+ ? $$q`bunx prettier --write .`
285
+ : $$q`prettier --write .`);
259
286
  }