@adobe/create-ccweb-add-on 3.0.0 → 3.1.0

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 (80) hide show
  1. package/.c8rc.json +4 -1
  2. package/bin/run.js +1 -2
  3. package/dist/app/AddOnFactory.d.ts +30 -3
  4. package/dist/app/AddOnFactory.d.ts.map +1 -1
  5. package/dist/app/AddOnFactory.js +140 -1
  6. package/dist/app/{AddOnPackageManager.d.ts → PackageManager.d.ts} +2 -2
  7. package/dist/app/PackageManager.d.ts.map +1 -0
  8. package/dist/app/{AddOnPackageManager.js → PackageManager.js} +2 -2
  9. package/dist/app/TemplateSelector.d.ts +20 -4
  10. package/dist/app/TemplateSelector.d.ts.map +1 -1
  11. package/dist/app/TemplateSelector.js +142 -1
  12. package/dist/app/index.d.ts +1 -3
  13. package/dist/app/index.d.ts.map +1 -1
  14. package/dist/app/index.js +1 -3
  15. package/dist/commands/create.d.ts +1 -1
  16. package/dist/commands/create.d.ts.map +1 -1
  17. package/dist/config/inversify.config.d.ts +1 -1
  18. package/dist/config/inversify.config.d.ts.map +1 -1
  19. package/dist/config/inversify.config.js +8 -6
  20. package/dist/templates/react-javascript/template.json +2 -2
  21. package/dist/templates/react-javascript-with-document-sandbox/template.json +2 -2
  22. package/dist/templates/react-typescript/template.json +2 -2
  23. package/dist/templates/react-typescript-with-document-sandbox/template.json +2 -2
  24. package/dist/templates/swc-javascript/template.json +2 -2
  25. package/dist/templates/swc-javascript-with-document-sandbox/template.json +2 -2
  26. package/dist/templates/swc-typescript/template.json +2 -2
  27. package/dist/templates/swc-typescript-with-document-sandbox/template.json +2 -2
  28. package/dist/tsconfig.tsbuildinfo +1 -1
  29. package/dist/validators/DirectoryValidator.d.ts +22 -11
  30. package/dist/validators/DirectoryValidator.d.ts.map +1 -1
  31. package/dist/validators/DirectoryValidator.js +152 -1
  32. package/dist/validators/EnvironmentValidator.d.ts +17 -2
  33. package/dist/validators/EnvironmentValidator.d.ts.map +1 -1
  34. package/dist/validators/EnvironmentValidator.js +149 -1
  35. package/dist/validators/index.d.ts +0 -2
  36. package/dist/validators/index.d.ts.map +1 -1
  37. package/dist/validators/index.js +0 -2
  38. package/package.json +8 -8
  39. package/src/app/AddOnFactory.ts +164 -4
  40. package/src/app/{AddOnPackageManager.ts → PackageManager.ts} +1 -1
  41. package/src/app/TemplateSelector.ts +157 -5
  42. package/src/app/index.ts +1 -3
  43. package/src/commands/create.ts +1 -1
  44. package/src/config/inversify.config.ts +10 -9
  45. package/src/test/app/{WxpAddOnFactory.spec.ts → AddOnFactory.spec.ts} +7 -6
  46. package/src/test/app/{AddOnPackageManager.spec.ts → PackageManager.spec.ts} +3 -6
  47. package/src/test/app/{AddOnTemplateSelector.spec.ts → TemplateSelector.spec.ts} +27 -14
  48. package/src/test/commands/command.spec.ts +1 -1
  49. package/src/test/commands/create.spec.ts +2 -2
  50. package/src/test/models/CLIOptions.spec.ts +1 -1
  51. package/src/test/validators/{AddOnDirectoryValidator.spec.ts → DirectoryValidator.spec.ts} +5 -6
  52. package/src/test/validators/{NodeEnvironmentValidator.spec.ts → EnvironmentValidator.spec.ts} +6 -19
  53. package/src/validators/DirectoryValidator.ts +172 -11
  54. package/src/validators/EnvironmentValidator.ts +157 -5
  55. package/src/validators/index.ts +0 -2
  56. package/templates/react-javascript/template.json +2 -2
  57. package/templates/react-javascript-with-document-sandbox/template.json +2 -2
  58. package/templates/react-typescript/template.json +2 -2
  59. package/templates/react-typescript-with-document-sandbox/template.json +2 -2
  60. package/templates/swc-javascript/template.json +2 -2
  61. package/templates/swc-javascript-with-document-sandbox/template.json +2 -2
  62. package/templates/swc-typescript/template.json +2 -2
  63. package/templates/swc-typescript-with-document-sandbox/template.json +2 -2
  64. package/dist/app/AddOnPackageManager.d.ts.map +0 -1
  65. package/dist/app/AddOnTemplateSelector.d.ts +0 -54
  66. package/dist/app/AddOnTemplateSelector.d.ts.map +0 -1
  67. package/dist/app/AddOnTemplateSelector.js +0 -168
  68. package/dist/app/WxpAddOnFactory.d.ts +0 -62
  69. package/dist/app/WxpAddOnFactory.d.ts.map +0 -1
  70. package/dist/app/WxpAddOnFactory.js +0 -159
  71. package/dist/validators/AddOnDirectoryValidator.d.ts +0 -55
  72. package/dist/validators/AddOnDirectoryValidator.d.ts.map +0 -1
  73. package/dist/validators/AddOnDirectoryValidator.js +0 -176
  74. package/dist/validators/NodeEnvironmentValidator.d.ts +0 -58
  75. package/dist/validators/NodeEnvironmentValidator.d.ts.map +0 -1
  76. package/dist/validators/NodeEnvironmentValidator.js +0 -173
  77. package/src/app/AddOnTemplateSelector.ts +0 -193
  78. package/src/app/WxpAddOnFactory.ts +0 -196
  79. package/src/validators/AddOnDirectoryValidator.ts +0 -207
  80. package/src/validators/NodeEnvironmentValidator.ts +0 -197
@@ -22,17 +22,169 @@
22
22
  * SOFTWARE.
23
23
  ********************************************************************************/
24
24
 
25
+ import type { AnalyticsService } from "@adobe/ccweb-add-on-analytics";
26
+ import { ITypes as IAnalyticsTypes } from "@adobe/ccweb-add-on-analytics";
27
+ import type { Logger } from "@adobe/ccweb-add-on-core";
28
+ import { ITypes as ICoreTypes, isNullOrWhiteSpace } from "@adobe/ccweb-add-on-core";
29
+ import { EntrypointType } from "@adobe/ccweb-add-on-manifest";
30
+ import chalk from "chalk";
31
+ import { inject, injectable } from "inversify";
32
+ import prompts from "prompts";
33
+ import "reflect-metadata";
34
+ import format from "string-template";
35
+ import { AnalyticsErrorMarkers } from "../AnalyticsMarkers.js";
36
+ import { ADD_ON_TEMPLATES, AVAILABLE_ADD_ON_TEMPLATES, PROGRAM_NAME, WITH_DOCUMENT_SANDBOX } from "../constants.js";
25
37
  import type { CLIOptions } from "../models/CLIOptions.js";
26
38
 
27
- /**
28
- * Template Selector interface.
29
- */
30
- export interface TemplateSelector {
39
+ @injectable()
40
+ export class TemplateSelector {
41
+ private readonly _logger: Logger;
42
+ private readonly _analyticsService: AnalyticsService;
43
+
44
+ /**
45
+ * Instantiate {@link TemplateSelector}.
46
+ * @param logger - {@link Logger} reference.
47
+ * @param analyticsService - {@link AnalyticsService} reference.
48
+ * @returns Reference to a new {@link TemplateSelector} instance.
49
+ */
50
+ constructor(
51
+ @inject(ICoreTypes.Logger) logger: Logger,
52
+ @inject(IAnalyticsTypes.AnalyticsService) analyticsService: AnalyticsService
53
+ ) {
54
+ this._logger = logger;
55
+ this._analyticsService = analyticsService;
56
+ }
57
+
31
58
  /**
32
59
  * Sets up a template, as selected/provided by the user
33
60
  * for scaffolding the add-on project.
34
61
  * @param options - {@link CLIOptions}.
35
62
  * @returns User selected/provided template name.
36
63
  */
37
- setupTemplate(options: CLIOptions): Promise<string>;
64
+ async setupTemplate(options: CLIOptions): Promise<string> {
65
+ await this._validateAddOnEntrypoint(options.entrypointType);
66
+
67
+ if (!isNullOrWhiteSpace(options.templateName)) {
68
+ if (AVAILABLE_ADD_ON_TEMPLATES.includes(options.templateName)) {
69
+ return options.templateName;
70
+ } else {
71
+ this._logger.warning(LOGS.chooseValidTemplate, { prefix: LOGS.newLine });
72
+ }
73
+ }
74
+
75
+ // Add a line break for better log readability.
76
+ console.log();
77
+
78
+ const templateChoices = [];
79
+ for (const [templateName, description] of ADD_ON_TEMPLATES.entries()) {
80
+ templateChoices.push({
81
+ title: this._promptMessageOption(templateName, description),
82
+ value: templateName
83
+ });
84
+ }
85
+
86
+ const templateResponse = await prompts.prompt({
87
+ type: "select",
88
+ name: "selectedTemplate",
89
+ message: this._promptMessage(LOGS.setupTemplate),
90
+ choices: templateChoices,
91
+ initial: 0
92
+ });
93
+
94
+ if (!templateResponse || !templateResponse.selectedTemplate) {
95
+ console.log();
96
+ return process.exit(0);
97
+ }
98
+
99
+ if (!AVAILABLE_ADD_ON_TEMPLATES.includes(`${templateResponse.selectedTemplate}-${WITH_DOCUMENT_SANDBOX}`)) {
100
+ return templateResponse.selectedTemplate;
101
+ }
102
+
103
+ const documentSandboxChoices = [
104
+ {
105
+ title: this._promptMessageOption(LOGS.no),
106
+ value: false
107
+ },
108
+ {
109
+ title: this._promptMessageOption(LOGS.yes),
110
+ value: true
111
+ }
112
+ ];
113
+ const documentSandboxResponse = await prompts.prompt({
114
+ type: "select",
115
+ name: "includeDocumentSandbox",
116
+ message: this._promptMessage(LOGS.includeDocumentSandbox),
117
+ choices: documentSandboxChoices,
118
+ initial: 0
119
+ });
120
+
121
+ if (!documentSandboxResponse || documentSandboxResponse.includeDocumentSandbox === undefined) {
122
+ console.log();
123
+ return process.exit(0);
124
+ }
125
+
126
+ // Append `with-document-sandbox` to the template name if user wants to include document sandbox
127
+ return documentSandboxResponse.includeDocumentSandbox
128
+ ? `${templateResponse.selectedTemplate}-${WITH_DOCUMENT_SANDBOX}`
129
+ : templateResponse.selectedTemplate;
130
+ }
131
+
132
+ private _promptMessage(message: string): string {
133
+ return chalk.cyan(message);
134
+ }
135
+
136
+ private _promptMessageOption(option: string, description?: string): string {
137
+ if (description) {
138
+ return `${chalk.hex("#E59400").bold(`[${option}]:`)} ${chalk.green(description)}`;
139
+ }
140
+ return chalk.green.bold(option);
141
+ }
142
+
143
+ /**
144
+ * Validate whether entrypointType is valid or not.
145
+ * @param entrypointType - Add-on entrypoint. For example: panel.
146
+ */
147
+ private async _validateAddOnEntrypoint(entrypointType: EntrypointType): Promise<void> {
148
+ if (entrypointType !== EntrypointType.PANEL) {
149
+ this._logger.warning(LOGS.chooseValidEntrypointType);
150
+ this._logger.warning(
151
+ format(LOGS.executeProgramWithValidEntrypointType, {
152
+ PROGRAM_NAME
153
+ }),
154
+ {
155
+ prefix: LOGS.tab
156
+ }
157
+ );
158
+ this._logger.message(LOGS.forExample, { prefix: LOGS.newLine });
159
+ this._logger.information(
160
+ format(LOGS.executeProgramWithValidEntrypointTypeExample, {
161
+ PROGRAM_NAME
162
+ }),
163
+ {
164
+ prefix: LOGS.tab
165
+ }
166
+ );
167
+
168
+ await this._analyticsService.postEvent(
169
+ AnalyticsErrorMarkers.ERROR_INVALID_KIND,
170
+ LOGS.analyticsInvalidEntrypointType,
171
+ false
172
+ );
173
+ return process.exit(0);
174
+ }
175
+ }
38
176
  }
177
+ const LOGS = {
178
+ newLine: "\n",
179
+ tab: " ",
180
+ setupTemplate: "Please select a template which you want to scaffold the Add-on project with",
181
+ chooseValidEntrypointType: "Please choose a valid Add-on entrypoint (valid entrypoint: panel)",
182
+ executeProgramWithValidEntrypointType: "{PROGRAM_NAME} <add-on-name> --entrypoint <panel>",
183
+ executeProgramWithValidEntrypointTypeExample: "{PROGRAM_NAME} my-add-on --entrypoint panel",
184
+ chooseValidTemplate: "You have chosen an invalid template.",
185
+ forExample: "For example:",
186
+ analyticsInvalidEntrypointType: "Invalid Add-on entrypoint specified",
187
+ includeDocumentSandbox: "Do you want to include document sandbox runtime?",
188
+ yes: "Yes",
189
+ no: "No"
190
+ };
package/src/app/index.ts CHANGED
@@ -23,7 +23,5 @@
23
23
  ********************************************************************************/
24
24
 
25
25
  export * from "./AddOnFactory.js";
26
- export * from "./AddOnPackageManager.js";
27
- export * from "./AddOnTemplateSelector.js";
26
+ export * from "./PackageManager.js";
28
27
  export * from "./TemplateSelector.js";
29
- export * from "./WxpAddOnFactory.js";
@@ -27,7 +27,7 @@ import { UncaughtExceptionHandler } from "@adobe/ccweb-add-on-core";
27
27
  import { EntrypointType } from "@adobe/ccweb-add-on-manifest";
28
28
  import type { Config } from "@oclif/core";
29
29
  import { Args, Flags } from "@oclif/core";
30
- import { Arg, CustomOptions, OptionFlag } from "@oclif/core/lib/interfaces/parser.js";
30
+ import type { Arg, CustomOptions, OptionFlag } from "@oclif/core/lib/interfaces/parser.js";
31
31
  import "reflect-metadata";
32
32
  import { AnalyticsErrorMarkers } from "../AnalyticsMarkers.js";
33
33
  import type { AddOnFactory } from "../app/AddOnFactory.js";
@@ -23,22 +23,23 @@
23
23
  ********************************************************************************/
24
24
 
25
25
  import { IContainer as ICoreContainer } from "@adobe/ccweb-add-on-core";
26
+ import type { Container } from "inversify";
26
27
  import "reflect-metadata";
27
- import type { AddOnFactory, TemplateSelector } from "../app/index.js";
28
- import { AddOnTemplateSelector, WxpAddOnFactory } from "../app/index.js";
29
- import type { DirectoryValidator, EnvironmentValidator } from "../validators/index.js";
30
- import { AddOnDirectoryValidator, NodeEnvironmentValidator } from "../validators/index.js";
28
+ import { AddOnFactory } from "../app/AddOnFactory.js";
29
+ import { TemplateSelector } from "../app/TemplateSelector.js";
30
+ import { DirectoryValidator } from "../validators/DirectoryValidator.js";
31
+ import { EnvironmentValidator } from "../validators/EnvironmentValidator.js";
32
+
31
33
  import { ITypes } from "./inversify.types.js";
32
- import { Container } from "inversify";
33
34
 
34
35
  const container: Container = ICoreContainer;
35
36
 
36
- container.bind<AddOnFactory>(ITypes.AddOnFactory).to(WxpAddOnFactory).inSingletonScope();
37
+ container.bind<AddOnFactory>(ITypes.AddOnFactory).to(AddOnFactory).inSingletonScope();
37
38
 
38
- container.bind<DirectoryValidator>(ITypes.DirectoryValidator).to(AddOnDirectoryValidator).inSingletonScope();
39
+ container.bind<DirectoryValidator>(ITypes.DirectoryValidator).to(DirectoryValidator).inSingletonScope();
39
40
 
40
- container.bind<EnvironmentValidator>(ITypes.EnvironmentValidator).to(NodeEnvironmentValidator).inSingletonScope();
41
+ container.bind<EnvironmentValidator>(ITypes.EnvironmentValidator).to(EnvironmentValidator).inSingletonScope();
41
42
 
42
- container.bind<TemplateSelector>(ITypes.TemplateSelector).to(AddOnTemplateSelector).inSingletonScope();
43
+ container.bind<TemplateSelector>(ITypes.TemplateSelector).to(TemplateSelector).inSingletonScope();
43
44
 
44
45
  export { container as IContainer };
@@ -38,12 +38,13 @@ import type { StubbedInstance } from "ts-sinon";
38
38
  import { stubInterface } from "ts-sinon";
39
39
  import url from "url";
40
40
  import { AnalyticsErrorMarkers, AnalyticsSuccessMarkers } from "../../AnalyticsMarkers.js";
41
- import type { AddOnFactory, TemplateSelector } from "../../app/index.js";
42
- import { WxpAddOnFactory } from "../../app/index.js";
43
- import { CLIOptions } from "../../models/index.js";
44
- import type { DirectoryValidator, EnvironmentValidator } from "../../validators/index.js";
41
+ import { AddOnFactory } from "../../app/AddOnFactory.js";
42
+ import type { TemplateSelector } from "../../app/TemplateSelector.js";
43
+ import { CLIOptions } from "../../models/CLIOptions.js";
44
+ import type { DirectoryValidator } from "../../validators/DirectoryValidator.js";
45
+ import type { EnvironmentValidator } from "../../validators/EnvironmentValidator.js";
45
46
 
46
- describe("WxpAddOnFactory", () => {
47
+ describe("AddOnFactory", () => {
47
48
  let sandbox: SinonSandbox;
48
49
 
49
50
  let directoryValidator: StubbedInstance<DirectoryValidator>;
@@ -74,7 +75,7 @@ describe("WxpAddOnFactory", () => {
74
75
  analyticsService = stubInterface();
75
76
  analyticsService.postEvent.resolves();
76
77
 
77
- addOnFactory = new WxpAddOnFactory(
78
+ addOnFactory = new AddOnFactory(
78
79
  directoryValidator,
79
80
  environmentValidator,
80
81
  templateSelector,
@@ -26,17 +26,14 @@ import { PackageJson } from "@adobe/ccweb-add-on-core";
26
26
  import { EntrypointType } from "@adobe/ccweb-add-on-manifest";
27
27
  import { assert } from "chai";
28
28
  import "mocha";
29
- import { AddOnPackageManager } from "../../app/index.js";
29
+ import { PackageManager } from "../../app/PackageManager.js";
30
30
 
31
- describe("AddOnManager", () => {
31
+ describe("PackageManager", () => {
32
32
  describe("getPackageJson", () => {
33
33
  const runs = [{ entrypointType: EntrypointType.PANEL, addOnName: "test-app" }];
34
34
  runs.forEach(run => {
35
35
  it("should return package.json.", async () => {
36
- const packageJson = AddOnPackageManager.getPackageJson(
37
- run.entrypointType as EntrypointType,
38
- run.addOnName
39
- );
36
+ const packageJson = PackageManager.getPackageJson(run.entrypointType as EntrypointType, run.addOnName);
40
37
  const expectedPackageJson = new PackageJson({
41
38
  name: run.addOnName,
42
39
  version: "1.0.0",
@@ -34,12 +34,11 @@ import sinon from "sinon";
34
34
  import type { StubbedInstance } from "ts-sinon";
35
35
  import { stubInterface } from "ts-sinon";
36
36
  import { AnalyticsErrorMarkers } from "../../AnalyticsMarkers.js";
37
- import { AddOnTemplateSelector } from "../../app/AddOnTemplateSelector.js";
38
- import type { TemplateSelector } from "../../app/TemplateSelector.js";
37
+ import { TemplateSelector } from "../../app/TemplateSelector.js";
39
38
  import { ADD_ON_TEMPLATES, PROGRAM_NAME, WITH_DOCUMENT_SANDBOX } from "../../constants.js";
40
- import { CLIOptions } from "../../models/index.js";
39
+ import { CLIOptions } from "../../models/CLIOptions.js";
41
40
 
42
- describe("AddOnTemplateSelector", () => {
41
+ describe("TemplateSelector", () => {
43
42
  let sandbox: SinonSandbox;
44
43
 
45
44
  let logger: StubbedInstance<Logger>;
@@ -79,7 +78,7 @@ describe("AddOnTemplateSelector", () => {
79
78
  false
80
79
  );
81
80
 
82
- const templateSelector: TemplateSelector = new AddOnTemplateSelector(logger, analyticsService);
81
+ const templateSelector: TemplateSelector = new TemplateSelector(logger, analyticsService);
83
82
 
84
83
  await templateSelector.setupTemplate(options);
85
84
 
@@ -128,7 +127,7 @@ describe("AddOnTemplateSelector", () => {
128
127
  false
129
128
  );
130
129
 
131
- const templateSelector: TemplateSelector = new AddOnTemplateSelector(logger, analyticsService);
130
+ const templateSelector: TemplateSelector = new TemplateSelector(logger, analyticsService);
132
131
  await templateSelector.setupTemplate(cliOptions);
133
132
 
134
133
  assert.equal(logger.warning.callCount, 2);
@@ -169,7 +168,7 @@ describe("AddOnTemplateSelector", () => {
169
168
  it("should return the passed template name if present in CLIOptions and is a valid one.", async () => {
170
169
  const cliOptions = new CLIOptions(EntrypointType.PANEL, "test-app", templateName, false);
171
170
 
172
- const templateSelector: TemplateSelector = new AddOnTemplateSelector(logger, analyticsService);
171
+ const templateSelector: TemplateSelector = new TemplateSelector(logger, analyticsService);
173
172
  const template = await templateSelector.setupTemplate(cliOptions);
174
173
 
175
174
  assert.equal(analyticsService.postEvent.callCount, 0);
@@ -196,7 +195,7 @@ describe("AddOnTemplateSelector", () => {
196
195
 
197
196
  const cliOptions = new CLIOptions(EntrypointType.PANEL, "test-app", "incorrect-template", false);
198
197
 
199
- const templateSelector: TemplateSelector = new AddOnTemplateSelector(logger, analyticsService);
198
+ const templateSelector: TemplateSelector = new TemplateSelector(logger, analyticsService);
200
199
  const template = await templateSelector.setupTemplate(cliOptions);
201
200
 
202
201
  assert.equal(template, templateChoices[1].value);
@@ -224,7 +223,7 @@ describe("AddOnTemplateSelector", () => {
224
223
  });
225
224
 
226
225
  const cliOptions = new CLIOptions(EntrypointType.PANEL, "test-app", "", false);
227
- const templateSelector: TemplateSelector = new AddOnTemplateSelector(logger, analyticsService);
226
+ const templateSelector: TemplateSelector = new TemplateSelector(logger, analyticsService);
228
227
  const template = await templateSelector.setupTemplate(cliOptions);
229
228
 
230
229
  assert.equal(logger.warning.callCount, 0);
@@ -252,7 +251,7 @@ describe("AddOnTemplateSelector", () => {
252
251
 
253
252
  const cliOptions = new CLIOptions(EntrypointType.PANEL, "test-app", "", false);
254
253
 
255
- const templateSelector: TemplateSelector = new AddOnTemplateSelector(logger, analyticsService);
254
+ const templateSelector: TemplateSelector = new TemplateSelector(logger, analyticsService);
256
255
  const template = await templateSelector.setupTemplate(cliOptions);
257
256
 
258
257
  assert.equal(logger.warning.callCount, 0);
@@ -260,14 +259,28 @@ describe("AddOnTemplateSelector", () => {
260
259
  assert.equal(analyticsService.postEvent.callCount, 0);
261
260
  });
262
261
 
263
- it("should exit if user doesnt select any prompted value and template is not passed.", async () => {
262
+ it("should return the custom template if the variant is not available.", async () => {
263
+ const customTemplate = "custom-template";
264
+ const promptsStub = sandbox.stub(prompts, "prompt");
265
+ promptsStub.resolves({ selectedTemplate: customTemplate });
266
+
267
+ const cliOptions = new CLIOptions(EntrypointType.PANEL, "test-app", "", false);
268
+ const templateSelector: TemplateSelector = new TemplateSelector(logger, analyticsService);
269
+ const template = await templateSelector.setupTemplate(cliOptions);
270
+
271
+ assert.equal(template, customTemplate);
272
+ assert.equal(logger.warning.callCount, 0);
273
+ assert.equal(analyticsService.postEvent.callCount, 0);
274
+ });
275
+
276
+ it("should exit if user does not select any prompted value and template is not passed.", async () => {
264
277
  const promptsStub = sandbox.stub(prompts, "prompt");
265
278
  const exitProcessStub = sandbox.stub(process, "exit");
266
279
  promptsStub.resolves({ selectedTemplate: undefined });
267
280
 
268
281
  const cliOptions = new CLIOptions(EntrypointType.PANEL, "test-app", "", false);
269
282
 
270
- const templateSelector: TemplateSelector = new AddOnTemplateSelector(logger, analyticsService);
283
+ const templateSelector: TemplateSelector = new TemplateSelector(logger, analyticsService);
271
284
  await templateSelector.setupTemplate(cliOptions);
272
285
 
273
286
  assert.equal(logger.warning.callCount, 0);
@@ -275,14 +288,14 @@ describe("AddOnTemplateSelector", () => {
275
288
  assert.equal(analyticsService.postEvent.callCount, 0);
276
289
  });
277
290
 
278
- it("should exit if user doesnt select any option in document sandbox prompt.", async () => {
291
+ it("should exit if user does not select any option in document sandbox prompt.", async () => {
279
292
  const promptsStub = sandbox.stub(prompts, "prompt");
280
293
  const exitProcessStub = sandbox.stub(process, "exit");
281
294
  promptsStub.resolves({ selectedTemplate: templateChoices[1].value, includeDocumentSandbox: undefined });
282
295
 
283
296
  const cliOptions = new CLIOptions(EntrypointType.PANEL, "test-app", "", false);
284
297
 
285
- const templateSelector: TemplateSelector = new AddOnTemplateSelector(logger, analyticsService);
298
+ const templateSelector: TemplateSelector = new TemplateSelector(logger, analyticsService);
286
299
  await templateSelector.setupTemplate(cliOptions);
287
300
 
288
301
  assert.equal(logger.warning.callCount, 0);
@@ -31,7 +31,7 @@ import "mocha";
31
31
  import sinon from "sinon";
32
32
  import type { StubbedInstance } from "ts-sinon";
33
33
  import { stubInterface } from "ts-sinon";
34
- import { AddOnFactory } from "../../app/AddOnFactory.js";
34
+ import type { AddOnFactory } from "../../app/AddOnFactory.js";
35
35
  import { IContainer, ITypes } from "../../config/index.js";
36
36
  import { CLIOptions } from "../../models/CLIOptions.js";
37
37
 
@@ -34,10 +34,10 @@ import sinon from "sinon";
34
34
  import type { StubbedInstance } from "ts-sinon";
35
35
  import { stubInterface } from "ts-sinon";
36
36
  import { AnalyticsErrorMarkers } from "../../AnalyticsMarkers.js";
37
- import type { AddOnFactory } from "../../app/index.js";
37
+ import type { AddOnFactory } from "../../app/AddOnFactory.js";
38
38
  import { Create } from "../../commands/create.js";
39
39
  import { IContainer, ITypes } from "../../config/index.js";
40
- import { CLIOptions } from "../../models/index.js";
40
+ import { CLIOptions } from "../../models/CLIOptions.js";
41
41
 
42
42
  chai.use(chaiAsPromised);
43
43
 
@@ -25,7 +25,7 @@
25
25
  import { EntrypointType } from "@adobe/ccweb-add-on-manifest";
26
26
  import { assert } from "chai";
27
27
  import "mocha";
28
- import { CLIOptions } from "../../models/index.js";
28
+ import { CLIOptions } from "../../models/CLIOptions.js";
29
29
 
30
30
  describe("CLIOptions", () => {
31
31
  describe("constructor", () => {
@@ -37,10 +37,9 @@ import { stubInterface } from "ts-sinon";
37
37
  import { AnalyticsErrorMarkers } from "../../AnalyticsMarkers.js";
38
38
  import { PROGRAM_NAME } from "../../constants.js";
39
39
  import { CLIOptions } from "../../models/CLIOptions.js";
40
- import type { DirectoryValidator } from "../../validators/index.js";
41
- import { AddOnDirectoryValidator } from "../../validators/index.js";
40
+ import { DirectoryValidator } from "../../validators/DirectoryValidator.js";
42
41
 
43
- describe("AddOnDirectoryValidator", () => {
42
+ describe("DirectoryValidator", () => {
44
43
  let sandbox: SinonSandbox;
45
44
 
46
45
  let analyticsService: StubbedInstance<AnalyticsService>;
@@ -54,7 +53,7 @@ describe("AddOnDirectoryValidator", () => {
54
53
  analyticsService = stubInterface<AnalyticsService>();
55
54
  logger = stubInterface<Logger>();
56
55
 
57
- validator = new AddOnDirectoryValidator(logger, analyticsService);
56
+ validator = new DirectoryValidator(logger, analyticsService);
58
57
  });
59
58
 
60
59
  afterEach(() => {
@@ -65,7 +64,7 @@ describe("AddOnDirectoryValidator", () => {
65
64
  let runs = [{ addOnName: "" }, { addOnName: " " }];
66
65
  runs.forEach(run => {
67
66
  it(`should exit for empty addOn name: ${run.addOnName}.`, async () => {
68
- const validator: DirectoryValidator = new AddOnDirectoryValidator(logger, analyticsService);
67
+ const validator: DirectoryValidator = new DirectoryValidator(logger, analyticsService);
69
68
  const processExitStub = sandbox.stub(process, "exit");
70
69
 
71
70
  await validator.validateAddOnName(run.addOnName);
@@ -239,7 +238,7 @@ describe("AddOnDirectoryValidator", () => {
239
238
 
240
239
  analyticsService.postEvent.resolves();
241
240
 
242
- const validator: DirectoryValidator = new AddOnDirectoryValidator(logger, analyticsService);
241
+ const validator: DirectoryValidator = new DirectoryValidator(logger, analyticsService);
243
242
 
244
243
  const cliOptions = new CLIOptions(EntrypointType.PANEL, "test-add-on", "javascript", false);
245
244
  await validator.validateAddOnName(cliOptions.addOnName);
@@ -33,10 +33,9 @@ import type { StubbedInstance } from "ts-sinon";
33
33
  import { stubInterface } from "ts-sinon";
34
34
  import { AnalyticsErrorMarkers } from "../../AnalyticsMarkers.js";
35
35
  import { PROGRAM_NAME } from "../../constants.js";
36
- import type { EnvironmentValidator } from "../../validators/index.js";
37
- import { NodeEnvironmentValidator } from "../../validators/index.js";
36
+ import { EnvironmentValidator } from "../../validators/EnvironmentValidator.js";
38
37
 
39
- describe("NodeEnvironmentValidator", () => {
38
+ describe("EnvironmentValidator", () => {
40
39
  let sandbox: SinonSandbox;
41
40
 
42
41
  let cliProcess: StubbedInstance<Process>;
@@ -55,7 +54,7 @@ describe("NodeEnvironmentValidator", () => {
55
54
 
56
55
  logger = stubInterface();
57
56
 
58
- validator = new NodeEnvironmentValidator(cliProcess, logger, analyticsService);
57
+ validator = new EnvironmentValidator(cliProcess, logger, analyticsService);
59
58
  });
60
59
 
61
60
  afterEach(() => {
@@ -66,11 +65,7 @@ describe("NodeEnvironmentValidator", () => {
66
65
  const runs = [{ version: "10.0.0" }, { version: "17.9.9" }];
67
66
  runs.forEach(({ version }) => {
68
67
  it(`should exit for lower node version: ${version}.`, async () => {
69
- const validator: EnvironmentValidator = new NodeEnvironmentValidator(
70
- cliProcess,
71
- logger,
72
- analyticsService
73
- );
68
+ const validator: EnvironmentValidator = new EnvironmentValidator(cliProcess, logger, analyticsService);
74
69
  const processExitStub = sandbox.stub(process, "exit");
75
70
 
76
71
  cliProcess.executeSync
@@ -116,11 +111,7 @@ describe("NodeEnvironmentValidator", () => {
116
111
  const dataList = [{ data: undefined }, { data: "" }];
117
112
  dataList.forEach(({ data }) => {
118
113
  it("should exit for no npm version.", async () => {
119
- const validator: EnvironmentValidator = new NodeEnvironmentValidator(
120
- cliProcess,
121
- logger,
122
- analyticsService
123
- );
114
+ const validator: EnvironmentValidator = new EnvironmentValidator(cliProcess, logger, analyticsService);
124
115
  const processExitStub = sandbox.stub(process, "exit");
125
116
 
126
117
  cliProcess.executeSync
@@ -150,11 +141,7 @@ describe("NodeEnvironmentValidator", () => {
150
141
  const runs = [{ version: "3.0.0" }, { version: "9.9.9" }];
151
142
  runs.forEach(run => {
152
143
  it(`should exit for lower npm version: ${run.version}.`, async () => {
153
- const validator: EnvironmentValidator = new NodeEnvironmentValidator(
154
- cliProcess,
155
- logger,
156
- analyticsService
157
- );
144
+ const validator: EnvironmentValidator = new EnvironmentValidator(cliProcess, logger, analyticsService);
158
145
  const processExitStub = sandbox.stub(process, "exit");
159
146
 
160
147
  cliProcess.executeSync