create-catalyst-app 1.1.0 → 1.2.0-canary.2

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.
@@ -0,0 +1,93 @@
1
+ Copyright 2016 The Inter Project Authors (https://github.com/rsms/inter) Inter-Italic[opsz,wght].ttf: Copyright 2016 The Inter Project Authors (https://github.com/rsms/inter)
2
+
3
+ This Font Software is licensed under the SIL Open Font License, Version 1.1.
4
+ This license is copied below, and is also available with a FAQ at:
5
+ http://scripts.sil.org/OFL
6
+
7
+
8
+ -----------------------------------------------------------
9
+ SIL OPEN FONT LICENSE Version 1.1 - 26 February 2007
10
+ -----------------------------------------------------------
11
+
12
+ PREAMBLE
13
+ The goals of the Open Font License (OFL) are to stimulate worldwide
14
+ development of collaborative font projects, to support the font creation
15
+ efforts of academic and linguistic communities, and to provide a free and
16
+ open framework in which fonts may be shared and improved in partnership
17
+ with others.
18
+
19
+ The OFL allows the licensed fonts to be used, studied, modified and
20
+ redistributed freely as long as they are not sold by themselves. The
21
+ fonts, including any derivative works, can be bundled, embedded,
22
+ redistributed and/or sold with any software provided that any reserved
23
+ names are not used by derivative works. The fonts and derivatives,
24
+ however, cannot be released under any other type of license. The
25
+ requirement for fonts to remain under this license does not apply
26
+ to any document created using the fonts or their derivatives.
27
+
28
+ DEFINITIONS
29
+ "Font Software" refers to the set of files released by the Copyright
30
+ Holder(s) under this license and clearly marked as such. This may
31
+ include source files, build scripts and documentation.
32
+
33
+ "Reserved Font Name" refers to any names specified as such after the
34
+ copyright statement(s).
35
+
36
+ "Original Version" refers to the collection of Font Software components as
37
+ distributed by the Copyright Holder(s).
38
+
39
+ "Modified Version" refers to any derivative made by adding to, deleting,
40
+ or substituting -- in part or in whole -- any of the components of the
41
+ Original Version, by changing formats or by porting the Font Software to a
42
+ new environment.
43
+
44
+ "Author" refers to any designer, engineer, programmer, technical
45
+ writer or other person who contributed to the Font Software.
46
+
47
+ PERMISSION & CONDITIONS
48
+ Permission is hereby granted, free of charge, to any person obtaining
49
+ a copy of the Font Software, to use, study, copy, merge, embed, modify,
50
+ redistribute, and sell modified and unmodified copies of the Font
51
+ Software, subject to the following conditions:
52
+
53
+ 1) Neither the Font Software nor any of its individual components,
54
+ in Original or Modified Versions, may be sold by itself.
55
+
56
+ 2) Original or Modified Versions of the Font Software may be bundled,
57
+ redistributed and/or sold with any software, provided that each copy
58
+ contains the above copyright notice and this license. These can be
59
+ included either as stand-alone text files, human-readable headers or
60
+ in the appropriate machine-readable metadata fields within text or
61
+ binary files as long as those fields can be easily viewed by the user.
62
+
63
+ 3) No Modified Version of the Font Software may use the Reserved Font
64
+ Name(s) unless explicit written permission is granted by the corresponding
65
+ Copyright Holder. This restriction only applies to the primary font name as
66
+ presented to the users.
67
+
68
+ 4) The name(s) of the Copyright Holder(s) or the Author(s) of the Font
69
+ Software shall not be used to promote, endorse or advertise any
70
+ Modified Version, except to acknowledge the contribution(s) of the
71
+ Copyright Holder(s) and the Author(s) or with their explicit written
72
+ permission.
73
+
74
+ 5) The Font Software, modified or unmodified, in part or in whole,
75
+ must be distributed entirely under this license, and must not be
76
+ distributed under any other license. The requirement for fonts to
77
+ remain under this license does not apply to any document created
78
+ using the Font Software.
79
+
80
+ TERMINATION
81
+ This license becomes null and void if any of the above conditions are
82
+ not met.
83
+
84
+ DISCLAIMER
85
+ THE FONT SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
86
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO ANY WARRANTIES OF
87
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT
88
+ OF COPYRIGHT, PATENT, TRADEMARK, OR OTHER RIGHT. IN NO EVENT SHALL THE
89
+ COPYRIGHT HOLDER BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
90
+ INCLUDING ANY GENERAL, SPECIAL, INDIRECT, INCIDENTAL, OR CONSEQUENTIAL
91
+ DAMAGES, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
92
+ FROM, OUT OF THE USE OR INABILITY TO USE THE FONT SOFTWARE OR FROM
93
+ OTHER DEALINGS IN THE FONT SOFTWARE.
@@ -0,0 +1,93 @@
1
+ Copyright 2020 The JetBrains Mono Project Authors (https://github.com/JetBrains/JetBrainsMono) JetBrainsMono-Italic[wght].ttf: Copyright 2020 The JetBrains Mono Project Authors (https://github.com/JetBrains/JetBrainsMono)
2
+
3
+ This Font Software is licensed under the SIL Open Font License, Version 1.1.
4
+ This license is copied below, and is also available with a FAQ at:
5
+ http://scripts.sil.org/OFL
6
+
7
+
8
+ -----------------------------------------------------------
9
+ SIL OPEN FONT LICENSE Version 1.1 - 26 February 2007
10
+ -----------------------------------------------------------
11
+
12
+ PREAMBLE
13
+ The goals of the Open Font License (OFL) are to stimulate worldwide
14
+ development of collaborative font projects, to support the font creation
15
+ efforts of academic and linguistic communities, and to provide a free and
16
+ open framework in which fonts may be shared and improved in partnership
17
+ with others.
18
+
19
+ The OFL allows the licensed fonts to be used, studied, modified and
20
+ redistributed freely as long as they are not sold by themselves. The
21
+ fonts, including any derivative works, can be bundled, embedded,
22
+ redistributed and/or sold with any software provided that any reserved
23
+ names are not used by derivative works. The fonts and derivatives,
24
+ however, cannot be released under any other type of license. The
25
+ requirement for fonts to remain under this license does not apply
26
+ to any document created using the fonts or their derivatives.
27
+
28
+ DEFINITIONS
29
+ "Font Software" refers to the set of files released by the Copyright
30
+ Holder(s) under this license and clearly marked as such. This may
31
+ include source files, build scripts and documentation.
32
+
33
+ "Reserved Font Name" refers to any names specified as such after the
34
+ copyright statement(s).
35
+
36
+ "Original Version" refers to the collection of Font Software components as
37
+ distributed by the Copyright Holder(s).
38
+
39
+ "Modified Version" refers to any derivative made by adding to, deleting,
40
+ or substituting -- in part or in whole -- any of the components of the
41
+ Original Version, by changing formats or by porting the Font Software to a
42
+ new environment.
43
+
44
+ "Author" refers to any designer, engineer, programmer, technical
45
+ writer or other person who contributed to the Font Software.
46
+
47
+ PERMISSION & CONDITIONS
48
+ Permission is hereby granted, free of charge, to any person obtaining
49
+ a copy of the Font Software, to use, study, copy, merge, embed, modify,
50
+ redistribute, and sell modified and unmodified copies of the Font
51
+ Software, subject to the following conditions:
52
+
53
+ 1) Neither the Font Software nor any of its individual components,
54
+ in Original or Modified Versions, may be sold by itself.
55
+
56
+ 2) Original or Modified Versions of the Font Software may be bundled,
57
+ redistributed and/or sold with any software, provided that each copy
58
+ contains the above copyright notice and this license. These can be
59
+ included either as stand-alone text files, human-readable headers or
60
+ in the appropriate machine-readable metadata fields within text or
61
+ binary files as long as those fields can be easily viewed by the user.
62
+
63
+ 3) No Modified Version of the Font Software may use the Reserved Font
64
+ Name(s) unless explicit written permission is granted by the corresponding
65
+ Copyright Holder. This restriction only applies to the primary font name as
66
+ presented to the users.
67
+
68
+ 4) The name(s) of the Copyright Holder(s) or the Author(s) of the Font
69
+ Software shall not be used to promote, endorse or advertise any
70
+ Modified Version, except to acknowledge the contribution(s) of the
71
+ Copyright Holder(s) and the Author(s) or with their explicit written
72
+ permission.
73
+
74
+ 5) The Font Software, modified or unmodified, in part or in whole,
75
+ must be distributed entirely under this license, and must not be
76
+ distributed under any other license. The requirement for fonts to
77
+ remain under this license does not apply to any document created
78
+ using the Font Software.
79
+
80
+ TERMINATION
81
+ This license becomes null and void if any of the above conditions are
82
+ not met.
83
+
84
+ DISCLAIMER
85
+ THE FONT SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
86
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO ANY WARRANTIES OF
87
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT
88
+ OF COPYRIGHT, PATENT, TRADEMARK, OR OTHER RIGHT. IN NO EVENT SHALL THE
89
+ COPYRIGHT HOLDER BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
90
+ INCLUDING ANY GENERAL, SPECIAL, INDIRECT, INCIDENTAL, OR CONSEQUENTIAL
91
+ DAMAGES, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
92
+ FROM, OUT OF THE USE OR INABILITY TO USE THE FONT SOFTWARE OR FROM
93
+ OTHER DEALINGS IN THE FONT SOFTWARE.
@@ -1,4 +1,7 @@
1
- import Home from "@containers/Home/Home"
1
+ import { split } from "catalyst-core"
2
+
3
+ // split() lets Catalyst run the page's serverFetcher and clientFetcher.
4
+ const Home = split(() => import("@containers/Home/Home"))
2
5
 
3
6
  const routes = [
4
7
  {
@@ -12,7 +12,11 @@
12
12
  "buildApp:android": "catalyst buildApp:android",
13
13
  "setupEmulator": "catalyst setupEmulator",
14
14
  "setupEmulator:ios": "catalyst setupEmulator:ios",
15
- "setupEmulator:android": "catalyst setupEmulator:android"
15
+ "setupEmulator:android": "catalyst setupEmulator:android",
16
+ "android": "catalyst buildApp:android",
17
+ "ios": "catalyst buildApp:ios",
18
+ "android:release": "catalyst buildApp:android --release",
19
+ "ios:release": "catalyst buildApp:ios --release"
16
20
  },
17
21
  "_moduleAliases": {
18
22
  "@api": "api.js",
@@ -23,7 +27,7 @@
23
27
  "@routes": "src/js/routes/"
24
28
  },
25
29
  "dependencies": {
26
- "catalyst-core": "1.1.0",
30
+ "catalyst-core": "1.2.0-canary.2",
27
31
  "react": "19.0.0",
28
32
  "react-dom": "19.0.0",
29
33
  "react-router": "^7.18.2"
@@ -13,6 +13,10 @@
13
13
  "setupEmulator": "catalyst setupEmulator",
14
14
  "setupEmulator:ios": "catalyst setupEmulator:ios",
15
15
  "setupEmulator:android": "catalyst setupEmulator:android",
16
+ "android": "catalyst buildApp:android",
17
+ "ios": "catalyst buildApp:ios",
18
+ "android:release": "catalyst buildApp:android --release",
19
+ "ios:release": "catalyst buildApp:ios --release",
16
20
  "typecheck": "tsc --noEmit"
17
21
  },
18
22
  "_moduleAliases": {
@@ -24,7 +28,7 @@
24
28
  "@routes": "src/js/routes/"
25
29
  },
26
30
  "dependencies": {
27
- "catalyst-core": "1.1.0",
31
+ "catalyst-core": "1.2.0-canary.2",
28
32
  "react": "19.0.0",
29
33
  "react-dom": "19.0.0",
30
34
  "react-router": "^7.18.2"
@@ -12,7 +12,11 @@
12
12
  "buildApp:android": "catalyst buildApp:android",
13
13
  "setupEmulator": "catalyst setupEmulator",
14
14
  "setupEmulator:ios": "catalyst setupEmulator:ios",
15
- "setupEmulator:android": "catalyst setupEmulator:android"
15
+ "setupEmulator:android": "catalyst setupEmulator:android",
16
+ "android": "catalyst buildApp:android",
17
+ "ios": "catalyst buildApp:ios",
18
+ "android:release": "catalyst buildApp:android --release",
19
+ "ios:release": "catalyst buildApp:ios --release"
16
20
  },
17
21
  "_moduleAliases": {
18
22
  "@api": "api.js",
@@ -26,7 +30,7 @@
26
30
  "dependencies": {
27
31
  "@reduxjs/toolkit": "^2.9.0",
28
32
  "react-redux": "^9.2.0",
29
- "catalyst-core": "1.1.0",
33
+ "catalyst-core": "1.2.0-canary.2",
30
34
  "react": "19.0.0",
31
35
  "react-dom": "19.0.0",
32
36
  "react-router": "^7.18.2",
@@ -13,6 +13,10 @@
13
13
  "setupEmulator": "catalyst setupEmulator",
14
14
  "setupEmulator:ios": "catalyst setupEmulator:ios",
15
15
  "setupEmulator:android": "catalyst setupEmulator:android",
16
+ "android": "catalyst buildApp:android",
17
+ "ios": "catalyst buildApp:ios",
18
+ "android:release": "catalyst buildApp:android --release",
19
+ "ios:release": "catalyst buildApp:ios --release",
16
20
  "typecheck": "tsc --noEmit"
17
21
  },
18
22
  "_moduleAliases": {
@@ -27,7 +31,7 @@
27
31
  "dependencies": {
28
32
  "@reduxjs/toolkit": "^2.9.0",
29
33
  "react-redux": "^9.2.0",
30
- "catalyst-core": "1.1.0",
34
+ "catalyst-core": "1.2.0-canary.2",
31
35
  "react": "19.0.0",
32
36
  "react-dom": "19.0.0",
33
37
  "react-router": "^7.18.2",
@@ -12,7 +12,11 @@
12
12
  "buildApp:android": "catalyst buildApp:android",
13
13
  "setupEmulator": "catalyst setupEmulator",
14
14
  "setupEmulator:ios": "catalyst setupEmulator:ios",
15
- "setupEmulator:android": "catalyst setupEmulator:android"
15
+ "setupEmulator:android": "catalyst setupEmulator:android",
16
+ "android": "catalyst buildApp:android",
17
+ "ios": "catalyst buildApp:ios",
18
+ "android:release": "catalyst buildApp:android --release",
19
+ "ios:release": "catalyst buildApp:ios --release"
16
20
  },
17
21
  "_moduleAliases": {
18
22
  "@api": "api.js",
@@ -26,7 +30,7 @@
26
30
  "dependencies": {
27
31
  "@reduxjs/toolkit": "^2.9.0",
28
32
  "react-redux": "^9.2.0",
29
- "catalyst-core": "1.1.0",
33
+ "catalyst-core": "1.2.0-canary.2",
30
34
  "react": "19.0.0",
31
35
  "react-dom": "19.0.0",
32
36
  "react-router": "^7.18.2",
@@ -13,6 +13,10 @@
13
13
  "setupEmulator": "catalyst setupEmulator",
14
14
  "setupEmulator:ios": "catalyst setupEmulator:ios",
15
15
  "setupEmulator:android": "catalyst setupEmulator:android",
16
+ "android": "catalyst buildApp:android",
17
+ "ios": "catalyst buildApp:ios",
18
+ "android:release": "catalyst buildApp:android --release",
19
+ "ios:release": "catalyst buildApp:ios --release",
16
20
  "typecheck": "tsc --noEmit"
17
21
  },
18
22
  "_moduleAliases": {
@@ -27,7 +31,7 @@
27
31
  "dependencies": {
28
32
  "@reduxjs/toolkit": "^2.9.0",
29
33
  "react-redux": "^9.2.0",
30
- "catalyst-core": "1.1.0",
34
+ "catalyst-core": "1.2.0-canary.2",
31
35
  "react": "19.0.0",
32
36
  "react-dom": "19.0.0",
33
37
  "react-router": "^7.18.2",
@@ -0,0 +1,142 @@
1
+ // The app id, app name, native scripts, icon and .gitignore entries every
2
+ // new app gets (scripts/appIdentity.cjs and the templates).
3
+ const identity: typeof import("../scripts/appIdentity.cjs") = require("../scripts/appIdentity.cjs")
4
+ const fs: typeof import("fs") = require("fs")
5
+ const os: typeof import("os") = require("os")
6
+ const path: typeof import("path") = require("path")
7
+
8
+ const templates = path.join(__dirname, "..", "templates")
9
+ const STARTERS = ["none-js", "none-ts", "redux-js", "redux-ts", "rtk-js", "rtk-ts"]
10
+
11
+ const dirs: string[] = []
12
+ afterEach(() => {
13
+ for (const dir of dirs.splice(0)) fs.rmSync(dir, { recursive: true, force: true })
14
+ })
15
+
16
+ describe("deriveAppId", () => {
17
+ it.each([
18
+ ["my-shop", "com.example.myshop"],
19
+ ["@acme/My_App", "com.example.myapp"],
20
+ ["123go", "com.example.app123go"],
21
+ ["class", "com.example.classapp"],
22
+ ["---", "com.example.app"],
23
+ ])("%s -> %s", (name, id) => {
24
+ expect(identity.deriveAppId(name)).toBe(id)
25
+ })
26
+ })
27
+
28
+ describe("deriveAppName", () => {
29
+ it.each([
30
+ ["my-shop", "My Shop"],
31
+ ["@acme/my-cool_app", "My Cool App"],
32
+ ["", "Catalyst App"],
33
+ ])("%s -> %s", (name, appName) => {
34
+ expect(identity.deriveAppName(name)).toBe(appName)
35
+ })
36
+ })
37
+
38
+ describe("applyAppIdentity", () => {
39
+ function app(): string {
40
+ const dir = fs.mkdtempSync(path.join(os.tmpdir(), "cca-identity-"))
41
+ dirs.push(dir)
42
+ fs.cpSync(path.join(templates, "common", "config"), path.join(dir, "config"), { recursive: true })
43
+ return dir
44
+ }
45
+
46
+ it("sets the derived id and name and changes nothing else in the file", () => {
47
+ const dir = app()
48
+ const file = path.join(dir, "config", "config.json")
49
+ const before = fs.readFileSync(file, "utf8")
50
+ expect(identity.applyAppIdentity(dir, "my-shop")).toBe(true)
51
+ const after = fs.readFileSync(file, "utf8")
52
+ const config = JSON.parse(after)
53
+ expect(config.WEBVIEW_CONFIG.appId).toBe("com.example.myshop")
54
+ expect(config.WEBVIEW_CONFIG.appName).toBe("My Shop")
55
+ const changed = after
56
+ .split("\n")
57
+ .filter((line: string, index: number) => line !== before.split("\n")[index])
58
+ expect(changed).toHaveLength(2)
59
+ })
60
+
61
+ it("adds the keys to a config that lacks them", () => {
62
+ const dir = app()
63
+ const file = path.join(dir, "config", "config.json")
64
+ fs.writeFileSync(file, JSON.stringify({ WEBVIEW_CONFIG: { port: "3005" } }))
65
+ expect(identity.applyAppIdentity(dir, "shop")).toBe(true)
66
+ expect(JSON.parse(fs.readFileSync(file, "utf8")).WEBVIEW_CONFIG).toEqual({
67
+ appId: "com.example.shop",
68
+ appName: "Shop",
69
+ port: "3005",
70
+ })
71
+ })
72
+
73
+ it("writes nothing when config.json is missing or not JSON", () => {
74
+ const dir = app()
75
+ const file = path.join(dir, "config", "config.json")
76
+ fs.writeFileSync(file, "{ not json")
77
+ expect(identity.applyAppIdentity(dir, "shop")).toBe(false)
78
+ expect(fs.readFileSync(file, "utf8")).toBe("{ not json")
79
+ fs.rmSync(file)
80
+ expect(identity.applyAppIdentity(dir, "shop")).toBe(false)
81
+ expect(fs.existsSync(file)).toBe(false)
82
+ })
83
+
84
+ it("leaves a config without WEBVIEW_CONFIG alone", () => {
85
+ const dir = app()
86
+ const file = path.join(dir, "config", "config.json")
87
+ fs.writeFileSync(file, "{}")
88
+ expect(identity.applyAppIdentity(dir, "shop")).toBe(false)
89
+ expect(fs.readFileSync(file, "utf8")).toBe("{}")
90
+ })
91
+ })
92
+
93
+ describe("templates", () => {
94
+ it("ship appId and appName placeholders in the shared config", () => {
95
+ const config = JSON.parse(
96
+ fs.readFileSync(path.join(templates, "common", "config", "config.json"), "utf8")
97
+ )
98
+ expect(config.WEBVIEW_CONFIG).toMatchObject({
99
+ appId: expect.any(String),
100
+ appName: expect.any(String),
101
+ })
102
+ })
103
+
104
+ it("ship a square 1024 px opaque icon at public/icon.png", () => {
105
+ const png = fs.readFileSync(path.join(templates, "common", "public", "icon.png"))
106
+ expect(png.subarray(1, 4).toString()).toBe("PNG")
107
+ expect(png.readUInt32BE(16)).toBe(1024)
108
+ expect(png.readUInt32BE(20)).toBe(1024)
109
+ // Colour type 2: RGB, no alpha (App Store Connect rejects alpha).
110
+ expect(png[25]).toBe(2)
111
+ })
112
+
113
+ it.each(STARTERS)("%s has the native scripts", (starter) => {
114
+ const pkg = JSON.parse(fs.readFileSync(path.join(templates, starter, "package.json"), "utf8"))
115
+ expect(pkg.scripts).toMatchObject({
116
+ android: "catalyst buildApp:android",
117
+ ios: "catalyst buildApp:ios",
118
+ "android:release": "catalyst buildApp:android --release",
119
+ "ios:release": "catalyst buildApp:ios --release",
120
+ })
121
+ })
122
+
123
+ it("no longer ship the native-only template", () => {
124
+ expect(fs.existsSync(path.join(templates, "native"))).toBe(false)
125
+ expect(fs.existsSync(path.join(__dirname, "..", "scripts", "native.cjs"))).toBe(false)
126
+ })
127
+ })
128
+
129
+ describe("cli.cjs", () => {
130
+ const cli = fs.readFileSync(path.join(__dirname, "..", "scripts", "cli.cjs"), "utf8")
131
+
132
+ it("ignores credentials/, .catalyst/ and build-output/", () => {
133
+ for (const entry of ["credentials/", ".catalyst/", "build-output/"])
134
+ expect(cli).toContain(`"${entry}"`)
135
+ })
136
+
137
+ it("has no native prompt or flags", () => {
138
+ expect(cli).not.toContain("--native")
139
+ expect(cli).not.toContain("--app-id")
140
+ expect(cli).toContain("applyAppIdentity")
141
+ })
142
+ })
@@ -206,6 +206,46 @@ describe("formatError() — same 3-mode contract (default/verbose/debug) as cata
206
206
  })
207
207
  })
208
208
 
209
+ describe("formatError() with a cause or details", () => {
210
+ const strip = (text: string) => text.replace(new RegExp(`${String.fromCharCode(27)}\\[[0-9;]*m`, "g"), "")
211
+
212
+ it("default mode shows the cause's message, or the details when there is no cause", () => {
213
+ const caused = cca.createError(cca.ERROR_CODES.CCA_UPSTREAM_ERROR, { cause: new Error("npm ERR! 404") })
214
+ expect(cca.formatError(caused)).toContain("npm ERR! 404")
215
+ const plain = cca.createError(cca.ERROR_CODES.CCA_UPSTREAM_ERROR, { cause: "exit code 7" as any })
216
+ expect(cca.formatError(plain)).toContain("exit code 7")
217
+ const detailed = cca.createError(cca.ERROR_CODES.CCA_DIRECTORY_EXISTS, { details: "./shop is not empty" })
218
+ expect(cca.formatError(detailed).split("\n")[1]).toBe("./shop is not empty")
219
+ })
220
+
221
+ it("verbose mode names the problem from the cause, else the details", () => {
222
+ const caused = cca.createError(cca.ERROR_CODES.CCA_UPSTREAM_ERROR, { cause: new Error("ETIMEDOUT") })
223
+ expect(strip(cca.formatError(caused, "verbose"))).toContain("Problem: ETIMEDOUT")
224
+ const detailed = cca.createError(cca.ERROR_CODES.CCA_DIRECTORY_EXISTS, { details: "./shop is not empty" })
225
+ expect(strip(cca.formatError(detailed, "verbose"))).toContain("Problem: ./shop is not empty")
226
+ })
227
+
228
+ it("debug mode without a cause shows the details and the error's own stack", () => {
229
+ const err = cca.createError(cca.ERROR_CODES.CCA_DIRECTORY_EXISTS, { details: "./shop is not empty" })
230
+ const output = strip(cca.formatError(err, "debug"))
231
+ expect(output).toContain("Problem: ./shop is not empty")
232
+ expect(output).not.toContain("Environment:")
233
+ expect(output).toContain("Stack trace:")
234
+ expect(output).toContain(String(err.stack).split("\n")[0])
235
+ const stackless = Object.assign(cca.createError(cca.ERROR_CODES.CCA_DIRECTORY_EXISTS), { stack: "" })
236
+ expect(strip(cca.formatError(stackless, "debug"))).toContain("(no stack available)")
237
+ })
238
+
239
+ it("getDebugEnvInfo reports node, platform and this package's version", () => {
240
+ const info = cca.getDebugEnvInfo()
241
+ expect(info).toEqual({
242
+ node: process.version,
243
+ platform: process.platform,
244
+ createCatalystApp: require("../package.json").version,
245
+ })
246
+ })
247
+ })
248
+
209
249
  describe("resolveOutputMode() — same bare-flag contract as scriptUtils.js#resolveOutputMode", () => {
210
250
  it("detects --debug and --verbose from an argv array", () => {
211
251
  expect(cca.resolveOutputMode(["node", "cli.js", "--debug"])).toBe("debug")