@adobe/create-ccweb-add-on 2.5.0 → 3.0.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 (108) hide show
  1. package/.mocharc.json +9 -2
  2. package/README.md +2 -2
  3. package/bin/run.js +3 -2
  4. package/dist/app/{AddOnManager.d.ts → AddOnPackageManager.d.ts} +4 -4
  5. package/dist/app/AddOnPackageManager.d.ts.map +1 -0
  6. package/dist/app/{AddOnManager.js → AddOnPackageManager.js} +5 -6
  7. package/dist/app/AddOnTemplateSelector.d.ts +3 -3
  8. package/dist/app/AddOnTemplateSelector.d.ts.map +1 -1
  9. package/dist/app/AddOnTemplateSelector.js +13 -13
  10. package/dist/app/WxpAddOnFactory.js +5 -5
  11. package/dist/app/index.d.ts +1 -1
  12. package/dist/app/index.d.ts.map +1 -1
  13. package/dist/app/index.js +1 -1
  14. package/dist/commands/create.d.ts +6 -10
  15. package/dist/commands/create.d.ts.map +1 -1
  16. package/dist/commands/create.js +11 -37
  17. package/dist/config/inversify.config.d.ts +2 -1
  18. package/dist/config/inversify.config.d.ts.map +1 -1
  19. package/dist/config/inversify.types.d.ts.map +1 -1
  20. package/dist/constants.d.ts.map +1 -1
  21. package/dist/index.d.ts +25 -0
  22. package/dist/index.d.ts.map +1 -0
  23. package/dist/index.js +25 -0
  24. package/dist/models/CLIOptions.d.ts +4 -4
  25. package/dist/models/CLIOptions.d.ts.map +1 -1
  26. package/dist/models/CLIOptions.js +5 -5
  27. package/dist/templates/react-javascript/template/src/components/App.jsx +2 -2
  28. package/dist/templates/react-javascript/template/webpack.config.js +1 -0
  29. package/dist/templates/react-javascript/template.json +4 -4
  30. package/dist/templates/react-javascript-with-document-sandbox/template/src/ui/components/App.jsx +2 -2
  31. package/dist/templates/react-javascript-with-document-sandbox/template/webpack.config.js +1 -0
  32. package/dist/templates/react-javascript-with-document-sandbox/template.json +4 -4
  33. package/dist/templates/react-typescript/template/src/components/App.tsx +2 -2
  34. package/dist/templates/react-typescript/template/webpack.config.js +1 -0
  35. package/dist/templates/react-typescript/template.json +4 -4
  36. package/dist/templates/react-typescript-with-document-sandbox/template/src/ui/components/App.tsx +2 -2
  37. package/dist/templates/react-typescript-with-document-sandbox/template/webpack.config.js +1 -0
  38. package/dist/templates/react-typescript-with-document-sandbox/template.json +4 -4
  39. package/dist/templates/swc-javascript/template/src/components/App.js +2 -2
  40. package/dist/templates/swc-javascript/template/webpack.config.js +1 -0
  41. package/dist/templates/swc-javascript/template.json +4 -4
  42. package/dist/templates/swc-javascript-with-document-sandbox/template/src/ui/components/App.js +2 -2
  43. package/dist/templates/swc-javascript-with-document-sandbox/template/webpack.config.js +1 -0
  44. package/dist/templates/swc-javascript-with-document-sandbox/template.json +4 -4
  45. package/dist/templates/swc-typescript/template/src/components/App.css.ts +2 -2
  46. package/dist/templates/swc-typescript/template/src/components/App.ts +4 -4
  47. package/dist/templates/swc-typescript/template/src/index.ts +2 -2
  48. package/dist/templates/swc-typescript/template/webpack.config.js +1 -0
  49. package/dist/templates/swc-typescript/template.json +4 -4
  50. package/dist/templates/swc-typescript-with-document-sandbox/template/src/ui/components/App.css.ts +2 -2
  51. package/dist/templates/swc-typescript-with-document-sandbox/template/src/ui/components/App.ts +4 -4
  52. package/dist/templates/swc-typescript-with-document-sandbox/template/src/ui/index.ts +2 -2
  53. package/dist/templates/swc-typescript-with-document-sandbox/template/webpack.config.js +1 -0
  54. package/dist/templates/swc-typescript-with-document-sandbox/template.json +4 -4
  55. package/dist/tsconfig.tsbuildinfo +1 -1
  56. package/dist/validators/AddOnDirectoryValidator.js +2 -2
  57. package/dist/validators/NodeEnvironmentValidator.js +2 -2
  58. package/package.json +24 -18
  59. package/src/app/{AddOnManager.ts → AddOnPackageManager.ts} +4 -6
  60. package/src/app/AddOnTemplateSelector.ts +13 -13
  61. package/src/app/WxpAddOnFactory.ts +5 -5
  62. package/src/app/index.ts +1 -1
  63. package/src/commands/create.ts +24 -48
  64. package/src/config/inversify.config.ts +2 -1
  65. package/src/config/inversify.types.ts +7 -1
  66. package/src/constants.ts +2 -2
  67. package/src/index.ts +25 -0
  68. package/src/models/CLIOptions.ts +5 -5
  69. package/src/test/app/{AddOnManager.spec.ts → AddOnPackageManager.spec.ts} +8 -5
  70. package/src/test/app/AddOnTemplateSelector.spec.ts +30 -12
  71. package/src/test/app/WxpAddOnFactory.spec.ts +11 -11
  72. package/src/test/commands/command.spec.ts +80 -0
  73. package/src/test/commands/create.spec.ts +42 -16
  74. package/src/test/models/CLIOptions.spec.ts +3 -3
  75. package/src/test/validators/AddOnDirectoryValidator.spec.ts +24 -15
  76. package/src/test/validators/NodeEnvironmentValidator.spec.ts +5 -5
  77. package/src/validators/AddOnDirectoryValidator.ts +2 -2
  78. package/src/validators/NodeEnvironmentValidator.ts +2 -2
  79. package/templates/react-javascript/template/src/components/App.jsx +2 -2
  80. package/templates/react-javascript/template/webpack.config.js +1 -0
  81. package/templates/react-javascript/template.json +4 -4
  82. package/templates/react-javascript-with-document-sandbox/template/src/ui/components/App.jsx +2 -2
  83. package/templates/react-javascript-with-document-sandbox/template/webpack.config.js +1 -0
  84. package/templates/react-javascript-with-document-sandbox/template.json +4 -4
  85. package/templates/react-typescript/template/src/components/App.tsx +2 -2
  86. package/templates/react-typescript/template/webpack.config.js +1 -0
  87. package/templates/react-typescript/template.json +4 -4
  88. package/templates/react-typescript-with-document-sandbox/template/src/ui/components/App.tsx +2 -2
  89. package/templates/react-typescript-with-document-sandbox/template/webpack.config.js +1 -0
  90. package/templates/react-typescript-with-document-sandbox/template.json +4 -4
  91. package/templates/swc-javascript/template/src/components/App.js +2 -2
  92. package/templates/swc-javascript/template/webpack.config.js +1 -0
  93. package/templates/swc-javascript/template.json +4 -4
  94. package/templates/swc-javascript-with-document-sandbox/template/src/ui/components/App.js +2 -2
  95. package/templates/swc-javascript-with-document-sandbox/template/webpack.config.js +1 -0
  96. package/templates/swc-javascript-with-document-sandbox/template.json +4 -4
  97. package/templates/swc-typescript/template/src/components/App.css.ts +2 -2
  98. package/templates/swc-typescript/template/src/components/App.ts +4 -4
  99. package/templates/swc-typescript/template/src/index.ts +2 -2
  100. package/templates/swc-typescript/template/webpack.config.js +1 -0
  101. package/templates/swc-typescript/template.json +4 -4
  102. package/templates/swc-typescript-with-document-sandbox/template/src/ui/components/App.css.ts +2 -2
  103. package/templates/swc-typescript-with-document-sandbox/template/src/ui/components/App.ts +4 -4
  104. package/templates/swc-typescript-with-document-sandbox/template/src/ui/index.ts +2 -2
  105. package/templates/swc-typescript-with-document-sandbox/template/webpack.config.js +1 -0
  106. package/templates/swc-typescript-with-document-sandbox/template.json +4 -4
  107. package/tsconfig.json +3 -1
  108. package/dist/app/AddOnManager.d.ts.map +0 -1
@@ -63,7 +63,7 @@ export class AddOnTemplateSelector implements TemplateSelector {
63
63
  * @returns User selected/provided template name.
64
64
  */
65
65
  async setupTemplate(options: CLIOptions): Promise<string> {
66
- await this._validateAddOnKind(options.addOnKind);
66
+ await this._validateAddOnEntrypoint(options.entrypointType);
67
67
 
68
68
  if (!isNullOrWhiteSpace(options.templateName)) {
69
69
  if (AVAILABLE_ADD_ON_TEMPLATES.includes(options.templateName)) {
@@ -144,14 +144,14 @@ export class AddOnTemplateSelector implements TemplateSelector {
144
144
  }
145
145
 
146
146
  /**
147
- * Validate whether addOnKind is valid or not.
148
- * @param addOnKind - Kind of Add-on. For example: panel.
147
+ * Validate whether entrypointType is valid or not.
148
+ * @param entrypointType - Add-on entrypoint. For example: panel.
149
149
  */
150
- private async _validateAddOnKind(addOnKind: EntrypointType): Promise<void> {
151
- if (addOnKind !== EntrypointType.PANEL) {
152
- this._logger.warning(LOGS.chooseValidKind);
150
+ private async _validateAddOnEntrypoint(entrypointType: EntrypointType): Promise<void> {
151
+ if (entrypointType !== EntrypointType.PANEL) {
152
+ this._logger.warning(LOGS.chooseValidEntrypointType);
153
153
  this._logger.warning(
154
- format(LOGS.executeProgramWithValidKind, {
154
+ format(LOGS.executeProgramWithValidEntrypointType, {
155
155
  PROGRAM_NAME
156
156
  }),
157
157
  {
@@ -160,7 +160,7 @@ export class AddOnTemplateSelector implements TemplateSelector {
160
160
  );
161
161
  this._logger.message(LOGS.forExample, { prefix: LOGS.newLine });
162
162
  this._logger.information(
163
- format(LOGS.executeProgramWithValidKindExample, {
163
+ format(LOGS.executeProgramWithValidEntrypointTypeExample, {
164
164
  PROGRAM_NAME
165
165
  }),
166
166
  {
@@ -170,7 +170,7 @@ export class AddOnTemplateSelector implements TemplateSelector {
170
170
 
171
171
  await this._analyticsService.postEvent(
172
172
  AnalyticsErrorMarkers.ERROR_INVALID_KIND,
173
- LOGS.analyticsInvalidKind,
173
+ LOGS.analyticsInvalidEntrypointType,
174
174
  false
175
175
  );
176
176
  return process.exit(0);
@@ -181,12 +181,12 @@ const LOGS = {
181
181
  newLine: "\n",
182
182
  tab: " ",
183
183
  setupTemplate: "Please select a template which you want to scaffold the Add-on project with",
184
- chooseValidKind: "Please choose a valid Add-on kind (valid kind: panel)",
185
- executeProgramWithValidKind: "{PROGRAM_NAME} <add-on-name> --kind <panel>",
186
- executeProgramWithValidKindExample: "{PROGRAM_NAME} my-add-on --kind panel",
184
+ chooseValidEntrypointType: "Please choose a valid Add-on entrypoint (valid entrypoint: panel)",
185
+ executeProgramWithValidEntrypointType: "{PROGRAM_NAME} <add-on-name> --entrypoint <panel>",
186
+ executeProgramWithValidEntrypointTypeExample: "{PROGRAM_NAME} my-add-on --entrypoint panel",
187
187
  chooseValidTemplate: "You have chosen an invalid template.",
188
188
  forExample: "For example:",
189
- analyticsInvalidKind: "Invalid Add-on kind specified",
189
+ analyticsInvalidEntrypointType: "Invalid Add-on entrypoint specified",
190
190
  includeDocumentSandbox: "Do you want to include document sandbox runtime?",
191
191
  yes: "Yes",
192
192
  no: "No"
@@ -42,7 +42,7 @@ import { TEMP_TEMPLATE_PATH } from "../constants.js";
42
42
  import type { CLIOptions } from "../models/CLIOptions.js";
43
43
  import type { DirectoryValidator, EnvironmentValidator } from "../validators/index.js";
44
44
  import type { AddOnFactory } from "./AddOnFactory.js";
45
- import { AddOnManager } from "./AddOnManager.js";
45
+ import { AddOnPackageManager } from "./AddOnPackageManager.js";
46
46
  import type { TemplateSelector } from "./TemplateSelector.js";
47
47
 
48
48
  /**
@@ -114,7 +114,7 @@ export class WxpAddOnFactory implements AddOnFactory {
114
114
 
115
115
  const templateName = await this._templateSelector.setupTemplate(options);
116
116
 
117
- const packageJson = AddOnManager.getPackageJson(options.addOnKind, options.addOnName);
117
+ const packageJson = AddOnPackageManager.getPackageJson(options.entrypointType, options.addOnName);
118
118
  const packageJsonPath = path.join(addOnDirectory, PACKAGE_JSON);
119
119
 
120
120
  fs.writeFileSync(packageJsonPath, packageJson.toJSON() + os.EOL);
@@ -141,7 +141,7 @@ export class WxpAddOnFactory implements AddOnFactory {
141
141
  const scaffolderOptions = new ScaffolderOptions(
142
142
  addOnDirectory,
143
143
  options.addOnName,
144
- options.addOnKind,
144
+ options.entrypointType,
145
145
  rootDirectory,
146
146
  templateName,
147
147
  options.verbose
@@ -156,8 +156,8 @@ export class WxpAddOnFactory implements AddOnFactory {
156
156
  const analyticsEventData = [
157
157
  "--addOnName",
158
158
  options.addOnName,
159
- "--kind",
160
- options.addOnKind,
159
+ "--entrypointType",
160
+ options.entrypointType,
161
161
  "--template",
162
162
  templateName
163
163
  ];
package/src/app/index.ts CHANGED
@@ -23,7 +23,7 @@
23
23
  ********************************************************************************/
24
24
 
25
25
  export * from "./AddOnFactory.js";
26
- export * from "./AddOnManager.js";
26
+ export * from "./AddOnPackageManager.js";
27
27
  export * from "./AddOnTemplateSelector.js";
28
28
  export * from "./TemplateSelector.js";
29
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 { 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
  }
@@ -29,8 +29,9 @@ import { AddOnTemplateSelector, WxpAddOnFactory } from "../app/index.js";
29
29
  import type { DirectoryValidator, EnvironmentValidator } from "../validators/index.js";
30
30
  import { AddOnDirectoryValidator, NodeEnvironmentValidator } from "../validators/index.js";
31
31
  import { ITypes } from "./inversify.types.js";
32
+ import { Container } from "inversify";
32
33
 
33
- const container = ICoreContainer;
34
+ const container: Container = ICoreContainer;
34
35
 
35
36
  container.bind<AddOnFactory>(ITypes.AddOnFactory).to(WxpAddOnFactory).inSingletonScope();
36
37
 
@@ -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;
@@ -26,19 +26,22 @@ 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 { AddOnPackageManager } from "../../app/index.js";
30
30
 
31
31
  describe("AddOnManager", () => {
32
- describe("getPackageJson ...", () => {
33
- const runs = [{ addOnKind: EntrypointType.PANEL, addOnName: "test-app" }];
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 = AddOnPackageManager.getPackageJson(
37
+ run.entrypointType as EntrypointType,
38
+ run.addOnName
39
+ );
37
40
  const expectedPackageJson = new PackageJson({
38
41
  name: run.addOnName,
39
42
  version: "1.0.0",
40
43
  description: "Adobe Creative Cloud Web Add-on.",
41
- keywords: ["Adobe", "Creative Cloud Web", "Add-on", run.addOnKind],
44
+ keywords: ["Adobe", "Creative Cloud Web", "Add-on", run.entrypointType],
42
45
  scripts: {
43
46
  clean: "ccweb-add-on-scripts clean",
44
47
  build: "ccweb-add-on-scripts build",
@@ -70,9 +70,14 @@ describe("AddOnTemplateSelector", () => {
70
70
  sandbox.restore();
71
71
  });
72
72
 
73
- it("should return error if the Add-on kind is not valid.", async () => {
73
+ it("should return error if the Add-on entrypoint is not valid.", async () => {
74
74
  const processExitStub = sandbox.stub(process, "exit");
75
- const options = new CLIOptions("test-add-on-kind" as EntrypointType, "test-add-on", templateName, false);
75
+ const options = new CLIOptions(
76
+ "test-add-on-entrypoint" as EntrypointType,
77
+ "test-add-on",
78
+ templateName,
79
+ false
80
+ );
76
81
 
77
82
  const templateSelector: TemplateSelector = new AddOnTemplateSelector(logger, analyticsService);
78
83
 
@@ -80,11 +85,15 @@ describe("AddOnTemplateSelector", () => {
80
85
 
81
86
  assert.equal(logger.warning.callCount, 2);
82
87
  assert.equal(
83
- logger.warning.getCall(0).calledWith("Please choose a valid Add-on kind (valid kind: panel)"),
88
+ logger.warning
89
+ .getCall(0)
90
+ .calledWith("Please choose a valid Add-on entrypoint (valid entrypoint: panel)"),
84
91
  true
85
92
  );
86
93
  assert.equal(
87
- logger.warning.getCall(1).calledWith(`${PROGRAM_NAME} <add-on-name> --kind <panel>`, { prefix: " " }),
94
+ logger.warning
95
+ .getCall(1)
96
+ .calledWith(`${PROGRAM_NAME} <add-on-name> --entrypoint <panel>`, { prefix: " " }),
88
97
  true
89
98
  );
90
99
 
@@ -93,7 +102,7 @@ describe("AddOnTemplateSelector", () => {
93
102
 
94
103
  assert.equal(logger.information.callCount, 1);
95
104
  assert.equal(
96
- logger.information.calledWith(`${PROGRAM_NAME} my-add-on --kind panel`, {
105
+ logger.information.calledWith(`${PROGRAM_NAME} my-add-on --entrypoint panel`, {
97
106
  prefix: " "
98
107
  }),
99
108
  true
@@ -102,28 +111,37 @@ describe("AddOnTemplateSelector", () => {
102
111
  assert.equal(
103
112
  analyticsService.postEvent.calledWith(
104
113
  AnalyticsErrorMarkers.ERROR_INVALID_KIND,
105
- "Invalid Add-on kind specified"
114
+ "Invalid Add-on entrypoint specified"
106
115
  ),
107
116
  true
108
117
  );
109
118
  assert.equal(processExitStub.calledWith(0), true);
110
119
  });
111
120
 
112
- it("should return error if the app kind is not valid.", async () => {
121
+ it("should return error if the app entrypoint is not valid.", async () => {
113
122
  const processExitStub = sandbox.stub(process, "exit");
114
123
 
115
- const cliOptions = new CLIOptions("test-add-on-kind" as EntrypointType, "test-add-on", templateName, false);
124
+ const cliOptions = new CLIOptions(
125
+ "test-add-on-entrypoint" as EntrypointType,
126
+ "test-add-on",
127
+ templateName,
128
+ false
129
+ );
116
130
 
117
131
  const templateSelector: TemplateSelector = new AddOnTemplateSelector(logger, analyticsService);
118
132
  await templateSelector.setupTemplate(cliOptions);
119
133
 
120
134
  assert.equal(logger.warning.callCount, 2);
121
135
  assert.equal(
122
- logger.warning.getCall(0).calledWith("Please choose a valid Add-on kind (valid kind: panel)"),
136
+ logger.warning
137
+ .getCall(0)
138
+ .calledWith("Please choose a valid Add-on entrypoint (valid entrypoint: panel)"),
123
139
  true
124
140
  );
125
141
  assert.equal(
126
- logger.warning.getCall(1).calledWith(`${PROGRAM_NAME} <add-on-name> --kind <panel>`, { prefix: " " }),
142
+ logger.warning
143
+ .getCall(1)
144
+ .calledWith(`${PROGRAM_NAME} <add-on-name> --entrypoint <panel>`, { prefix: " " }),
127
145
  true
128
146
  );
129
147
 
@@ -132,7 +150,7 @@ describe("AddOnTemplateSelector", () => {
132
150
 
133
151
  assert.equal(logger.information.callCount, 1);
134
152
  assert.equal(
135
- logger.information.calledWith(`${PROGRAM_NAME} my-add-on --kind panel`, {
153
+ logger.information.calledWith(`${PROGRAM_NAME} my-add-on --entrypoint panel`, {
136
154
  prefix: " "
137
155
  }),
138
156
  true
@@ -141,7 +159,7 @@ describe("AddOnTemplateSelector", () => {
141
159
  assert.equal(
142
160
  analyticsService.postEvent.calledWith(
143
161
  AnalyticsErrorMarkers.ERROR_INVALID_KIND,
144
- "Invalid Add-on kind specified"
162
+ "Invalid Add-on entrypoint specified"
145
163
  ),
146
164
  true
147
165
  );
@@ -96,12 +96,12 @@ describe("WxpAddOnFactory", () => {
96
96
 
97
97
  const processExitStub = sandbox.stub(process, "exit");
98
98
 
99
- const addOnKind = EntrypointType.PANEL;
99
+ const entrypointType = EntrypointType.PANEL;
100
100
  const addOnName = "test-add-on";
101
101
  const templateName = "javascript";
102
102
  const verbose = false;
103
103
 
104
- await addOnFactory.create(new CLIOptions(addOnKind, addOnName, templateName, verbose));
104
+ await addOnFactory.create(new CLIOptions(entrypointType, addOnName, templateName, verbose));
105
105
 
106
106
  assert.equal(cliProcess.handleError.callCount, 1);
107
107
  assert.equal(cliProcess.handleError.calledWith(error), true);
@@ -118,7 +118,7 @@ describe("WxpAddOnFactory", () => {
118
118
 
119
119
  it("should handle the errors when template doesnt exist.", async () => {
120
120
  const run = {
121
- addOnKind: EntrypointType.PANEL,
121
+ entrypointType: EntrypointType.PANEL,
122
122
  addOnName: "test-add-on",
123
123
  templateName: "javascript",
124
124
  verbose: false
@@ -149,7 +149,7 @@ describe("WxpAddOnFactory", () => {
149
149
  templateSelector.setupTemplate.resolves(run.templateName);
150
150
 
151
151
  const options = new CLIOptions(
152
- run.addOnKind as EntrypointType,
152
+ run.entrypointType as EntrypointType,
153
153
  run.addOnName,
154
154
  run.templateName,
155
155
  run.verbose
@@ -162,19 +162,19 @@ describe("WxpAddOnFactory", () => {
162
162
 
163
163
  const runs = [
164
164
  {
165
- addOnKind: EntrypointType.PANEL,
165
+ entrypointType: EntrypointType.PANEL,
166
166
  addOnName: "test-add-on",
167
167
  templateName: "javascript",
168
168
  verbose: false
169
169
  },
170
170
  {
171
- addOnKind: EntrypointType.PANEL,
171
+ entrypointType: EntrypointType.PANEL,
172
172
  addOnName: "test-add-on",
173
173
  templateName: "typescript",
174
174
  verbose: true
175
175
  },
176
176
  {
177
- addOnKind: EntrypointType.PANEL,
177
+ entrypointType: EntrypointType.PANEL,
178
178
  addOnName: "test-add-on",
179
179
  templateName: "react-javascript",
180
180
  verbose: false
@@ -207,7 +207,7 @@ describe("WxpAddOnFactory", () => {
207
207
  templateSelector.setupTemplate.resolves(run.templateName);
208
208
 
209
209
  const options = new CLIOptions(
210
- run.addOnKind as EntrypointType,
210
+ run.entrypointType as EntrypointType,
211
211
  run.addOnName,
212
212
  run.templateName,
213
213
  run.verbose
@@ -236,7 +236,7 @@ describe("WxpAddOnFactory", () => {
236
236
  const scaffolderOptions = new ScaffolderOptions(
237
237
  addOnDirectory,
238
238
  options.addOnName,
239
- options.addOnKind,
239
+ options.entrypointType,
240
240
  rootDirectory,
241
241
  run.templateName,
242
242
  options.verbose
@@ -244,8 +244,8 @@ describe("WxpAddOnFactory", () => {
244
244
  const analyticsServiceEventData = [
245
245
  "--addOnName",
246
246
  run.addOnName,
247
- "--kind",
248
- run.addOnKind,
247
+ "--entrypointType",
248
+ run.entrypointType,
249
249
  "--template",
250
250
  run.templateName
251
251
  ];
@@ -0,0 +1,80 @@
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
+ import type { AnalyticsConsent, AnalyticsService } from "@adobe/ccweb-add-on-analytics";
26
+ import { ITypes as IAnalyticsTypes } from "@adobe/ccweb-add-on-analytics";
27
+ import { EntrypointType } from "@adobe/ccweb-add-on-manifest";
28
+ import { runCommand } from "@oclif/test";
29
+ import { assert } from "chai";
30
+ import "mocha";
31
+ import sinon from "sinon";
32
+ import type { StubbedInstance } from "ts-sinon";
33
+ import { stubInterface } from "ts-sinon";
34
+ import { AddOnFactory } from "../../app/AddOnFactory.js";
35
+ import { IContainer, ITypes } from "../../config/index.js";
36
+ import { CLIOptions } from "../../models/CLIOptions.js";
37
+
38
+ describe("create-ccweb-add-on", () => {
39
+ let sandbox: sinon.SinonSandbox;
40
+
41
+ let container: sinon.SinonStub;
42
+
43
+ let addOnFactory: StubbedInstance<AddOnFactory>;
44
+
45
+ let analyticsConsent: StubbedInstance<AnalyticsConsent>;
46
+ let analyticsService: StubbedInstance<AnalyticsService>;
47
+
48
+ beforeEach(() => {
49
+ sandbox = sinon.createSandbox();
50
+
51
+ addOnFactory = stubInterface();
52
+ addOnFactory.create.resolves();
53
+
54
+ analyticsConsent = stubInterface();
55
+ analyticsService = stubInterface();
56
+
57
+ container = sandbox.stub(IContainer, "get");
58
+ container.withArgs(ITypes.AddOnFactory).returns(addOnFactory);
59
+
60
+ container.withArgs(IAnalyticsTypes.AnalyticsConsent).returns(analyticsConsent);
61
+ container.withArgs(IAnalyticsTypes.AnalyticsService).returns(analyticsService);
62
+ });
63
+
64
+ afterEach(() => {
65
+ sandbox.restore();
66
+ });
67
+
68
+ describe("create", () => {
69
+ it("should execute succesfully when correct parameters are passed.", async () => {
70
+ analyticsConsent.set.resolves();
71
+
72
+ await runCommand(["hello-world", "--entrypoint=panel", "--template=react-javascript"], {
73
+ root: "."
74
+ });
75
+
76
+ const options = new CLIOptions(EntrypointType.PANEL, "hello-world", "react-javascript", false);
77
+ assert.equal(addOnFactory.create.calledOnceWith(options), true);
78
+ });
79
+ });
80
+ });