create-medusa-app 2.22.4 → 2.22.6

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/AGENTS.md CHANGED
@@ -15,7 +15,7 @@ Options (from `src/index.ts`):
15
15
  - `[project-name]`: prompted if missing. Names containing `.` are rejected (MikroORM path resolution breaks).
16
16
  - `--plugin`: clone `medusajs/medusa-starter-plugin` and only install dependencies (no DB, no start).
17
17
  - `--repo-url <url>`: starter to clone (default `https://github.com/medusajs/dtc-starter`, branch `main`, `--depth 1`).
18
- - `--version <version>`: pin every `@medusajs/*` dependency to this version (except `@medusajs/ui`, which is versioned separately).
18
+ - `--version <version>`: pin every `@medusajs/*` entry in `dependencies`, `devDependencies`, and `peerDependencies` to this version (except `@medusajs/ui`, which is versioned separately). Also applies with `--plugin`.
19
19
  - `--skip-db`, `--db-url <url>`, `--no-migrations`, `--no-browser`, `--directory-path <path>`.
20
20
  - `--with-nextjs-starter`: keep and install `apps/storefront`; otherwise you're prompted, and a "no" deletes it.
21
21
  - `--use-npm` / `--use-yarn` / `--use-pnpm` (mutually exclusive), `--verbose`.
package/CHANGELOG.md CHANGED
@@ -1,5 +1,22 @@
1
1
  # Change Log
2
2
 
3
+ ## 2.22.6
4
+
5
+ ### Patch Changes
6
+
7
+ - Updated dependencies []:
8
+ - @medusajs/deps@2.22.6
9
+ - @medusajs/telemetry@2.22.6
10
+
11
+ ## 2.22.5
12
+
13
+ ### Patch Changes
14
+
15
+ - [#17716](https://github.com/medusajs/medusa/pull/17716) [`d06808b`](https://github.com/medusajs/medusa/commit/d06808b468c55247b9a76fedde7dd864aec92eeb) Thanks [@medusa-os-bot](https://github.com/apps/medusa-os-bot)! - fix(create-medusa-app): apply --version to plugin dependencies and peer dependencies
16
+ - Updated dependencies []:
17
+ - @medusajs/deps@2.22.5
18
+ - @medusajs/telemetry@2.22.5
19
+
3
20
  ## 2.22.4
4
21
 
5
22
  ### Patch Changes
@@ -20,7 +20,7 @@ export default async (prepareOptions) => {
20
20
  }
21
21
  return prepareProject(prepareOptions);
22
22
  };
23
- async function preparePlugin({ directory, projectName, spinner, processManager, abortController, verbose = false, packageManager, }) {
23
+ async function preparePlugin({ directory, projectName, spinner, processManager, abortController, verbose = false, packageManager, version, }) {
24
24
  // initialize execution options
25
25
  const execOptions = {
26
26
  cwd: directory,
@@ -44,6 +44,10 @@ async function preparePlugin({ directory, projectName, spinner, processManager,
44
44
  if (packageManagerString) {
45
45
  packageJson.packageManager = packageManagerString;
46
46
  }
47
+ // Update medusa dependencies versions
48
+ if (version) {
49
+ updatePackageVersions(packageJson, version);
50
+ }
47
51
  fs.writeFileSync(packageJsonPath, JSON.stringify(packageJson, null, 2));
48
52
  factBoxOptions.interval = displayFactBox({
49
53
  ...factBoxOptions,
@@ -59,6 +59,7 @@ export class PluginProjectCreator extends BaseProjectCreator {
59
59
  abortController: this.abortController,
60
60
  verbose: this.options.verbose,
61
61
  packageManager: this.packageManager,
62
+ version: this.options.version,
62
63
  });
63
64
  }
64
65
  handleError(e) {
@@ -17,6 +17,13 @@ export function updatePackageVersions(packageJsonOrPath, version, { applyChanges
17
17
  }
18
18
  }
19
19
  }
20
+ if (packageJson.peerDependencies) {
21
+ for (const dependency of Object.keys(packageJson.peerDependencies)) {
22
+ if (shouldUpdateVersion(dependency)) {
23
+ packageJson.peerDependencies[dependency] = version;
24
+ }
25
+ }
26
+ }
20
27
  if (applyChanges && typeof packageJsonOrPath === "string") {
21
28
  writeFileSync(packageJsonOrPath, JSON.stringify(packageJson, null, 2));
22
29
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "create-medusa-app",
3
- "version": "2.22.4",
3
+ "version": "2.22.6",
4
4
  "description": "Create a Medusa project using a single command.",
5
5
  "type": "module",
6
6
  "exports": "./dist/index.js",
@@ -14,8 +14,8 @@
14
14
  "test": "../../../node_modules/.bin/jest --passWithNoTests src"
15
15
  },
16
16
  "dependencies": {
17
- "@medusajs/deps": "2.22.4",
18
- "@medusajs/telemetry": "2.22.4",
17
+ "@medusajs/deps": "2.22.6",
18
+ "@medusajs/telemetry": "2.22.6",
19
19
  "boxen": "^9.0.0",
20
20
  "chalk": "^6.0.1",
21
21
  "commander": "^15.0.0",
@@ -0,0 +1,65 @@
1
+ import fs from "fs"
2
+ import os from "os"
3
+ import path from "path"
4
+ import prepareProject from "../prepare-project"
5
+
6
+ jest.mock("../facts", () => ({
7
+ displayFactBox: jest.fn().mockReturnValue(null),
8
+ }))
9
+
10
+ describe("prepareProject", () => {
11
+ describe("plugin", () => {
12
+ let directory: string
13
+
14
+ beforeEach(() => {
15
+ directory = fs.mkdtempSync(path.join(os.tmpdir(), "cma-plugin-"))
16
+ fs.writeFileSync(
17
+ path.join(directory, "package.json"),
18
+ JSON.stringify({
19
+ name: "starter",
20
+ devDependencies: {
21
+ "@medusajs/medusa": "2.0.0",
22
+ "@medusajs/ui": "4.0.0",
23
+ },
24
+ peerDependencies: {
25
+ "@medusajs/framework": "2.0.0",
26
+ },
27
+ })
28
+ )
29
+ })
30
+
31
+ afterEach(() => {
32
+ fs.rmSync(directory, { recursive: true, force: true })
33
+ })
34
+
35
+ it("should update the plugin's @medusajs package versions when a version is passed", async () => {
36
+ const packageManager = {
37
+ getPackageManagerString: jest.fn().mockResolvedValue(undefined),
38
+ installDependencies: jest.fn().mockResolvedValue(undefined),
39
+ }
40
+
41
+ await prepareProject({
42
+ isPlugin: true,
43
+ directory,
44
+ projectName: "my-plugin",
45
+ spinner: {} as any,
46
+ processManager: {} as any,
47
+ packageManager: packageManager as any,
48
+ version: "2.5.0",
49
+ })
50
+
51
+ const packageJson = JSON.parse(
52
+ fs.readFileSync(path.join(directory, "package.json"), "utf-8")
53
+ )
54
+
55
+ expect(packageJson.name).toBe("my-plugin")
56
+ expect(packageJson.devDependencies).toEqual({
57
+ "@medusajs/medusa": "2.5.0",
58
+ "@medusajs/ui": "4.0.0",
59
+ })
60
+ expect(packageJson.peerDependencies).toEqual({
61
+ "@medusajs/framework": "2.5.0",
62
+ })
63
+ })
64
+ })
65
+ })
@@ -0,0 +1,41 @@
1
+ import { updatePackageVersions } from "../update-package-versions"
2
+
3
+ describe("updatePackageVersions", () => {
4
+ it("should update @medusajs dependencies, devDependencies, and peerDependencies except @medusajs/ui", () => {
5
+ const packageJson = {
6
+ dependencies: {
7
+ "@medusajs/medusa": "2.0.0",
8
+ "@medusajs/ui": "4.0.0",
9
+ lodash: "4.0.0",
10
+ },
11
+ devDependencies: {
12
+ "@medusajs/cli": "2.0.0",
13
+ typescript: "5.0.0",
14
+ },
15
+ peerDependencies: {
16
+ "@medusajs/framework": "2.0.0",
17
+ "@medusajs/ui": "4.0.0",
18
+ react: "18.0.0",
19
+ },
20
+ }
21
+
22
+ const result = updatePackageVersions(packageJson, "2.5.0")
23
+
24
+ expect(result).toEqual({
25
+ dependencies: {
26
+ "@medusajs/medusa": "2.5.0",
27
+ "@medusajs/ui": "4.0.0",
28
+ lodash: "4.0.0",
29
+ },
30
+ devDependencies: {
31
+ "@medusajs/cli": "2.5.0",
32
+ typescript: "5.0.0",
33
+ },
34
+ peerDependencies: {
35
+ "@medusajs/framework": "2.5.0",
36
+ "@medusajs/ui": "4.0.0",
37
+ react: "18.0.0",
38
+ },
39
+ })
40
+ })
41
+ })
@@ -30,6 +30,7 @@ type PreparePluginOptions = {
30
30
  abortController?: AbortController
31
31
  verbose?: boolean
32
32
  packageManager: PackageManager
33
+ version?: string
33
34
  }
34
35
 
35
36
  type PrepareProjectOptions = {
@@ -76,6 +77,7 @@ async function preparePlugin({
76
77
  abortController,
77
78
  verbose = false,
78
79
  packageManager,
80
+ version,
79
81
  }: PreparePluginOptions) {
80
82
  // initialize execution options
81
83
  const execOptions = {
@@ -105,6 +107,11 @@ async function preparePlugin({
105
107
  packageJson.packageManager = packageManagerString
106
108
  }
107
109
 
110
+ // Update medusa dependencies versions
111
+ if (version) {
112
+ updatePackageVersions(packageJson, version)
113
+ }
114
+
108
115
  fs.writeFileSync(packageJsonPath, JSON.stringify(packageJson, null, 2))
109
116
 
110
117
  factBoxOptions.interval = displayFactBox({
@@ -75,6 +75,7 @@ export class PluginProjectCreator
75
75
  abortController: this.abortController,
76
76
  verbose: this.options.verbose,
77
77
  packageManager: this.packageManager,
78
+ version: this.options.version,
78
79
  })
79
80
  }
80
81
 
@@ -24,6 +24,13 @@ export function updatePackageVersions(
24
24
  }
25
25
  }
26
26
  }
27
+ if (packageJson.peerDependencies) {
28
+ for (const dependency of Object.keys(packageJson.peerDependencies)) {
29
+ if (shouldUpdateVersion(dependency)) {
30
+ packageJson.peerDependencies[dependency] = version
31
+ }
32
+ }
33
+ }
27
34
 
28
35
  if (applyChanges && typeof packageJsonOrPath === "string") {
29
36
  writeFileSync(packageJsonOrPath, JSON.stringify(packageJson, null, 2))