create-message-kit 1.1.7-beta.21 → 1.1.7-beta.22

Sign up to get free protection for your applications and to get access to all the features.
Files changed (2) hide show
  1. package/index.js +29 -24
  2. package/package.json +1 -1
package/index.js CHANGED
@@ -32,6 +32,8 @@ Powered by XMTP`;
32
32
 
33
33
  const { templateType, displayName, destDir } = await gatherProjectInfo();
34
34
 
35
+ console.log("detected package manager", detectPackageManager());
36
+
35
37
  // Add package.json
36
38
  addPackagejson(destDir, displayName);
37
39
 
@@ -62,7 +64,7 @@ program.parse(process.argv);
62
64
 
63
65
  async function addPackagejson(destDir, name) {
64
66
  // Create package.json based on the template
65
- const packageTemplate = {
67
+ let packageTemplate = {
66
68
  name: name,
67
69
  private: true,
68
70
  type: "module",
@@ -79,7 +81,11 @@ async function addPackagejson(destDir, name) {
79
81
  node: ">=20",
80
82
  },
81
83
  };
82
-
84
+ // Only add packageManager field if using yarn
85
+ const pkgManager = detectPackageManager();
86
+ if (pkgManager.startsWith("yarn")) {
87
+ packageTemplate.packageManager = pkgManager;
88
+ }
83
89
  fs.writeJsonSync(resolve(destDir, "package.json"), packageTemplate, {
84
90
  spaces: 2,
85
91
  });
@@ -130,24 +136,6 @@ async function gatherProjectInfo() {
130
136
  return { templateType, displayName, destDir, templateDir };
131
137
  }
132
138
 
133
- function updateDependenciesToLatest(pkgJson) {
134
- const updateToLatest = (deps) => {
135
- for (const key in deps) {
136
- if (deps[key].startsWith("workspace:")) {
137
- deps[key] = "latest";
138
- }
139
- }
140
- };
141
-
142
- if (pkgJson.dependencies) {
143
- updateToLatest(pkgJson.dependencies);
144
- }
145
-
146
- if (pkgJson.devDependencies) {
147
- updateToLatest(pkgJson.devDependencies);
148
- }
149
- }
150
-
151
139
  function createTsconfig(destDir) {
152
140
  const tsconfigContent = {
153
141
  include: ["src/**/*"],
@@ -211,10 +199,27 @@ yarn-error.log*
211
199
  function detectPackageManager() {
212
200
  const userAgent = process.env.npm_config_user_agent;
213
201
  if (!userAgent) return "npm";
214
- if (userAgent.includes("bun")) return "bun";
215
- if (userAgent.includes("yarn")) return "yarn";
216
- if (userAgent.includes("pnpm")) return "pnpm";
217
- if (userAgent.includes("npm")) return "npm";
202
+
203
+ // Improve package manager detection
204
+ const managers = {
205
+ bun: "bun",
206
+ yarn: "yarn",
207
+ pnpm: "pnpm",
208
+ npm: "npm",
209
+ };
210
+
211
+ for (const [manager, value] of Object.entries(managers)) {
212
+ if (userAgent.includes(manager)) {
213
+ // Extract version for yarn
214
+ if (manager === "yarn") {
215
+ const version =
216
+ userAgent.match(/yarn\/(\d+\.\d+\.\d+)/)?.[1] || "4.5.1";
217
+ return `${value}@${version}`;
218
+ }
219
+ return value;
220
+ }
221
+ }
222
+
218
223
  return "npm";
219
224
  }
220
225
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "create-message-kit",
3
- "version": "1.1.7-beta.21",
3
+ "version": "1.1.7-beta.22",
4
4
  "license": "MIT",
5
5
  "type": "module",
6
6
  "main": "index.js",