@adobe/create-ccweb-add-on 2.5.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 (136) hide show
  1. package/.c8rc.json +4 -1
  2. package/.mocharc.json +9 -2
  3. package/README.md +2 -2
  4. package/bin/run.js +2 -2
  5. package/dist/app/AddOnFactory.d.ts +30 -3
  6. package/dist/app/AddOnFactory.d.ts.map +1 -1
  7. package/dist/app/AddOnFactory.js +140 -1
  8. package/dist/app/{AddOnManager.d.ts → PackageManager.d.ts} +4 -4
  9. package/dist/app/PackageManager.d.ts.map +1 -0
  10. package/dist/app/{AddOnManager.js → PackageManager.js} +5 -6
  11. package/dist/app/TemplateSelector.d.ts +20 -4
  12. package/dist/app/TemplateSelector.d.ts.map +1 -1
  13. package/dist/app/TemplateSelector.js +142 -1
  14. package/dist/app/index.d.ts +1 -3
  15. package/dist/app/index.d.ts.map +1 -1
  16. package/dist/app/index.js +1 -3
  17. package/dist/commands/create.d.ts +6 -10
  18. package/dist/commands/create.d.ts.map +1 -1
  19. package/dist/commands/create.js +11 -37
  20. package/dist/config/inversify.config.d.ts +2 -1
  21. package/dist/config/inversify.config.d.ts.map +1 -1
  22. package/dist/config/inversify.config.js +8 -6
  23. package/dist/config/inversify.types.d.ts.map +1 -1
  24. package/dist/constants.d.ts.map +1 -1
  25. package/dist/index.d.ts +25 -0
  26. package/dist/index.d.ts.map +1 -0
  27. package/dist/index.js +25 -0
  28. package/dist/models/CLIOptions.d.ts +4 -4
  29. package/dist/models/CLIOptions.d.ts.map +1 -1
  30. package/dist/models/CLIOptions.js +5 -5
  31. package/dist/templates/react-javascript/template/src/components/App.jsx +2 -2
  32. package/dist/templates/react-javascript/template/webpack.config.js +1 -0
  33. package/dist/templates/react-javascript/template.json +4 -4
  34. package/dist/templates/react-javascript-with-document-sandbox/template/src/ui/components/App.jsx +2 -2
  35. package/dist/templates/react-javascript-with-document-sandbox/template/webpack.config.js +1 -0
  36. package/dist/templates/react-javascript-with-document-sandbox/template.json +4 -4
  37. package/dist/templates/react-typescript/template/src/components/App.tsx +2 -2
  38. package/dist/templates/react-typescript/template/webpack.config.js +1 -0
  39. package/dist/templates/react-typescript/template.json +4 -4
  40. package/dist/templates/react-typescript-with-document-sandbox/template/src/ui/components/App.tsx +2 -2
  41. package/dist/templates/react-typescript-with-document-sandbox/template/webpack.config.js +1 -0
  42. package/dist/templates/react-typescript-with-document-sandbox/template.json +4 -4
  43. package/dist/templates/swc-javascript/template/src/components/App.js +2 -2
  44. package/dist/templates/swc-javascript/template/webpack.config.js +1 -0
  45. package/dist/templates/swc-javascript/template.json +4 -4
  46. package/dist/templates/swc-javascript-with-document-sandbox/template/src/ui/components/App.js +2 -2
  47. package/dist/templates/swc-javascript-with-document-sandbox/template/webpack.config.js +1 -0
  48. package/dist/templates/swc-javascript-with-document-sandbox/template.json +4 -4
  49. package/dist/templates/swc-typescript/template/src/components/App.css.ts +2 -2
  50. package/dist/templates/swc-typescript/template/src/components/App.ts +4 -4
  51. package/dist/templates/swc-typescript/template/src/index.ts +2 -2
  52. package/dist/templates/swc-typescript/template/webpack.config.js +1 -0
  53. package/dist/templates/swc-typescript/template.json +4 -4
  54. package/dist/templates/swc-typescript-with-document-sandbox/template/src/ui/components/App.css.ts +2 -2
  55. package/dist/templates/swc-typescript-with-document-sandbox/template/src/ui/components/App.ts +4 -4
  56. package/dist/templates/swc-typescript-with-document-sandbox/template/src/ui/index.ts +2 -2
  57. package/dist/templates/swc-typescript-with-document-sandbox/template/webpack.config.js +1 -0
  58. package/dist/templates/swc-typescript-with-document-sandbox/template.json +4 -4
  59. package/dist/tsconfig.tsbuildinfo +1 -1
  60. package/dist/validators/DirectoryValidator.d.ts +22 -11
  61. package/dist/validators/DirectoryValidator.d.ts.map +1 -1
  62. package/dist/validators/DirectoryValidator.js +152 -1
  63. package/dist/validators/EnvironmentValidator.d.ts +17 -2
  64. package/dist/validators/EnvironmentValidator.d.ts.map +1 -1
  65. package/dist/validators/EnvironmentValidator.js +149 -1
  66. package/dist/validators/index.d.ts +0 -2
  67. package/dist/validators/index.d.ts.map +1 -1
  68. package/dist/validators/index.js +0 -2
  69. package/package.json +26 -20
  70. package/src/app/AddOnFactory.ts +164 -4
  71. package/src/app/{AddOnManager.ts → PackageManager.ts} +4 -6
  72. package/src/app/TemplateSelector.ts +157 -5
  73. package/src/app/index.ts +1 -3
  74. package/src/commands/create.ts +24 -48
  75. package/src/config/inversify.config.ts +11 -9
  76. package/src/config/inversify.types.ts +7 -1
  77. package/src/constants.ts +2 -2
  78. package/src/index.ts +25 -0
  79. package/src/models/CLIOptions.ts +5 -5
  80. package/src/test/app/{WxpAddOnFactory.spec.ts → AddOnFactory.spec.ts} +18 -17
  81. package/src/test/app/{AddOnManager.spec.ts → PackageManager.spec.ts} +6 -6
  82. package/src/test/app/{AddOnTemplateSelector.spec.ts → TemplateSelector.spec.ts} +57 -26
  83. package/src/test/commands/command.spec.ts +80 -0
  84. package/src/test/commands/create.spec.ts +44 -18
  85. package/src/test/models/CLIOptions.spec.ts +4 -4
  86. package/src/test/validators/{AddOnDirectoryValidator.spec.ts → DirectoryValidator.spec.ts} +29 -21
  87. package/src/test/validators/{NodeEnvironmentValidator.spec.ts → EnvironmentValidator.spec.ts} +11 -24
  88. package/src/validators/DirectoryValidator.ts +172 -11
  89. package/src/validators/EnvironmentValidator.ts +157 -5
  90. package/src/validators/index.ts +0 -2
  91. package/templates/react-javascript/template/src/components/App.jsx +2 -2
  92. package/templates/react-javascript/template/webpack.config.js +1 -0
  93. package/templates/react-javascript/template.json +4 -4
  94. package/templates/react-javascript-with-document-sandbox/template/src/ui/components/App.jsx +2 -2
  95. package/templates/react-javascript-with-document-sandbox/template/webpack.config.js +1 -0
  96. package/templates/react-javascript-with-document-sandbox/template.json +4 -4
  97. package/templates/react-typescript/template/src/components/App.tsx +2 -2
  98. package/templates/react-typescript/template/webpack.config.js +1 -0
  99. package/templates/react-typescript/template.json +4 -4
  100. package/templates/react-typescript-with-document-sandbox/template/src/ui/components/App.tsx +2 -2
  101. package/templates/react-typescript-with-document-sandbox/template/webpack.config.js +1 -0
  102. package/templates/react-typescript-with-document-sandbox/template.json +4 -4
  103. package/templates/swc-javascript/template/src/components/App.js +2 -2
  104. package/templates/swc-javascript/template/webpack.config.js +1 -0
  105. package/templates/swc-javascript/template.json +4 -4
  106. package/templates/swc-javascript-with-document-sandbox/template/src/ui/components/App.js +2 -2
  107. package/templates/swc-javascript-with-document-sandbox/template/webpack.config.js +1 -0
  108. package/templates/swc-javascript-with-document-sandbox/template.json +4 -4
  109. package/templates/swc-typescript/template/src/components/App.css.ts +2 -2
  110. package/templates/swc-typescript/template/src/components/App.ts +4 -4
  111. package/templates/swc-typescript/template/src/index.ts +2 -2
  112. package/templates/swc-typescript/template/webpack.config.js +1 -0
  113. package/templates/swc-typescript/template.json +4 -4
  114. package/templates/swc-typescript-with-document-sandbox/template/src/ui/components/App.css.ts +2 -2
  115. package/templates/swc-typescript-with-document-sandbox/template/src/ui/components/App.ts +4 -4
  116. package/templates/swc-typescript-with-document-sandbox/template/src/ui/index.ts +2 -2
  117. package/templates/swc-typescript-with-document-sandbox/template/webpack.config.js +1 -0
  118. package/templates/swc-typescript-with-document-sandbox/template.json +4 -4
  119. package/tsconfig.json +3 -1
  120. package/dist/app/AddOnManager.d.ts.map +0 -1
  121. package/dist/app/AddOnTemplateSelector.d.ts +0 -54
  122. package/dist/app/AddOnTemplateSelector.d.ts.map +0 -1
  123. package/dist/app/AddOnTemplateSelector.js +0 -168
  124. package/dist/app/WxpAddOnFactory.d.ts +0 -62
  125. package/dist/app/WxpAddOnFactory.d.ts.map +0 -1
  126. package/dist/app/WxpAddOnFactory.js +0 -159
  127. package/dist/validators/AddOnDirectoryValidator.d.ts +0 -55
  128. package/dist/validators/AddOnDirectoryValidator.d.ts.map +0 -1
  129. package/dist/validators/AddOnDirectoryValidator.js +0 -176
  130. package/dist/validators/NodeEnvironmentValidator.d.ts +0 -58
  131. package/dist/validators/NodeEnvironmentValidator.d.ts.map +0 -1
  132. package/dist/validators/NodeEnvironmentValidator.js +0 -173
  133. package/src/app/AddOnTemplateSelector.ts +0 -193
  134. package/src/app/WxpAddOnFactory.ts +0 -196
  135. package/src/validators/AddOnDirectoryValidator.ts +0 -207
  136. package/src/validators/NodeEnvironmentValidator.ts +0 -197
@@ -28,21 +28,19 @@ import type { EntrypointType } from "@adobe/ccweb-add-on-manifest";
28
28
  /**
29
29
  * Class to manage the Add-on project requirements.
30
30
  */
31
- export class AddOnManager {
31
+ export class PackageManager {
32
32
  /**
33
33
  * Get package.json for the Add-on project.
34
- * @param addOnKind - Kind of Add-on. For example: panel.
34
+ * @param entrypointType - Entrypoint type of Add-on. For example: panel, command, etc.
35
35
  * @param addOnName - Name of Add-on.
36
36
  * @returns package.json as {@link PackageJson}.
37
37
  */
38
-
39
- // ToDo: [WXP-1625] Update the addOnKind parameter to entrypointType
40
- static getPackageJson(addOnKind: EntrypointType, addOnName: string): PackageJson {
38
+ static getPackageJson(entrypointType: EntrypointType, addOnName: string): PackageJson {
41
39
  return new PackageJson({
42
40
  name: addOnName,
43
41
  version: "1.0.0",
44
42
  description: "Adobe Creative Cloud Web Add-on.",
45
- keywords: ["Adobe", "Creative Cloud Web", "Add-on", addOnKind],
43
+ keywords: ["Adobe", "Creative Cloud Web", "Add-on", entrypointType],
46
44
  scripts: {
47
45
  clean: "ccweb-add-on-scripts clean",
48
46
  build: "ccweb-add-on-scripts build",
@@ -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 "./AddOnManager.js";
27
- export * from "./AddOnTemplateSelector.js";
26
+ export * from "./PackageManager.js";
28
27
  export * from "./TemplateSelector.js";
29
- export * from "./WxpAddOnFactory.js";
@@ -22,12 +22,12 @@
22
22
  * SOFTWARE.
23
23
  ********************************************************************************/
24
24
 
25
- import type { AnalyticsConsent, AnalyticsService } from "@adobe/ccweb-add-on-analytics";
26
- import { CLIProgram, ITypes as IAnalyticsTypes } from "@adobe/ccweb-add-on-analytics";
25
+ import { BaseCommand, CLIProgram } from "@adobe/ccweb-add-on-analytics";
27
26
  import { UncaughtExceptionHandler } from "@adobe/ccweb-add-on-core";
28
27
  import { EntrypointType } from "@adobe/ccweb-add-on-manifest";
29
28
  import type { Config } from "@oclif/core";
30
- import { Args, Command, Flags } from "@oclif/core";
29
+ import { Args, Flags } from "@oclif/core";
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";
@@ -38,20 +38,20 @@ import { CLIOptions } from "../models/CLIOptions.js";
38
38
  /**
39
39
  * Implementation class of the create-ccweb-add-on command.
40
40
  */
41
- export class CreateCCWebAddOn extends Command {
42
- private readonly _analyticsConsent: AnalyticsConsent;
43
- private readonly _analyticsService: AnalyticsService;
44
-
41
+ export class Create extends BaseCommand {
45
42
  private readonly _addOnFactory: AddOnFactory;
46
43
 
47
44
  static description = "Create an Adobe Creative Cloud Web Add-on.";
48
45
 
49
- static examples = ["create-ccweb-add-on <add-on-name> --template <javascript>"];
46
+ static examples: string[] = ["create-ccweb-add-on <add-on-name> --template <javascript>"];
50
47
 
51
- static flags = {
52
- kind: Flags.string({
53
- char: "k",
54
- description: "Kind of Add-on (panel).",
48
+ static flags: {
49
+ entrypoint: OptionFlag<string, CustomOptions>;
50
+ template: OptionFlag<string, CustomOptions>;
51
+ } = {
52
+ entrypoint: Flags.string({
53
+ char: "e",
54
+ description: "Entrypoint type of Add-on (By default it is set as 'panel').",
55
55
  default: EntrypointType.PANEL,
56
56
  required: false,
57
57
  hidden: true
@@ -61,37 +61,21 @@ export class CreateCCWebAddOn extends Command {
61
61
  description: "Template to use for creating the Add-on project.",
62
62
  default: "",
63
63
  required: false
64
- }),
65
- analytics: Flags.string({
66
- char: "a",
67
- description: "Turn on/off sending analytics to Adobe.",
68
- options: ["on", "off"],
69
- required: false
70
- }),
71
- verbose: Flags.boolean({
72
- char: "v",
73
- description: "Enable verbose logging.",
74
- default: false,
75
- required: false
76
64
  })
77
65
  };
78
66
 
79
- static args = {
80
- addOnName: Args.string({
81
- name: "addOnName",
67
+ static args: {
68
+ name: Arg<string, Record<string, unknown>>;
69
+ } = {
70
+ name: Args.string({
71
+ name: "name",
82
72
  description: "Name of the Add-on project.",
83
73
  required: true
84
74
  })
85
75
  };
86
76
 
87
77
  constructor(argv: string[], config: Config) {
88
- super(argv, config);
89
-
90
- this._analyticsConsent = IContainer.get<AnalyticsConsent>(IAnalyticsTypes.AnalyticsConsent);
91
-
92
- this._analyticsService = IContainer.get<AnalyticsService>(IAnalyticsTypes.AnalyticsService);
93
- this._analyticsService.program = new CLIProgram(PROGRAM_NAME, this.config.name + "@" + this.config.version);
94
- this._analyticsService.startTime = Date.now();
78
+ super(argv, config, new CLIProgram(PROGRAM_NAME, config.name + "@" + config.version));
95
79
 
96
80
  this._addOnFactory = IContainer.get<AddOnFactory>(ITypes.AddOnFactory);
97
81
  }
@@ -100,17 +84,17 @@ export class CreateCCWebAddOn extends Command {
100
84
  UncaughtExceptionHandler.registerExceptionHandler(PROGRAM_NAME);
101
85
 
102
86
  const {
103
- args: { addOnName },
104
- flags: { kind, template, analytics, verbose }
105
- } = await this.parse(CreateCCWebAddOn);
87
+ args: { name },
88
+ flags: { entrypoint, template, analytics, verbose }
89
+ } = await this.parse(Create);
106
90
 
107
91
  await this._seekAnalyticsConsent(analytics);
108
92
 
109
93
  console.log();
110
94
 
111
95
  const options = new CLIOptions(
112
- kind.toLowerCase() as EntrypointType,
113
- addOnName,
96
+ entrypoint.toLowerCase() as EntrypointType,
97
+ name,
114
98
  template.toLowerCase(),
115
99
  verbose
116
100
  );
@@ -118,16 +102,8 @@ export class CreateCCWebAddOn extends Command {
118
102
  await this._addOnFactory.create(options);
119
103
  }
120
104
 
121
- async catch(error: { message: string }) {
105
+ async catch(error: { message: string }): Promise<void> {
122
106
  await this._analyticsService.postEvent(AnalyticsErrorMarkers.ERROR_INVALID_ARGS, error.message, false);
123
107
  throw error;
124
108
  }
125
-
126
- private async _seekAnalyticsConsent(analytics: string | undefined): Promise<void> {
127
- if (analytics === undefined) {
128
- await this._analyticsConsent.get();
129
- } else {
130
- await this._analyticsConsent.set(analytics === "on");
131
- }
132
- }
133
109
  }
@@ -23,21 +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
34
 
33
- const container = ICoreContainer;
35
+ const container: Container = ICoreContainer;
34
36
 
35
- container.bind<AddOnFactory>(ITypes.AddOnFactory).to(WxpAddOnFactory).inSingletonScope();
37
+ container.bind<AddOnFactory>(ITypes.AddOnFactory).to(AddOnFactory).inSingletonScope();
36
38
 
37
- container.bind<DirectoryValidator>(ITypes.DirectoryValidator).to(AddOnDirectoryValidator).inSingletonScope();
39
+ container.bind<DirectoryValidator>(ITypes.DirectoryValidator).to(DirectoryValidator).inSingletonScope();
38
40
 
39
- container.bind<EnvironmentValidator>(ITypes.EnvironmentValidator).to(NodeEnvironmentValidator).inSingletonScope();
41
+ container.bind<EnvironmentValidator>(ITypes.EnvironmentValidator).to(EnvironmentValidator).inSingletonScope();
40
42
 
41
- container.bind<TemplateSelector>(ITypes.TemplateSelector).to(AddOnTemplateSelector).inSingletonScope();
43
+ container.bind<TemplateSelector>(ITypes.TemplateSelector).to(TemplateSelector).inSingletonScope();
42
44
 
43
45
  export { container as IContainer };
@@ -22,7 +22,13 @@
22
22
  * SOFTWARE.
23
23
  ********************************************************************************/
24
24
 
25
- export const ITypes = {
25
+ export const ITypes: {
26
+ Command: symbol;
27
+ AddOnFactory: symbol;
28
+ DirectoryValidator: symbol;
29
+ EnvironmentValidator: symbol;
30
+ TemplateSelector: symbol;
31
+ } = {
26
32
  Command: Symbol.for("Command"),
27
33
  AddOnFactory: Symbol.for("AddOnFactory"),
28
34
  DirectoryValidator: Symbol.for("DirectoryValidator"),
package/src/constants.ts CHANGED
@@ -24,7 +24,7 @@
24
24
 
25
25
  export const PROGRAM_NAME = "create-ccweb-add-on";
26
26
 
27
- export const ADD_ON_TEMPLATES = new Map<string, string>([
27
+ export const ADD_ON_TEMPLATES: Map<string, string> = new Map<string, string>([
28
28
  ["javascript", "Get started with Add-on development using JavaScript"],
29
29
  ["swc-javascript", "Get started with Add-on development using using Spectrum Web Components and JavaScript"],
30
30
  ["swc-typescript", "Get started with Add-on development using using Spectrum Web Components and TypeScript"],
@@ -36,7 +36,7 @@ export const TEMP_TEMPLATE_PATH = ".template";
36
36
 
37
37
  export const WITH_DOCUMENT_SANDBOX = "with-document-sandbox";
38
38
 
39
- export const AVAILABLE_ADD_ON_TEMPLATES = [
39
+ export const AVAILABLE_ADD_ON_TEMPLATES: string[] = [
40
40
  "javascript",
41
41
  "swc-javascript",
42
42
  "swc-typescript",
package/src/index.ts ADDED
@@ -0,0 +1,25 @@
1
+ /********************************************************************************
2
+ * MIT License
3
+
4
+ * © Copyright 2025 Adobe. All rights reserved.
5
+
6
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
7
+ * of this software and associated documentation files (the "Software"), to deal
8
+ * in the Software without restriction, including without limitation the rights
9
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10
+ * copies of the Software, and to permit persons to whom the Software is
11
+ * furnished to do so, subject to the following conditions:
12
+ *
13
+ * The above copyright notice and this permission notice shall be included in all
14
+ * copies or substantial portions of the Software.
15
+ *
16
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
22
+ * SOFTWARE.
23
+ ********************************************************************************/
24
+
25
+ export { run } from "@oclif/core";
@@ -29,9 +29,9 @@ import type { EntrypointType } from "@adobe/ccweb-add-on-manifest";
29
29
  */
30
30
  export class CLIOptions {
31
31
  /**
32
- * Kind of the Add-on. For example: panel.
32
+ * Entrypoint type of the Add-on. Example: 'panel'.
33
33
  */
34
- readonly addOnKind: EntrypointType;
34
+ readonly entrypointType: EntrypointType;
35
35
 
36
36
  /**
37
37
  * Name of the Add-on.
@@ -50,14 +50,14 @@ export class CLIOptions {
50
50
 
51
51
  /**
52
52
  * Instantiate {@link CLIOptions}.
53
- * @param addOnKind - Kind of the Add-on. For example: panel.
53
+ * @param entrypointType - Kind of the Add-on. For example: panel.
54
54
  * @param addOnName - Name of the Add-on.
55
55
  * @param templateName - Template name.
56
56
  * @param verbose - Verbose flag.
57
57
  * @returns Reference to a new {@link CLIOptions} instance.
58
58
  */
59
- constructor(addOnKind: EntrypointType, addOnName: string, templateName: string, verbose: boolean) {
60
- this.addOnKind = addOnKind;
59
+ constructor(entrypointType: EntrypointType, addOnName: string, templateName: string, verbose: boolean) {
60
+ this.entrypointType = entrypointType;
61
61
  this.addOnName = addOnName;
62
62
  this.templateName = templateName;
63
63
  this.verbose = verbose;
@@ -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,
@@ -96,12 +97,12 @@ describe("WxpAddOnFactory", () => {
96
97
 
97
98
  const processExitStub = sandbox.stub(process, "exit");
98
99
 
99
- const addOnKind = EntrypointType.PANEL;
100
+ const entrypointType = EntrypointType.PANEL;
100
101
  const addOnName = "test-add-on";
101
102
  const templateName = "javascript";
102
103
  const verbose = false;
103
104
 
104
- await addOnFactory.create(new CLIOptions(addOnKind, addOnName, templateName, verbose));
105
+ await addOnFactory.create(new CLIOptions(entrypointType, addOnName, templateName, verbose));
105
106
 
106
107
  assert.equal(cliProcess.handleError.callCount, 1);
107
108
  assert.equal(cliProcess.handleError.calledWith(error), true);
@@ -118,7 +119,7 @@ describe("WxpAddOnFactory", () => {
118
119
 
119
120
  it("should handle the errors when template doesnt exist.", async () => {
120
121
  const run = {
121
- addOnKind: EntrypointType.PANEL,
122
+ entrypointType: EntrypointType.PANEL,
122
123
  addOnName: "test-add-on",
123
124
  templateName: "javascript",
124
125
  verbose: false
@@ -149,7 +150,7 @@ describe("WxpAddOnFactory", () => {
149
150
  templateSelector.setupTemplate.resolves(run.templateName);
150
151
 
151
152
  const options = new CLIOptions(
152
- run.addOnKind as EntrypointType,
153
+ run.entrypointType as EntrypointType,
153
154
  run.addOnName,
154
155
  run.templateName,
155
156
  run.verbose
@@ -162,19 +163,19 @@ describe("WxpAddOnFactory", () => {
162
163
 
163
164
  const runs = [
164
165
  {
165
- addOnKind: EntrypointType.PANEL,
166
+ entrypointType: EntrypointType.PANEL,
166
167
  addOnName: "test-add-on",
167
168
  templateName: "javascript",
168
169
  verbose: false
169
170
  },
170
171
  {
171
- addOnKind: EntrypointType.PANEL,
172
+ entrypointType: EntrypointType.PANEL,
172
173
  addOnName: "test-add-on",
173
174
  templateName: "typescript",
174
175
  verbose: true
175
176
  },
176
177
  {
177
- addOnKind: EntrypointType.PANEL,
178
+ entrypointType: EntrypointType.PANEL,
178
179
  addOnName: "test-add-on",
179
180
  templateName: "react-javascript",
180
181
  verbose: false
@@ -207,7 +208,7 @@ describe("WxpAddOnFactory", () => {
207
208
  templateSelector.setupTemplate.resolves(run.templateName);
208
209
 
209
210
  const options = new CLIOptions(
210
- run.addOnKind as EntrypointType,
211
+ run.entrypointType as EntrypointType,
211
212
  run.addOnName,
212
213
  run.templateName,
213
214
  run.verbose
@@ -236,7 +237,7 @@ describe("WxpAddOnFactory", () => {
236
237
  const scaffolderOptions = new ScaffolderOptions(
237
238
  addOnDirectory,
238
239
  options.addOnName,
239
- options.addOnKind,
240
+ options.entrypointType,
240
241
  rootDirectory,
241
242
  run.templateName,
242
243
  options.verbose
@@ -244,8 +245,8 @@ describe("WxpAddOnFactory", () => {
244
245
  const analyticsServiceEventData = [
245
246
  "--addOnName",
246
247
  run.addOnName,
247
- "--kind",
248
- run.addOnKind,
248
+ "--entrypointType",
249
+ run.entrypointType,
249
250
  "--template",
250
251
  run.templateName
251
252
  ];
@@ -26,19 +26,19 @@ 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 { AddOnManager } from "../../app/index.js";
29
+ import { PackageManager } from "../../app/PackageManager.js";
30
30
 
31
- describe("AddOnManager", () => {
32
- describe("getPackageJson ...", () => {
33
- const runs = [{ addOnKind: EntrypointType.PANEL, addOnName: "test-app" }];
31
+ describe("PackageManager", () => {
32
+ describe("getPackageJson", () => {
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 = AddOnManager.getPackageJson(run.addOnKind as EntrypointType, run.addOnName);
36
+ const packageJson = PackageManager.getPackageJson(run.entrypointType as EntrypointType, run.addOnName);
37
37
  const expectedPackageJson = new PackageJson({
38
38
  name: run.addOnName,
39
39
  version: "1.0.0",
40
40
  description: "Adobe Creative Cloud Web Add-on.",
41
- keywords: ["Adobe", "Creative Cloud Web", "Add-on", run.addOnKind],
41
+ keywords: ["Adobe", "Creative Cloud Web", "Add-on", run.entrypointType],
42
42
  scripts: {
43
43
  clean: "ccweb-add-on-scripts clean",
44
44
  build: "ccweb-add-on-scripts build",