create-renoun 2.0.4 → 2.1.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.
package/LICENSE.md CHANGED
@@ -1,6 +1,6 @@
1
1
  MIT License
2
2
 
3
- Copyright (c) 2025 souporserious LLC
3
+ Copyright (c) souporserious
4
4
 
5
5
  Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the “Software”), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
6
6
 
package/dist/index.mjs CHANGED
@@ -1,10 +1,11 @@
1
1
  #!/usr/bin/env node
2
2
  import { installPackage } from '@antfu/install-pkg';
3
- import { log, text, isCancel, confirm, spinner, intro, select, outro, cancel } from '@clack/prompts';
3
+ import { log, text, isCancel, confirm, spinner, select, intro, outro, cancel } from '@clack/prompts';
4
4
  import { readFileSync, existsSync, mkdirSync, writeFileSync, rmdirSync, createWriteStream } from 'node:fs';
5
- import __node_cjsPath, { resolve, basename, join } from 'node:path';
5
+ import __node_cjsPath, { resolve, basename, join, relative, isAbsolute, sep } from 'node:path';
6
6
  import color from 'picocolors';
7
7
  import terminalLink from 'terminal-link';
8
+ import { spawn } from 'node:child_process';
8
9
  import { Readable } from 'node:stream';
9
10
  import { pipeline } from 'node:stream/promises';
10
11
  import { homedir } from 'node:os';
@@ -105,9 +106,7 @@ function shouldRefreshCache() {
105
106
  }
106
107
  if (isYes) {
107
108
  try {
108
- rmdirSync(workingDirectory, {
109
- recursive: true
110
- });
109
+ rmdirSync(workingDirectory);
111
110
  mkdirSync(workingDirectory, {
112
111
  recursive: true
113
112
  });
@@ -143,8 +142,8 @@ function shouldRefreshCache() {
143
142
  log.error('Failed to fetch example files.');
144
143
  throw error;
145
144
  }
146
- const { detectPackageManager } = await import('@antfu/install-pkg');
147
- const packageManager = await detectPackageManager(workingDirectory);
145
+ const { detectPackageManager, installPackage } = await import('@antfu/install-pkg');
146
+ const detectedPackageManager = await detectPackageManager(workingDirectory);
148
147
  try {
149
148
  await reformatPackageJson(workingDirectory);
150
149
  loader.start('Reformatting package.json...');
@@ -159,9 +158,13 @@ node_modules
159
158
  # testing
160
159
  coverage
161
160
 
161
+ # renoun
162
+ .renoun
163
+
162
164
  # next.js
163
165
  .next
164
166
  out
167
+ next-env.d.ts
165
168
 
166
169
  # production
167
170
  build
@@ -173,18 +176,79 @@ dist
173
176
  # debug
174
177
  npm-debug.log*
175
178
 
176
- # local env files
179
+ # environment files
177
180
  .env
178
181
  .env.local
179
182
 
180
183
  # typescript
181
184
  *.tsbuildinfo
182
- next-env.d.ts
183
185
  `, 'utf-8');
184
- const introInstallInstructions = workingDirectory === process.cwd() ? `Run ${color.bold(`${packageManager ?? 'npm'} install`)} to install the dependencies and get started.` : `Change to the directory (cd ${color.bold(workingDirectory)}) and run ${color.bold(`${packageManager ?? 'npm'} install`)} to install the dependencies and get started.`;
185
- log.success(`Example ${color.bold(directoryName)} fetched and configured successfully! ${introInstallInstructions}`);
186
+ const normalizedDetectedPackageManager = detectedPackageManager?.startsWith('yarn') ? 'yarn' : detectedPackageManager;
187
+ const packageManagerChoices = [
188
+ normalizedDetectedPackageManager,
189
+ 'pnpm',
190
+ 'npm',
191
+ 'yarn',
192
+ 'bun'
193
+ ].filter((value, index, array)=>{
194
+ return Boolean(value) && array.indexOf(value) === index;
195
+ });
196
+ const packageManager = await select({
197
+ message: 'Which package manager should we use to install dependencies?',
198
+ options: packageManagerChoices.map((value)=>({
199
+ label: value,
200
+ value
201
+ }))
202
+ });
203
+ if (isCancel(packageManager)) {
204
+ throw new Error('Dependency installation cancelled.');
205
+ }
206
+ const installLoader = spinner();
207
+ installLoader.start(`Installing dependencies with ${color.bold(packageManager)}...`);
208
+ try {
209
+ if (packageManager === 'yarn') {
210
+ await runCommand('yarn', [
211
+ 'install'
212
+ ], workingDirectory);
213
+ } else {
214
+ await installPackage([], {
215
+ cwd: workingDirectory,
216
+ packageManager
217
+ });
218
+ }
219
+ installLoader.stop('Dependencies installed successfully.');
220
+ } catch (error) {
221
+ installLoader.stop('Failed to install dependencies.');
222
+ if (error instanceof Error) {
223
+ throw new Error(`Failed to install dependencies: ${error.message}`);
224
+ }
225
+ throw error;
226
+ }
227
+ const devCommand = packageManager === 'npm' ? 'npm run dev' : `${packageManager} dev`;
228
+ const introNextSteps = workingDirectory === process.cwd() ? `Run ${color.bold(devCommand)} to get started.` : (()=>{
229
+ const cwd = process.cwd();
230
+ const relativeWorkingDirectory = relative(cwd, workingDirectory);
231
+ const canUseRelativePath = relativeWorkingDirectory !== '' && relativeWorkingDirectory !== '.' && !isAbsolute(relativeWorkingDirectory) && relativeWorkingDirectory !== '..' && !relativeWorkingDirectory.startsWith(`..${sep}`);
232
+ const cdPath = canUseRelativePath ? relativeWorkingDirectory : workingDirectory;
233
+ return `Change directories (cd ${color.bold(`"${cdPath}"`)}) and run ${color.bold(devCommand)} to get started.`;
234
+ })();
235
+ log.success(`Example ${color.bold(directoryName)} fetched and configured successfully! ${introNextSteps}`);
186
236
  return true;
187
237
  }
238
+ function runCommand(command, args, cwd) {
239
+ return new Promise((resolve, reject)=>{
240
+ const childProcess = spawn(command, args, {
241
+ cwd,
242
+ stdio: 'inherit',
243
+ shell: false
244
+ });
245
+ childProcess.on('error', reject);
246
+ childProcess.on('close', (code)=>{
247
+ if (code === 0) resolve();
248
+ else reject(new Error(`${command} exited with code ${code}`));
249
+ });
250
+ });
251
+ }
188
252
  /** Fetches the contents of a directory in a GitHub repository and downloads them to the local file system. */ async function fetchGitHubDirectory({ owner, repo, branch, directoryPath, workingDirectory, basePath }) {
189
253
  const apiUrl = `https://api.github.com/repos/${owner}/${repo}/contents/${directoryPath}?ref=${branch}`;
190
254
  const response = await fetch(apiUrl);
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "create-renoun",
3
3
  "type": "module",
4
- "version": "2.0.4",
4
+ "version": "2.1.0",
5
5
  "author": {
6
6
  "name": "souporserious",
7
7
  "email": "support@souporserious.com"
@@ -19,7 +19,7 @@
19
19
  ],
20
20
  "bin": "./dist/index.mjs",
21
21
  "devDependencies": {
22
- "bunchee": "6.6.2"
22
+ "bunchee": "6.8.2"
23
23
  },
24
24
  "dependencies": {
25
25
  "@antfu/install-pkg": "1.1.0",