@thegetty/quire-cli 1.0.0-rc.45 → 1.0.0-rc.46

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 (245) hide show
  1. package/CHANGELOG.md +0 -36
  2. package/README.md +0 -9
  3. package/bin/cli.js +1 -46
  4. package/package.json +10 -27
  5. package/src/Command.js +6 -26
  6. package/src/commands/README.md +122 -213
  7. package/src/commands/build.js +37 -45
  8. package/src/commands/clean.js +19 -33
  9. package/src/commands/conf.js +43 -0
  10. package/src/commands/create.js +14 -42
  11. package/src/commands/epub.js +31 -67
  12. package/src/commands/index.js +2 -9
  13. package/src/commands/info.js +86 -88
  14. package/src/commands/pdf.js +82 -63
  15. package/src/commands/preview.js +31 -32
  16. package/src/commands/validate.js +20 -64
  17. package/src/commands/version.js +43 -0
  18. package/src/errors/validation/validation-error.js +11 -20
  19. package/src/helpers/clean.js +1 -1
  20. package/src/helpers/is-quire.js +31 -0
  21. package/src/helpers/test-cwd.js +6 -5
  22. package/src/helpers/which.js +4 -10
  23. package/src/lib/11ty/README.md +19 -135
  24. package/src/lib/11ty/api.js +93 -235
  25. package/src/lib/11ty/cli.js +37 -112
  26. package/src/lib/11ty/index.js +5 -64
  27. package/src/lib/11ty/paths.js +103 -0
  28. package/src/lib/README.md +0 -330
  29. package/src/lib/conf/README.md +69 -86
  30. package/src/lib/conf/config.js +3 -5
  31. package/src/lib/conf/defaults.js +0 -65
  32. package/src/lib/conf/schema.js +9 -103
  33. package/src/lib/epub/README.md +2 -133
  34. package/src/lib/epub/epub.js +11 -36
  35. package/src/lib/epub/index.js +21 -111
  36. package/src/lib/epub/pandoc.js +4 -33
  37. package/src/lib/git/README.md +2 -151
  38. package/src/lib/git/index.js +13 -217
  39. package/src/lib/i18n/README.md +3 -0
  40. package/src/lib/i18n/config.js +53 -0
  41. package/src/lib/i18n/index.js +43 -0
  42. package/src/lib/i18n/localeService.js +58 -0
  43. package/src/lib/pdf/README.md +0 -131
  44. package/src/lib/pdf/index.js +21 -124
  45. package/src/lib/pdf/paged.js +52 -100
  46. package/src/lib/pdf/prince.js +37 -115
  47. package/src/lib/pdf/split.js +33 -61
  48. package/src/lib/quire/README.md +19 -0
  49. package/src/lib/quire/index.js +353 -0
  50. package/src/lib/reporter/README.md +2 -211
  51. package/src/lib/reporter/index.js +0 -607
  52. package/src/main.js +48 -221
  53. package/src/packageConfig.js +0 -17
  54. package/src/validators/utils.js +1 -2
  55. package/man/quire.1 +0 -341
  56. package/man/quire.1.md +0 -232
  57. package/schemas/config.schema.json +0 -194
  58. package/schemas/figures.schema.json +0 -56
  59. package/schemas/layout.schema.json +0 -5
  60. package/schemas/objects.schema.json +0 -62
  61. package/schemas/publication.schema.json +0 -140
  62. package/schemas/references.schema.json +0 -29
  63. package/src/Command.spec.js +0 -99
  64. package/src/commands/build.spec.js +0 -113
  65. package/src/commands/build.test.js +0 -397
  66. package/src/commands/clean.spec.js +0 -118
  67. package/src/commands/clean.test.js +0 -382
  68. package/src/commands/config.js +0 -238
  69. package/src/commands/config.spec.js +0 -107
  70. package/src/commands/config.test.js +0 -845
  71. package/src/commands/create.spec.js +0 -112
  72. package/src/commands/create.test.js +0 -415
  73. package/src/commands/doctor.js +0 -251
  74. package/src/commands/doctor.spec.js +0 -115
  75. package/src/commands/doctor.test.js +0 -1409
  76. package/src/commands/epub.spec.js +0 -114
  77. package/src/commands/epub.test.js +0 -503
  78. package/src/commands/help.js +0 -60
  79. package/src/commands/help.test.js +0 -132
  80. package/src/commands/info.spec.js +0 -72
  81. package/src/commands/info.test.js +0 -512
  82. package/src/commands/pdf.spec.js +0 -114
  83. package/src/commands/pdf.test.js +0 -464
  84. package/src/commands/preview.spec.js +0 -97
  85. package/src/commands/preview.test.js +0 -250
  86. package/src/commands/use.js +0 -56
  87. package/src/commands/use.spec.js +0 -61
  88. package/src/commands/use.test.js +0 -280
  89. package/src/commands/validate.spec.js +0 -90
  90. package/src/commands/validate.test.js +0 -378
  91. package/src/commands/workflows.js +0 -70
  92. package/src/errors/build/build-failed-error.js +0 -19
  93. package/src/errors/build/config-field-missing-error.js +0 -20
  94. package/src/errors/build/config-file-not-found-error.js +0 -20
  95. package/src/errors/build/index.js +0 -11
  96. package/src/errors/help/help-topic-not-found-error.js +0 -30
  97. package/src/errors/help/index.js +0 -8
  98. package/src/errors/index.js +0 -58
  99. package/src/errors/input/index.js +0 -8
  100. package/src/errors/input/invalid-input-error.js +0 -21
  101. package/src/errors/install/dependency-install-error.js +0 -19
  102. package/src/errors/install/directory-not-empty-error.js +0 -25
  103. package/src/errors/install/index.js +0 -12
  104. package/src/errors/install/invalid-path-error.js +0 -31
  105. package/src/errors/install/invalid-starter-error.js +0 -27
  106. package/src/errors/install/version-not-found-error.js +0 -35
  107. package/src/errors/output/epub-generation-error.js +0 -19
  108. package/src/errors/output/index.js +0 -14
  109. package/src/errors/output/invalid-epub-library-error.js +0 -20
  110. package/src/errors/output/invalid-pdf-library-error.js +0 -20
  111. package/src/errors/output/missing-build-output-error.js +0 -21
  112. package/src/errors/output/pdf-generation-error.js +0 -24
  113. package/src/errors/output/tool-not-found-error.js +0 -37
  114. package/src/errors/project/index.js +0 -10
  115. package/src/errors/project/not-in-project-error.js +0 -20
  116. package/src/errors/project/project-create-error.js +0 -21
  117. package/src/errors/quire-error.js +0 -27
  118. package/src/errors/validation/index.js +0 -3
  119. package/src/errors/validation/unknown-config-key-error.js +0 -27
  120. package/src/errors/validation/unknown-config-operation-error.js +0 -24
  121. package/src/helpers/docs-url.js +0 -32
  122. package/src/helpers/pager.js +0 -59
  123. package/src/helpers/pager.test.js +0 -85
  124. package/src/helpers/suggest-similar.js +0 -124
  125. package/src/helpers/suggest-similar.test.js +0 -108
  126. package/src/helpers/test-cwd.test.js +0 -192
  127. package/src/lib/11ty/index.test.js +0 -655
  128. package/src/lib/commander/index.js +0 -103
  129. package/src/lib/commander/index.test.js +0 -86
  130. package/src/lib/commander/options.js +0 -237
  131. package/src/lib/commander/options.test.js +0 -205
  132. package/src/lib/conf/build-status.js +0 -103
  133. package/src/lib/conf/build-status.test.js +0 -247
  134. package/src/lib/conf/config.test.js +0 -281
  135. package/src/lib/conf/format.js +0 -60
  136. package/src/lib/conf/format.test.js +0 -106
  137. package/src/lib/conf/helpers.js +0 -91
  138. package/src/lib/conf/helpers.test.js +0 -136
  139. package/src/lib/conf/index.js +0 -22
  140. package/src/lib/constants.js +0 -28
  141. package/src/lib/doctor/README.md +0 -667
  142. package/src/lib/doctor/checks/environment/cli-version.js +0 -62
  143. package/src/lib/doctor/checks/environment/cli-version.test.js +0 -132
  144. package/src/lib/doctor/checks/environment/git-available.js +0 -77
  145. package/src/lib/doctor/checks/environment/git-available.test.js +0 -52
  146. package/src/lib/doctor/checks/environment/index.js +0 -13
  147. package/src/lib/doctor/checks/environment/node-version.js +0 -66
  148. package/src/lib/doctor/checks/environment/node-version.test.js +0 -17
  149. package/src/lib/doctor/checks/environment/npm-available.js +0 -66
  150. package/src/lib/doctor/checks/environment/npm-available.test.js +0 -52
  151. package/src/lib/doctor/checks/environment/os-info.js +0 -48
  152. package/src/lib/doctor/checks/environment/os-info.test.js +0 -81
  153. package/src/lib/doctor/checks/environment/runtime-info.js +0 -51
  154. package/src/lib/doctor/checks/environment/runtime-info.test.js +0 -132
  155. package/src/lib/doctor/checks/outputs/epub-output.js +0 -119
  156. package/src/lib/doctor/checks/outputs/epub-output.test.js +0 -277
  157. package/src/lib/doctor/checks/outputs/index.js +0 -10
  158. package/src/lib/doctor/checks/outputs/pdf-output.js +0 -144
  159. package/src/lib/doctor/checks/outputs/pdf-output.test.js +0 -377
  160. package/src/lib/doctor/checks/outputs/stale-build.js +0 -122
  161. package/src/lib/doctor/checks/outputs/stale-build.test.js +0 -282
  162. package/src/lib/doctor/checks/project/data-files.js +0 -56
  163. package/src/lib/doctor/checks/project/data-files.test.js +0 -125
  164. package/src/lib/doctor/checks/project/dependencies.js +0 -53
  165. package/src/lib/doctor/checks/project/dependencies.test.js +0 -71
  166. package/src/lib/doctor/checks/project/index.js +0 -11
  167. package/src/lib/doctor/checks/project/quire-11ty.js +0 -98
  168. package/src/lib/doctor/checks/project/quire-11ty.test.js +0 -170
  169. package/src/lib/doctor/checks/project/quire-project.js +0 -38
  170. package/src/lib/doctor/checks/project/quire-project.test.js +0 -47
  171. package/src/lib/doctor/checks/tools/index.js +0 -10
  172. package/src/lib/doctor/checks/tools/pandoc-available.js +0 -82
  173. package/src/lib/doctor/checks/tools/pandoc-available.test.js +0 -73
  174. package/src/lib/doctor/checks/tools/prince-available.js +0 -81
  175. package/src/lib/doctor/checks/tools/prince-available.test.js +0 -73
  176. package/src/lib/doctor/constants.js +0 -39
  177. package/src/lib/doctor/formatDuration.js +0 -108
  178. package/src/lib/doctor/formatDuration.test.js +0 -76
  179. package/src/lib/doctor/formatters/human.js +0 -257
  180. package/src/lib/doctor/formatters/human.test.js +0 -463
  181. package/src/lib/doctor/formatters/index.js +0 -8
  182. package/src/lib/doctor/formatters/json.js +0 -78
  183. package/src/lib/doctor/formatters/json.test.js +0 -174
  184. package/src/lib/doctor/formatters/shared.js +0 -129
  185. package/src/lib/doctor/formatters/shared.test.js +0 -194
  186. package/src/lib/doctor/index.js +0 -271
  187. package/src/lib/doctor/index.test.js +0 -797
  188. package/src/lib/epub/engines.js +0 -46
  189. package/src/lib/epub/index.test.js +0 -518
  190. package/src/lib/epub/pandoc.test.js +0 -122
  191. package/src/lib/epub/schema.js +0 -21
  192. package/src/lib/error/README.md +0 -170
  193. package/src/lib/error/handler.js +0 -107
  194. package/src/lib/git/index.spec.js +0 -80
  195. package/src/lib/git/index.test.js +0 -453
  196. package/src/lib/help/frontmatter.js +0 -77
  197. package/src/lib/help/frontmatter.test.js +0 -139
  198. package/src/lib/help/index.js +0 -146
  199. package/src/lib/help/index.test.js +0 -188
  200. package/src/lib/help/topics/configuration.md +0 -77
  201. package/src/lib/help/topics/debugging.md +0 -69
  202. package/src/lib/help/topics/epub.md +0 -74
  203. package/src/lib/help/topics/pdf.md +0 -74
  204. package/src/lib/help/topics/publishing.md +0 -80
  205. package/src/lib/help/topics/workflows.md +0 -50
  206. package/src/lib/installer/index.js +0 -309
  207. package/src/lib/installer/index.spec.js +0 -83
  208. package/src/lib/installer/index.test.js +0 -545
  209. package/src/lib/logger/README.md +0 -424
  210. package/src/lib/logger/debug.js +0 -132
  211. package/src/lib/logger/debug.spec.js +0 -130
  212. package/src/lib/logger/debug.test.js +0 -128
  213. package/src/lib/logger/index.js +0 -228
  214. package/src/lib/logger/index.spec.js +0 -131
  215. package/src/lib/logger/index.test.js +0 -578
  216. package/src/lib/npm/README.md +0 -127
  217. package/src/lib/npm/index.js +0 -198
  218. package/src/lib/npm/index.spec.js +0 -60
  219. package/src/lib/npm/index.test.js +0 -355
  220. package/src/lib/pdf/engines.js +0 -46
  221. package/src/lib/pdf/index.test.js +0 -708
  222. package/src/lib/pdf/paged.test.js +0 -366
  223. package/src/lib/pdf/prince.test.js +0 -202
  224. package/src/lib/pdf/schema.js +0 -21
  225. package/src/lib/pdf/split.test.js +0 -445
  226. package/src/lib/platform.js +0 -95
  227. package/src/lib/process/manager.js +0 -110
  228. package/src/lib/process/manager.test.js +0 -55
  229. package/src/lib/project/build.js +0 -162
  230. package/src/lib/project/build.test.js +0 -275
  231. package/src/lib/project/config.js +0 -48
  232. package/src/lib/project/config.test.js +0 -134
  233. package/src/lib/project/detect.js +0 -47
  234. package/src/lib/project/detect.test.js +0 -157
  235. package/src/lib/project/index.js +0 -56
  236. package/src/lib/project/output-paths.js +0 -87
  237. package/src/lib/project/output-paths.test.js +0 -66
  238. package/src/lib/project/paths.js +0 -272
  239. package/src/lib/project/version.js +0 -110
  240. package/src/lib/project/version.test.js +0 -350
  241. package/src/lib/reporter/index.test.js +0 -862
  242. package/src/main.spec.js +0 -61
  243. package/src/main.test.js +0 -347
  244. package/src/validators/validate-data-files.js +0 -154
  245. package/src/validators/validate-data-files.test.js +0 -217
@@ -1,655 +0,0 @@
1
- import esmock from 'esmock'
2
- import sinon from 'sinon'
3
- import test from 'ava'
4
-
5
- /**
6
- * Eleventy Module Integration Tests
7
- *
8
- * Tests the Eleventy façade module behavior with mocked dependencies.
9
- * Uses esmock to replace execa and paths for isolated testing.
10
- */
11
-
12
- test.beforeEach((t) => {
13
- t.context.sandbox = sinon.createSandbox()
14
- })
15
-
16
- test.afterEach.always((t) => {
17
- t.context.sandbox.restore()
18
- })
19
-
20
- // ─────────────────────────────────────────────────────────────────────────────
21
- // CLI module tests
22
- // ─────────────────────────────────────────────────────────────────────────────
23
-
24
- test('cli.build() runs eleventy with correct arguments', async (t) => {
25
- const { sandbox } = t.context
26
-
27
- const mockExeca = sandbox.stub().returns({
28
- all: { pipe: sandbox.stub() },
29
- exitCode: 0
30
- })
31
-
32
- const mockPaths = {
33
- getConfigPath: () => '/project/.eleventy.js',
34
- getEleventyRoot: () => '/project',
35
- getInputDir: () => '/project/content',
36
- getOutputDir: () => '/project/_site',
37
- getProjectRoot: () => '/project',
38
- getDataDir: () => '/project/content/_data',
39
- getIncludesDir: () => '/project/_includes',
40
- getLayoutsDir: () => '/project/_layouts',
41
- toObject: () => ({})
42
- }
43
-
44
- const mockFs = {
45
- readFileSync: sandbox.stub().returns(JSON.stringify({ version: '3.0.0' }))
46
- }
47
-
48
- const cli = await esmock('./cli.js', {
49
- execa: { execa: mockExeca },
50
- '#lib/project/index.js': { default: mockPaths },
51
- 'node:fs': mockFs
52
- })
53
-
54
- await cli.build({})
55
-
56
- t.true(mockExeca.calledOnce)
57
- const [cmd, args, options] = mockExeca.firstCall.args
58
- t.is(cmd, 'node')
59
- t.true(args.some(arg => arg.includes('cmd.cjs')))
60
- t.true(args.some(arg => arg.includes('--config=')))
61
- t.true(args.some(arg => arg.includes('--input=')))
62
- t.true(args.some(arg => arg.includes('--output=')))
63
- t.is(options.env.ELEVENTY_ENV, 'production')
64
- })
65
-
66
- test('cli.build() passes quiet option when specified', async (t) => {
67
- const { sandbox } = t.context
68
-
69
- const mockExeca = sandbox.stub().returns({
70
- all: { pipe: sandbox.stub() },
71
- exitCode: 0
72
- })
73
-
74
- const mockPaths = {
75
- getConfigPath: () => '/project/.eleventy.js',
76
- getEleventyRoot: () => '/project',
77
- getInputDir: () => '/project/content',
78
- getOutputDir: () => '/project/_site',
79
- getProjectRoot: () => '/project',
80
- getDataDir: () => '/project/content/_data',
81
- getIncludesDir: () => '/project/_includes',
82
- getLayoutsDir: () => '/project/_layouts',
83
- toObject: () => ({})
84
- }
85
-
86
- const mockFs = {
87
- readFileSync: sandbox.stub().returns(JSON.stringify({ version: '3.0.0' }))
88
- }
89
-
90
- const cli = await esmock('./cli.js', {
91
- execa: { execa: mockExeca },
92
- '#lib/project/index.js': { default: mockPaths },
93
- 'node:fs': mockFs
94
- })
95
-
96
- await cli.build({ quiet: true })
97
-
98
- const [, args] = mockExeca.firstCall.args
99
- t.true(args.includes('--quiet'))
100
- })
101
-
102
- test('cli.build() passes verbose option when specified', async (t) => {
103
- const { sandbox } = t.context
104
-
105
- const mockExeca = sandbox.stub().returns({
106
- all: { pipe: sandbox.stub() },
107
- exitCode: 0
108
- })
109
-
110
- const mockPaths = {
111
- getConfigPath: () => '/project/.eleventy.js',
112
- getEleventyRoot: () => '/project',
113
- getInputDir: () => '/project/content',
114
- getOutputDir: () => '/project/_site',
115
- getProjectRoot: () => '/project',
116
- getDataDir: () => '/project/content/_data',
117
- getIncludesDir: () => '/project/_includes',
118
- getLayoutsDir: () => '/project/_layouts',
119
- toObject: () => ({})
120
- }
121
-
122
- const mockFs = {
123
- readFileSync: sandbox.stub().returns(JSON.stringify({ version: '3.0.0' }))
124
- }
125
-
126
- const cli = await esmock('./cli.js', {
127
- execa: { execa: mockExeca },
128
- '#lib/project/index.js': { default: mockPaths },
129
- 'node:fs': mockFs
130
- })
131
-
132
- await cli.build({ verbose: true })
133
-
134
- const [, args] = mockExeca.firstCall.args
135
- t.true(args.includes('--verbose'))
136
- })
137
-
138
- test('cli.build() sets DEBUG environment variable when debug option is true', async (t) => {
139
- const { sandbox } = t.context
140
-
141
- const mockExeca = sandbox.stub().returns({
142
- all: { pipe: sandbox.stub() },
143
- exitCode: 0
144
- })
145
-
146
- const mockPaths = {
147
- getConfigPath: () => '/project/.eleventy.js',
148
- getEleventyRoot: () => '/project',
149
- getInputDir: () => '/project/content',
150
- getOutputDir: () => '/project/_site',
151
- getProjectRoot: () => '/project',
152
- getDataDir: () => '/project/content/_data',
153
- getIncludesDir: () => '/project/_includes',
154
- getLayoutsDir: () => '/project/_layouts',
155
- toObject: () => ({})
156
- }
157
-
158
- const mockFs = {
159
- readFileSync: sandbox.stub().returns(JSON.stringify({ version: '3.0.0' }))
160
- }
161
-
162
- const cli = await esmock('./cli.js', {
163
- execa: { execa: mockExeca },
164
- '#lib/project/index.js': { default: mockPaths },
165
- 'node:fs': mockFs
166
- })
167
-
168
- await cli.build({ debug: true })
169
-
170
- const [, , options] = mockExeca.firstCall.args
171
- t.is(options.env.DEBUG, 'Eleventy*')
172
- })
173
-
174
- test('cli.build() passes dryrun option when specified', async (t) => {
175
- const { sandbox } = t.context
176
-
177
- const mockExeca = sandbox.stub().returns({
178
- all: { pipe: sandbox.stub() },
179
- exitCode: 0
180
- })
181
-
182
- const mockPaths = {
183
- getConfigPath: () => '/project/.eleventy.js',
184
- getEleventyRoot: () => '/project',
185
- getInputDir: () => '/project/content',
186
- getOutputDir: () => '/project/_site',
187
- getProjectRoot: () => '/project',
188
- getDataDir: () => '/project/content/_data',
189
- getIncludesDir: () => '/project/_includes',
190
- getLayoutsDir: () => '/project/_layouts',
191
- toObject: () => ({})
192
- }
193
-
194
- const mockFs = {
195
- readFileSync: sandbox.stub().returns(JSON.stringify({ version: '3.0.0' }))
196
- }
197
-
198
- const cli = await esmock('./cli.js', {
199
- execa: { execa: mockExeca },
200
- '#lib/project/index.js': { default: mockPaths },
201
- 'node:fs': mockFs
202
- })
203
-
204
- await cli.build({ dryRun: true })
205
-
206
- const [, args] = mockExeca.firstCall.args
207
- t.true(args.includes('--dryrun'))
208
- })
209
-
210
- test('cli.serve() runs eleventy with --serve flag', async (t) => {
211
- const { sandbox } = t.context
212
-
213
- const mockExeca = sandbox.stub().returns({
214
- all: { pipe: sandbox.stub() }
215
- })
216
-
217
- const mockPaths = {
218
- getConfigPath: () => '/project/.eleventy.js',
219
- getEleventyRoot: () => '/project',
220
- getInputDir: () => '/project/content',
221
- getOutputDir: () => '/project/_site',
222
- getProjectRoot: () => '/project',
223
- getDataDir: () => '/project/content/_data',
224
- getIncludesDir: () => '/project/_includes',
225
- getLayoutsDir: () => '/project/_layouts',
226
- toObject: () => ({})
227
- }
228
-
229
- const mockFs = {
230
- readFileSync: sandbox.stub().returns(JSON.stringify({ version: '3.0.0' }))
231
- }
232
-
233
- const cli = await esmock('./cli.js', {
234
- execa: { execa: mockExeca },
235
- '#lib/project/index.js': { default: mockPaths },
236
- 'node:fs': mockFs
237
- })
238
-
239
- await cli.serve({})
240
-
241
- const [, args, options] = mockExeca.firstCall.args
242
- t.true(args.includes('--serve'))
243
- t.is(options.env.ELEVENTY_ENV, 'development')
244
- })
245
-
246
- test('cli.serve() passes port option when specified', async (t) => {
247
- const { sandbox } = t.context
248
-
249
- const mockExeca = sandbox.stub().returns({
250
- all: { pipe: sandbox.stub() }
251
- })
252
-
253
- const mockPaths = {
254
- getConfigPath: () => '/project/.eleventy.js',
255
- getEleventyRoot: () => '/project',
256
- getInputDir: () => '/project/content',
257
- getOutputDir: () => '/project/_site',
258
- getProjectRoot: () => '/project',
259
- getDataDir: () => '/project/content/_data',
260
- getIncludesDir: () => '/project/_includes',
261
- getLayoutsDir: () => '/project/_layouts',
262
- toObject: () => ({})
263
- }
264
-
265
- const mockFs = {
266
- readFileSync: sandbox.stub().returns(JSON.stringify({ version: '3.0.0' }))
267
- }
268
-
269
- const cli = await esmock('./cli.js', {
270
- execa: { execa: mockExeca },
271
- '#lib/project/index.js': { default: mockPaths },
272
- 'node:fs': mockFs
273
- })
274
-
275
- await cli.serve({ port: 8080 })
276
-
277
- const [, args] = mockExeca.firstCall.args
278
- t.true(args.includes('--port=8080'))
279
- })
280
-
281
- test('cli uses cmd.js for Eleventy v2', async (t) => {
282
- const { sandbox } = t.context
283
-
284
- const mockExeca = sandbox.stub().returns({
285
- all: { pipe: sandbox.stub() },
286
- exitCode: 0
287
- })
288
-
289
- const mockPaths = {
290
- getConfigPath: () => '/project/.eleventy.js',
291
- getEleventyRoot: () => '/project',
292
- getInputDir: () => '/project/content',
293
- getOutputDir: () => '/project/_site',
294
- getProjectRoot: () => '/project',
295
- getDataDir: () => '/project/content/_data',
296
- getIncludesDir: () => '/project/_includes',
297
- getLayoutsDir: () => '/project/_layouts',
298
- toObject: () => ({})
299
- }
300
-
301
- const mockFs = {
302
- readFileSync: sandbox.stub().returns(JSON.stringify({ version: '2.0.1' }))
303
- }
304
-
305
- const cli = await esmock('./cli.js', {
306
- execa: { execa: mockExeca },
307
- '#lib/project/index.js': { default: mockPaths },
308
- 'node:fs': mockFs
309
- })
310
-
311
- await cli.build({})
312
-
313
- const [, args] = mockExeca.firstCall.args
314
- t.true(args.some(arg => arg.includes('cmd.js')))
315
- t.false(args.some(arg => arg.includes('cmd.cjs')))
316
- })
317
-
318
- // ─────────────────────────────────────────────────────────────────────────────
319
- // API module tests
320
- // ─────────────────────────────────────────────────────────────────────────────
321
-
322
- test('configureEleventyEnv sets required environment variables', async (t) => {
323
- const { sandbox } = t.context
324
-
325
- // Save original env
326
- const originalEnv = { ...process.env }
327
-
328
- const mockPaths = {
329
- getDataDir: () => '/project/content/_data',
330
- getIncludesDir: () => '/project/_includes',
331
- getLayoutsDir: () => '/project/_layouts'
332
- }
333
-
334
- const { configureEleventyEnv } = await esmock('./api.js', {
335
- '#lib/project/index.js': { default: mockPaths },
336
- '#helpers/os-utils.js': { dynamicImport: sandbox.stub() }
337
- })
338
-
339
- configureEleventyEnv({ mode: 'production', debug: false })
340
-
341
- t.is(process.env.ELEVENTY_DATA, '/project/content/_data')
342
- t.is(process.env.ELEVENTY_INCLUDES, '/project/_includes')
343
- t.is(process.env.ELEVENTY_LAYOUTS, '/project/_layouts')
344
- t.is(process.env.ELEVENTY_ENV, 'production')
345
-
346
- // Restore original env
347
- Object.assign(process.env, originalEnv)
348
- })
349
-
350
- test('configureEleventyEnv sets DEBUG when debug is true', async (t) => {
351
- const { sandbox } = t.context
352
-
353
- const originalDebug = process.env.DEBUG
354
-
355
- const mockPaths = {
356
- getDataDir: () => '/project/content/_data',
357
- getIncludesDir: () => '/project/_includes',
358
- getLayoutsDir: () => '/project/_layouts'
359
- }
360
-
361
- const { configureEleventyEnv } = await esmock('./api.js', {
362
- '#lib/project/index.js': { default: mockPaths },
363
- '#helpers/os-utils.js': { dynamicImport: sandbox.stub() }
364
- })
365
-
366
- configureEleventyEnv({ mode: 'development', debug: true })
367
-
368
- t.is(process.env.DEBUG, 'Eleventy*')
369
- t.is(process.env.ELEVENTY_ENV, 'development')
370
-
371
- // Restore
372
- if (originalDebug !== undefined) {
373
- process.env.DEBUG = originalDebug
374
- } else {
375
- delete process.env.DEBUG
376
- }
377
- })
378
-
379
- // ─────────────────────────────────────────────────────────────────────────────
380
- // Index module exports tests
381
- // ─────────────────────────────────────────────────────────────────────────────
382
-
383
- test('index exports eleventy singleton with build and serve methods', async (t) => {
384
- const { sandbox } = t.context
385
-
386
- const mockPaths = {
387
- getProjectRoot: () => '/project',
388
- getDataDir: () => '/project/content/_data',
389
- getIncludesDir: () => '/project/_includes',
390
- getLayoutsDir: () => '/project/_layouts',
391
- getConfigPath: () => '/project/.eleventy.js',
392
- getEleventyRoot: () => '/project',
393
- getInputDir: () => '/project/content',
394
- getOutputDir: () => '/project/_site',
395
- toObject: () => ({})
396
- }
397
-
398
- const eleventy = await esmock('./index.js', {
399
- '#lib/project/index.js': {
400
- default: mockPaths,
401
- Paths: class MockPaths {},
402
- loadProjectConfig: sandbox.stub()
403
- },
404
- '#helpers/os-utils.js': { dynamicImport: sandbox.stub() }
405
- })
406
-
407
- t.is(typeof eleventy.default.build, 'function')
408
- t.is(typeof eleventy.default.serve, 'function')
409
- t.truthy(eleventy.default.paths)
410
- })
411
-
412
- test('index exports api object for backwards compatibility', async (t) => {
413
- const { sandbox } = t.context
414
-
415
- const mockPaths = {
416
- getProjectRoot: () => '/project',
417
- getDataDir: () => '/project/content/_data',
418
- getIncludesDir: () => '/project/_includes',
419
- getLayoutsDir: () => '/project/_layouts',
420
- getConfigPath: () => '/project/.eleventy.js',
421
- getEleventyRoot: () => '/project',
422
- getInputDir: () => '/project/content',
423
- getOutputDir: () => '/project/_site',
424
- toObject: () => ({})
425
- }
426
-
427
- const { api } = await esmock('./index.js', {
428
- '#lib/project/index.js': {
429
- default: mockPaths,
430
- Paths: class MockPaths {},
431
- loadProjectConfig: sandbox.stub()
432
- },
433
- '#helpers/os-utils.js': { dynamicImport: sandbox.stub() }
434
- })
435
-
436
- t.is(typeof api.build, 'function')
437
- t.is(typeof api.serve, 'function')
438
- })
439
-
440
- test('index exports cli object', async (t) => {
441
- const { sandbox } = t.context
442
-
443
- const mockPaths = {
444
- getProjectRoot: () => '/project',
445
- getDataDir: () => '/project/content/_data',
446
- getIncludesDir: () => '/project/_includes',
447
- getLayoutsDir: () => '/project/_layouts',
448
- getConfigPath: () => '/project/.eleventy.js',
449
- getEleventyRoot: () => '/project',
450
- getInputDir: () => '/project/content',
451
- getOutputDir: () => '/project/_site',
452
- toObject: () => ({})
453
- }
454
-
455
- const { cli } = await esmock('./index.js', {
456
- '#lib/project/index.js': {
457
- default: mockPaths,
458
- Paths: class MockPaths {},
459
- loadProjectConfig: sandbox.stub()
460
- },
461
- '#helpers/os-utils.js': { dynamicImport: sandbox.stub() }
462
- })
463
-
464
- t.is(typeof cli.build, 'function')
465
- t.is(typeof cli.serve, 'function')
466
- })
467
-
468
- // ─────────────────────────────────────────────────────────────────────────────
469
- // Lifecycle management tests
470
- // ─────────────────────────────────────────────────────────────────────────────
471
-
472
- test('Quire11ty.isActive() returns false when no process is active', async (t) => {
473
- const { sandbox } = t.context
474
-
475
- const mockPaths = {
476
- getProjectRoot: () => '/project',
477
- getDataDir: () => '/project/content/_data',
478
- getIncludesDir: () => '/project/_includes',
479
- getLayoutsDir: () => '/project/_layouts'
480
- }
481
-
482
- const { Quire11ty } = await esmock('./api.js', {
483
- '#lib/project/index.js': { default: mockPaths },
484
- '#helpers/os-utils.js': { dynamicImport: sandbox.stub() }
485
- })
486
-
487
- const eleventy = new Quire11ty(mockPaths)
488
- t.false(eleventy.isActive())
489
- })
490
-
491
- test('Quire11ty.isActive() returns true when activeInstance is set', async (t) => {
492
- const { sandbox } = t.context
493
-
494
- const mockPaths = {
495
- getProjectRoot: () => '/project',
496
- getDataDir: () => '/project/content/_data',
497
- getIncludesDir: () => '/project/_includes',
498
- getLayoutsDir: () => '/project/_layouts'
499
- }
500
-
501
- const { Quire11ty } = await esmock('./api.js', {
502
- '#lib/project/index.js': { default: mockPaths },
503
- '#helpers/os-utils.js': { dynamicImport: sandbox.stub() }
504
- })
505
-
506
- const eleventy = new Quire11ty(mockPaths)
507
- t.false(eleventy.isActive())
508
-
509
- // Simulate setting an active instance
510
- eleventy.activeInstance = { close: sandbox.stub() }
511
- t.true(eleventy.isActive())
512
- })
513
-
514
- test('Quire11ty.close() clears activeInstance', async (t) => {
515
- const { sandbox } = t.context
516
-
517
- const mockPaths = {
518
- getProjectRoot: () => '/project',
519
- getDataDir: () => '/project/content/_data',
520
- getIncludesDir: () => '/project/_includes',
521
- getLayoutsDir: () => '/project/_layouts'
522
- }
523
-
524
- const { Quire11ty } = await esmock('./api.js', {
525
- '#lib/project/index.js': { default: mockPaths },
526
- '#helpers/os-utils.js': { dynamicImport: sandbox.stub() }
527
- })
528
-
529
- const eleventy = new Quire11ty(mockPaths)
530
- eleventy.activeInstance = { close: sandbox.stub().resolves() }
531
- t.true(eleventy.isActive())
532
-
533
- await eleventy.close()
534
- t.false(eleventy.isActive())
535
- })
536
-
537
- test('Quire11ty.close() calls close on active Eleventy instance', async (t) => {
538
- const { sandbox } = t.context
539
-
540
- const mockPaths = {
541
- getProjectRoot: () => '/project',
542
- getDataDir: () => '/project/content/_data',
543
- getIncludesDir: () => '/project/_includes',
544
- getLayoutsDir: () => '/project/_layouts'
545
- }
546
-
547
- const { Quire11ty } = await esmock('./api.js', {
548
- '#lib/project/index.js': { default: mockPaths },
549
- '#helpers/os-utils.js': { dynamicImport: sandbox.stub() }
550
- })
551
-
552
- const eleventy = new Quire11ty(mockPaths)
553
-
554
- // Simulate an active Eleventy instance
555
- const mockEleventyInstance = {
556
- close: sandbox.stub().resolves()
557
- }
558
- eleventy.activeInstance = mockEleventyInstance
559
-
560
- t.true(eleventy.isActive())
561
-
562
- await eleventy.close()
563
-
564
- t.true(mockEleventyInstance.close.calledOnce)
565
- t.false(eleventy.isActive())
566
- })
567
-
568
- test('cli.build() uses processManager.signal for cancellation', async (t) => {
569
- const { sandbox } = t.context
570
-
571
- const mockExeca = sandbox.stub().returns({
572
- all: { pipe: sandbox.stub() },
573
- exitCode: 0
574
- })
575
-
576
- const mockPaths = {
577
- getConfigPath: () => '/project/.eleventy.js',
578
- getEleventyRoot: () => '/project',
579
- getInputDir: () => '/project/content',
580
- getOutputDir: () => '/project/_site',
581
- getProjectRoot: () => '/project',
582
- getDataDir: () => '/project/content/_data',
583
- getIncludesDir: () => '/project/_includes',
584
- getLayoutsDir: () => '/project/_layouts',
585
- toObject: () => ({})
586
- }
587
-
588
- const mockFs = {
589
- readFileSync: sandbox.stub().returns(JSON.stringify({ version: '3.0.0' }))
590
- }
591
-
592
- const mockSignal = new AbortController().signal
593
- const mockProcessManager = {
594
- signal: mockSignal,
595
- onShutdown: sandbox.stub(),
596
- onShutdownComplete: sandbox.stub()
597
- }
598
-
599
- const cli = await esmock('./cli.js', {
600
- execa: { execa: mockExeca },
601
- '#lib/project/index.js': { default: mockPaths },
602
- '#lib/process/manager.js': { default: mockProcessManager },
603
- 'node:fs': mockFs
604
- })
605
-
606
- await cli.build({})
607
-
608
- const [, , options] = mockExeca.firstCall.args
609
- t.is(options.cancelSignal, mockSignal)
610
- t.true(options.gracefulCancel)
611
- })
612
-
613
- test('cli.serve() uses processManager.signal for cancellation', async (t) => {
614
- const { sandbox } = t.context
615
-
616
- const mockExeca = sandbox.stub().returns({
617
- all: { pipe: sandbox.stub() }
618
- })
619
-
620
- const mockPaths = {
621
- getConfigPath: () => '/project/.eleventy.js',
622
- getEleventyRoot: () => '/project',
623
- getInputDir: () => '/project/content',
624
- getOutputDir: () => '/project/_site',
625
- getProjectRoot: () => '/project',
626
- getDataDir: () => '/project/content/_data',
627
- getIncludesDir: () => '/project/_includes',
628
- getLayoutsDir: () => '/project/_layouts',
629
- toObject: () => ({})
630
- }
631
-
632
- const mockFs = {
633
- readFileSync: sandbox.stub().returns(JSON.stringify({ version: '3.0.0' }))
634
- }
635
-
636
- const mockSignal = new AbortController().signal
637
- const mockProcessManager = {
638
- signal: mockSignal,
639
- onShutdown: sandbox.stub(),
640
- onShutdownComplete: sandbox.stub()
641
- }
642
-
643
- const cli = await esmock('./cli.js', {
644
- execa: { execa: mockExeca },
645
- '#lib/project/index.js': { default: mockPaths },
646
- '#lib/process/manager.js': { default: mockProcessManager },
647
- 'node:fs': mockFs
648
- })
649
-
650
- await cli.serve({})
651
-
652
- const [, , options] = mockExeca.firstCall.args
653
- t.is(options.cancelSignal, mockSignal)
654
- t.true(options.gracefulCancel)
655
- })