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

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/index.js +32 -26
  2. package/package.json +1 -1
package/index.js CHANGED
@@ -15,9 +15,16 @@ const packageJson = JSON.parse(
15
15
  );
16
16
  const version = packageJson.version;
17
17
  program
18
- .name("byob")
18
+ .name("message-kit")
19
19
  .description("CLI to initialize projects")
20
20
  .action(async () => {
21
+ // Add Yarn 4 check at the start of the action
22
+ const pkgManager = detectPackageManager();
23
+ if (pkgManager.startsWith("yarn@4")) {
24
+ log.error("Yarn 4 is not supported. Please use bun, npm, or yarn v1");
25
+ process.exit(1);
26
+ }
27
+
21
28
  log.info(pc.cyan(`Welcome to MessageKit CLI v${version}!`));
22
29
  const coolLogo = `
23
30
  ███╗ ███╗███████╗███████╗███████╗ █████╗ ██████╗ ███████╗██╗ ██╗██╗████████╗
@@ -32,9 +39,6 @@ Powered by XMTP`;
32
39
 
33
40
  const { templateType, displayName, destDir } = await gatherProjectInfo();
34
41
 
35
- // Add package.json
36
- addPackagejson(destDir, displayName);
37
-
38
42
  // Create .gitignore
39
43
  createGitignore(destDir);
40
44
 
@@ -47,7 +51,8 @@ Powered by XMTP`;
47
51
  // Wrap up
48
52
  log.success(`Project launched in ${pc.red(destDir)}!`);
49
53
 
50
- const pkgManager = detectPackageManager();
54
+ // Add package.json
55
+ addPackagejson(destDir, displayName, pkgManager);
51
56
 
52
57
  // Create README.md file
53
58
  createReadme(destDir, templateType, displayName, pkgManager);
@@ -60,9 +65,9 @@ Powered by XMTP`;
60
65
 
61
66
  program.parse(process.argv);
62
67
 
63
- async function addPackagejson(destDir, name) {
68
+ async function addPackagejson(destDir, name, pkgManager) {
64
69
  // Create package.json based on the template
65
- const packageTemplate = {
70
+ let packageTemplate = {
66
71
  name: name,
67
72
  private: true,
68
73
  type: "module",
@@ -75,11 +80,17 @@ async function addPackagejson(destDir, name) {
75
80
  dependencies: {
76
81
  "@xmtp/message-kit": "latest",
77
82
  },
83
+ devDependencies: {
84
+ typescript: "^5.4.5",
85
+ },
78
86
  engines: {
79
87
  node: ">=20",
80
88
  },
81
89
  };
82
90
 
91
+ if (pkgManager.startsWith("yarn")) {
92
+ packageTemplate.packageManager = pkgManager;
93
+ }
83
94
  fs.writeJsonSync(resolve(destDir, "package.json"), packageTemplate, {
84
95
  spaces: 2,
85
96
  });
@@ -130,24 +141,6 @@ async function gatherProjectInfo() {
130
141
  return { templateType, displayName, destDir, templateDir };
131
142
  }
132
143
 
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
144
  function createTsconfig(destDir) {
152
145
  const tsconfigContent = {
153
146
  include: ["src/**/*"],
@@ -212,9 +205,22 @@ function detectPackageManager() {
212
205
  const userAgent = process.env.npm_config_user_agent;
213
206
  if (!userAgent) return "npm";
214
207
  if (userAgent.includes("bun")) return "bun";
215
- if (userAgent.includes("yarn")) return "yarn";
216
208
  if (userAgent.includes("pnpm")) return "pnpm";
217
209
  if (userAgent.includes("npm")) return "npm";
210
+
211
+ if (userAgent.includes("yarn")) {
212
+ for (const [manager, value] of Object.entries(managers)) {
213
+ if (userAgent.includes(manager)) {
214
+ // Extract version for yarn
215
+ if (manager === "yarn") {
216
+ const version =
217
+ userAgent.match(/yarn\/(\d+\.\d+\.\d+)/)?.[1] || "4.5.1";
218
+ return `${value}@${version}`;
219
+ }
220
+ return value;
221
+ }
222
+ }
223
+ }
218
224
  return "npm";
219
225
  }
220
226
 
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.23",
4
4
  "license": "MIT",
5
5
  "type": "module",
6
6
  "main": "index.js",