create-tina-app 1.3.3 → 1.4.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/dist/index.d.ts CHANGED
@@ -1,2 +1,9 @@
1
- export declare const PKG_MANAGERS: string[];
1
+ /**
2
+ * The available package managers a user can use.
3
+ * To add a new supported package manager, add the usage command to this list.
4
+ * The `PackageManager` type will be automatically updated as a result.
5
+ */
6
+ declare const PKG_MANAGERS: readonly ["npm", "yarn", "pnpm", "bun"];
7
+ export type PackageManager = (typeof PKG_MANAGERS)[number];
2
8
  export declare function run(): Promise<void>;
9
+ export {};
package/dist/index.js CHANGED
@@ -29,18 +29,17 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
29
29
  // src/index.ts
30
30
  var index_exports = {};
31
31
  __export(index_exports, {
32
- PKG_MANAGERS: () => PKG_MANAGERS,
33
32
  run: () => run
34
33
  });
35
34
  module.exports = __toCommonJS(index_exports);
36
35
  var import_metrics = require("@tinacms/metrics");
37
36
  var import_commander = require("commander");
38
37
  var import_prompts = __toESM(require("prompts"));
39
- var import_node_path = __toESM(require("path"));
38
+ var import_node_path = __toESM(require("node:path"));
40
39
 
41
40
  // package.json
42
41
  var name = "create-tina-app";
43
- var version = "1.3.3";
42
+ var version = "1.4.0";
44
43
 
45
44
  // src/util/fileUtil.ts
46
45
  var import_fs_extra = __toESM(require("fs-extra"));
@@ -157,63 +156,15 @@ function updateProjectPackageVersion(dir, version2) {
157
156
 
158
157
  // src/util/install.ts
159
158
  var import_cross_spawn = __toESM(require("cross-spawn"));
160
- function install(root, dependencies, { packageManager, isOnline, devDependencies }) {
161
- const npmFlags = [];
162
- const yarnFlags = [];
163
- const pnpmFlags = [];
159
+ function install(packageManager) {
164
160
  return new Promise((resolve, reject) => {
165
- let args;
166
- const command = packageManager;
167
- if (dependencies == null ? void 0 : dependencies.length) {
168
- switch (packageManager) {
169
- case "yarn":
170
- args = ["add", "--exact"];
171
- if (!isOnline) args.push("--offline");
172
- args.push("--cwd", root);
173
- if (devDependencies) args.push("--dev");
174
- args.push(...dependencies);
175
- break;
176
- case "npm":
177
- args = ["install", "--save-exact"];
178
- args.push(devDependencies ? "--save-dev" : "--save");
179
- args.push(...dependencies);
180
- break;
181
- case "pnpm":
182
- args = ["add"];
183
- if (!isOnline) args.push("--offline");
184
- args.push("--save-exact");
185
- if (devDependencies) args.push("-D");
186
- args.push(...dependencies);
187
- break;
188
- }
189
- } else {
190
- args = ["install"];
191
- if (!isOnline) {
192
- log.warn("You appear to be offline.");
193
- if (packageManager === "yarn") {
194
- log.warn("Falling back to the local Yarn cache.");
195
- args.push("--offline");
196
- }
197
- }
198
- }
199
- switch (packageManager) {
200
- case "yarn":
201
- args.push(...yarnFlags);
202
- break;
203
- case "npm":
204
- args.push(...npmFlags);
205
- break;
206
- case "pnpm":
207
- args.push(...pnpmFlags);
208
- break;
209
- }
210
- const child = (0, import_cross_spawn.default)(command, args, {
161
+ const child = (0, import_cross_spawn.default)(packageManager, ["install"], {
211
162
  stdio: "inherit",
212
163
  env: { ...process.env, ADBLOCK: "1", DISABLE_OPENCOLLECTIVE: "1" }
213
164
  });
214
165
  child.on("close", (code) => {
215
166
  if (code !== 0) {
216
- reject({ command: `${command} ${args.join(" ")}` });
167
+ reject({ command: `${packageManager} install` });
217
168
  return;
218
169
  }
219
170
  resolve();
@@ -276,8 +227,8 @@ function initializeGit() {
276
227
  }
277
228
 
278
229
  // src/util/examples.ts
279
- var import_node_stream = require("stream");
280
- var import_promises = require("stream/promises");
230
+ var import_node_stream = require("node:stream");
231
+ var import_promises = require("node:stream/promises");
281
232
  var import_tar = require("tar");
282
233
  async function getRepoInfo(url, examplePath) {
283
234
  const [, username, name2, t, _branch, ...file] = url.pathname.split("/");
@@ -386,7 +337,7 @@ async function downloadTemplate(template, root) {
386
337
  }
387
338
  log.info(
388
339
  `Downloading files from repo ${TextStyles.link(
389
- `${repoInfo == null ? void 0 : repoInfo.username}/${repoInfo == null ? void 0 : repoInfo.name}`
340
+ `${repoInfo?.username}/${repoInfo?.name}`
390
341
  )}.`
391
342
  );
392
343
  await downloadAndExtractRepo(root, repoInfo);
@@ -434,9 +385,9 @@ async function checkPackageExists(name2) {
434
385
  }
435
386
 
436
387
  // src/index.ts
437
- var import_node_process = require("process");
388
+ var import_node_process = require("node:process");
438
389
  var import_validate_npm_package_name = __toESM(require("validate-npm-package-name"));
439
- var PKG_MANAGERS = ["npm", "yarn", "pnpm"];
390
+ var PKG_MANAGERS = ["npm", "yarn", "pnpm", "bun"];
440
391
  async function run() {
441
392
  preRunChecks();
442
393
  let projectName = "";
@@ -460,7 +411,7 @@ async function run() {
460
411
  if (opts.dir) {
461
412
  process.chdir(opts.dir);
462
413
  }
463
- const telemetry = new import_metrics.Telemetry({ disabled: opts == null ? void 0 : opts.noTelemetry });
414
+ const telemetry = new import_metrics.Telemetry({ disabled: opts?.noTelemetry });
464
415
  let template = opts.template;
465
416
  if (template) {
466
417
  template = TEMPLATES.find((_template) => _template.value === template);
@@ -557,7 +508,7 @@ async function run() {
557
508
  (0, import_node_process.exit)(1);
558
509
  }
559
510
  log.info("Installing packages.");
560
- await install(rootDir, null, { packageManager: pkgManager, isOnline: true });
511
+ await install(pkgManager);
561
512
  log.info("Initializing git repository.");
562
513
  try {
563
514
  if (initializeGit()) {
@@ -570,7 +521,7 @@ async function run() {
570
521
  log.success("Starter successfully created!");
571
522
  if (template.value === "tina-hugo-starter")
572
523
  log.warn(
573
- "Hugo is required for this starter. Install it: https://gohugo.io/installation/"
524
+ `Hugo is required for this starter. Install it via ${TextStyles.link("https://gohugo.io/installation/")}.`
574
525
  );
575
526
  log.log(TextStyles.bold("\nTo launch your app, run:\n"));
576
527
  log.cmd(`cd ${appName}
@@ -592,6 +543,5 @@ Next steps:
592
543
  run();
593
544
  // Annotate the CommonJS export names for ESM import in node:
594
545
  0 && (module.exports = {
595
- PKG_MANAGERS,
596
546
  run
597
547
  });
@@ -1,2 +1,2 @@
1
- import { PKG_MANAGERS } from '..';
2
- export declare function checkPackageExists(name: (typeof PKG_MANAGERS)[number]): Promise<boolean>;
1
+ import { PackageManager } from '..';
2
+ export declare function checkPackageExists(name: PackageManager): Promise<boolean>;
@@ -1,21 +1,7 @@
1
- interface InstallArgs {
2
- /**
3
- * The package manager to use (yarn, npm, pnpm).
4
- */
5
- packageManager: 'yarn' | 'npm' | 'pnpm';
6
- /**
7
- * Indicate whether there is an active Internet connection.
8
- */
9
- isOnline: boolean;
10
- /**
11
- * Indicate whether the given dependencies are devDependencies.
12
- */
13
- devDependencies?: boolean;
14
- }
1
+ import { PackageManager } from '..';
15
2
  /**
16
- * Spawn a package manager installation with Yarn, NPM, or PNPM.
3
+ * Spawn a package manager installation.
17
4
  *
18
5
  * @returns A Promise that resolves once the installation is finished.
19
6
  */
20
- export declare function install(root: string, dependencies: string[] | null, { packageManager, isOnline, devDependencies }: InstallArgs): Promise<void>;
21
- export {};
7
+ export declare function install(packageManager: PackageManager): Promise<void>;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "create-tina-app",
3
- "version": "1.3.3",
3
+ "version": "1.4.0",
4
4
  "main": "dist/index.js",
5
5
  "files": [
6
6
  "dist",
@@ -35,7 +35,7 @@
35
35
  "@types/prompts": "^2.4.9",
36
36
  "@types/tar": "6.1.13",
37
37
  "typescript": "^5.7.3",
38
- "@tinacms/scripts": "1.3.3"
38
+ "@tinacms/scripts": "1.4.0"
39
39
  },
40
40
  "dependencies": {
41
41
  "chalk": "4.1.2",
@@ -45,7 +45,7 @@
45
45
  "prompts": "^2.4.2",
46
46
  "tar": "7.4.0",
47
47
  "validate-npm-package-name": "^5.0.1",
48
- "@tinacms/metrics": "1.0.9"
48
+ "@tinacms/metrics": "1.1.0"
49
49
  },
50
50
  "scripts": {
51
51
  "types": "pnpm tsc",