@adobe/ccweb-add-on-scaffolder 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 (59) hide show
  1. package/.c8rc.json +5 -1
  2. package/.mocharc.json +3 -1
  3. package/dist/app/AddOnBuilder.d.ts +27 -7
  4. package/dist/app/AddOnBuilder.d.ts.map +1 -1
  5. package/dist/app/AddOnBuilder.js +247 -0
  6. package/dist/app/AddOnScaffolder.d.ts +29 -2
  7. package/dist/app/AddOnScaffolder.d.ts.map +1 -1
  8. package/dist/app/AddOnScaffolder.js +106 -1
  9. package/dist/app/PackageBuilder.d.ts +21 -7
  10. package/dist/app/PackageBuilder.d.ts.map +1 -1
  11. package/dist/app/PackageBuilder.js +68 -1
  12. package/dist/app/index.d.ts +0 -3
  13. package/dist/app/index.d.ts.map +1 -1
  14. package/dist/app/index.js +0 -3
  15. package/dist/config/inversify.config.js +8 -6
  16. package/dist/config/inversify.types.d.ts +0 -1
  17. package/dist/config/inversify.types.d.ts.map +1 -1
  18. package/dist/config/inversify.types.js +0 -1
  19. package/dist/index.d.ts +1 -1
  20. package/dist/index.d.ts.map +1 -1
  21. package/dist/index.js +0 -1
  22. package/dist/tsconfig.tsbuildinfo +1 -1
  23. package/dist/validators/TemplateValidator.d.ts +12 -2
  24. package/dist/validators/TemplateValidator.d.ts.map +1 -1
  25. package/dist/validators/TemplateValidator.js +54 -1
  26. package/dist/validators/index.d.ts +0 -1
  27. package/dist/validators/index.d.ts.map +1 -1
  28. package/dist/validators/index.js +0 -1
  29. package/package.json +8 -8
  30. package/src/app/AddOnBuilder.ts +258 -15
  31. package/src/app/AddOnScaffolder.ts +120 -3
  32. package/src/app/PackageBuilder.ts +75 -9
  33. package/src/app/index.ts +0 -3
  34. package/src/config/inversify.config.ts +8 -8
  35. package/src/config/inversify.types.ts +0 -2
  36. package/src/index.ts +1 -1
  37. package/src/test/app/{TemplateAddOnBuilder.spec.ts → AddOnBuilder.spec.ts} +21 -22
  38. package/src/test/app/{TemplateAddOnScaffolder.spec.ts → AddOnScaffolder.spec.ts} +11 -13
  39. package/src/test/app/{TemplatePackageBuilder.spec.ts → PackageBuilder.spec.ts} +13 -14
  40. package/src/test/models/ScaffolderOptions.spec.ts +1 -1
  41. package/src/test/validators/{AppTemplateValidator.spec.ts → TemplateValidator.spec.ts} +2 -3
  42. package/src/validators/TemplateValidator.ts +46 -3
  43. package/src/validators/index.ts +0 -1
  44. package/dist/app/TemplateAddOnBuilder.d.ts +0 -90
  45. package/dist/app/TemplateAddOnBuilder.d.ts.map +0 -1
  46. package/dist/app/TemplateAddOnBuilder.js +0 -273
  47. package/dist/app/TemplateAddOnScaffolder.d.ts +0 -63
  48. package/dist/app/TemplateAddOnScaffolder.d.ts.map +0 -1
  49. package/dist/app/TemplateAddOnScaffolder.js +0 -130
  50. package/dist/app/TemplatePackageBuilder.d.ts +0 -49
  51. package/dist/app/TemplatePackageBuilder.d.ts.map +0 -1
  52. package/dist/app/TemplatePackageBuilder.js +0 -92
  53. package/dist/validators/AddOnTemplateValidator.d.ts +0 -46
  54. package/dist/validators/AddOnTemplateValidator.d.ts.map +0 -1
  55. package/dist/validators/AddOnTemplateValidator.js +0 -78
  56. package/src/app/TemplateAddOnBuilder.ts +0 -319
  57. package/src/app/TemplateAddOnScaffolder.ts +0 -153
  58. package/src/app/TemplatePackageBuilder.ts +0 -102
  59. package/src/validators/AddOnTemplateValidator.ts +0 -79
@@ -1,273 +0,0 @@
1
- /********************************************************************************
2
- * MIT License
3
-
4
- * © Copyright 2023 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
- import { __decorate, __metadata, __param } from "tslib";
25
- import { ADDITIONAL_ADD_ON_INFO, DEFAULT_ADD_ON_VERSION, ITypes as ICoreTypes, PackageJson, TemplateJson, getJSONString, isNullOrWhiteSpace } from "@adobe/ccweb-add-on-core";
26
- import { AddOnManifest, EntrypointType } from "@adobe/ccweb-add-on-manifest";
27
- import fs from "fs-extra";
28
- import { inject, injectable } from "inversify";
29
- import { createRequire } from "module";
30
- import os from "os";
31
- import path from "path";
32
- import "reflect-metadata";
33
- import format from "string-template";
34
- import { v4 as uuidv4 } from "uuid";
35
- import { MANIFEST_JSON, PACKAGE_JSON, TEMPLATE_JSON, TEMP_TEMPLATE_PATH } from "../constants.js";
36
- /**
37
- * App builder implementation class for constructing the Add-on project.
38
- */
39
- let TemplateAddOnBuilder = class TemplateAddOnBuilder {
40
- _logger;
41
- _options;
42
- _require;
43
- _templateRootDirectory;
44
- _gitignoreExists = false;
45
- _readmeExists = false;
46
- /**
47
- * Instantiate {@link TemplateAddOnBuilder}.
48
- *
49
- * @param options - {@link ScaffolderOptions}.
50
- * @param logger - {@link Logger} reference.
51
- * @returns Reference to a new {@link TemplateAddOnBuilder} instance.
52
- */
53
- constructor(options, logger) {
54
- this._options = options;
55
- this._logger = logger;
56
- this._require = createRequire(import.meta.url);
57
- this._templateRootDirectory = path.join(process.cwd(), TEMP_TEMPLATE_PATH);
58
- }
59
- /**
60
- * Get {@link PackageJson}.
61
- *
62
- * @returns Reference of {@link PackageJson}.
63
- */
64
- getPackageJson() {
65
- const packageJsonPath = path.join(this._options.addOnDirectory, PACKAGE_JSON);
66
- return new PackageJson(this._require(packageJsonPath));
67
- }
68
- /**
69
- * Get {@link TemplateJson}.
70
- *
71
- * @returns Reference of {@link TemplateJson}.
72
- */
73
- getTemplateJson() {
74
- const templateJsonPath = path.join(this._templateRootDirectory, TEMPLATE_JSON);
75
- return fs.existsSync(templateJsonPath)
76
- ? new TemplateJson(this._require(templateJsonPath))
77
- : new TemplateJson({});
78
- }
79
- /**
80
- * Get template devDependencies.
81
- *
82
- * @param template - {@link TemplateJson}
83
- * @returns Set of template devDependencies.
84
- */
85
- getDevDependenciesToInstall(template) {
86
- const devDependencies = new Set();
87
- if (template.devDependencies) {
88
- template.devDependencies.forEach((value, key) => {
89
- devDependencies.add(`${key}@${value}`);
90
- });
91
- }
92
- return devDependencies;
93
- }
94
- /**
95
- * Get template dependencies.
96
- *
97
- * @param template - {@link TemplateJson}
98
- * @returns Set of template dependencies.
99
- */
100
- getDependenciesToInstall(template) {
101
- const dependencies = new Set();
102
- if (template.dependencies) {
103
- template.dependencies.forEach((value, key) => {
104
- dependencies.add(`${key}@${value}`);
105
- });
106
- }
107
- return dependencies;
108
- }
109
- /**
110
- * Build the Add-on.
111
- *
112
- * @param packageJson - {@link PackageJson}
113
- */
114
- build(packageJson) {
115
- fs.writeFileSync(path.join(this._options.addOnDirectory, PACKAGE_JSON), packageJson + os.EOL);
116
- this._updateReadMe();
117
- this._copyTemplateFiles();
118
- this._updateGitIgnore();
119
- this._updateManifest();
120
- this._removeTemplateTempFiles();
121
- }
122
- /**
123
- * Display success message.
124
- */
125
- displaySuccess() {
126
- let cdPath;
127
- if (!isNullOrWhiteSpace(this._options.rootDirectory) &&
128
- path.join(this._options.rootDirectory, this._options.addOnName) === this._options.addOnDirectory) {
129
- cdPath = this._options.addOnName;
130
- }
131
- else {
132
- cdPath = this._options.addOnDirectory;
133
- }
134
- this._logger.success(format(LOGS.successCreatedAddOn, {
135
- addOnName: this._options.addOnName,
136
- addOnDirectory: this._options.addOnDirectory
137
- }));
138
- this._logger.success(LOGS.insideDirectoryCommandsToRun, { postfix: LOGS.newLine });
139
- this._logger.information(LOGS.npmRunBuild, { prefix: `${LOGS.tab}` });
140
- this._logger.message(LOGS.buildsTheAddOn, { prefix: `${LOGS.tab}${LOGS.tab}` });
141
- this._logger.information(LOGS.npmRunStart, { prefix: LOGS.tab });
142
- this._logger.message(LOGS.startsTheAddOn, { prefix: `${LOGS.tab}${LOGS.tab}` });
143
- this._logger.message(LOGS.suggestBeginByTyping, {
144
- prefix: LOGS.newLine,
145
- postfix: LOGS.newLine
146
- });
147
- this._logger.warning(format(LOGS.changeDirectoryIntoCreatedApp, { cdPath }), {
148
- prefix: LOGS.tab
149
- });
150
- this._logger.information(LOGS.npmRunBuild, { prefix: LOGS.tab });
151
- this._logger.information(LOGS.npmRunStart, { prefix: LOGS.tab, postfix: LOGS.newLine });
152
- if (this._readmeExists) {
153
- this._logger.warning(LOGS.renamedReadme, { postfix: LOGS.newLine });
154
- }
155
- if (this._gitignoreExists) {
156
- this._logger.warning(LOGS.mergedGitIgnore, { postfix: LOGS.newLine });
157
- }
158
- this._logger.warning(LOGS.whatWillYouCreateToday, { postfix: LOGS.newLine });
159
- }
160
- _updateReadMe() {
161
- this._readmeExists = fs.existsSync(path.join(this._options.addOnDirectory, "README.md"));
162
- if (this._readmeExists) {
163
- fs.renameSync(path.join(this._options.addOnDirectory, "README.md"), path.join(this._options.addOnDirectory, "README.OLD.md"));
164
- }
165
- }
166
- _copyTemplateFiles() {
167
- const templateContentDirectory = path.join(this._templateRootDirectory, "template");
168
- if (fs.existsSync(templateContentDirectory)) {
169
- fs.copySync(templateContentDirectory, this._options.addOnDirectory);
170
- }
171
- else {
172
- this._logger.warning(format(LOGS.couldNotLocateTemplate, { templateContentDirectory }));
173
- process.exit(1);
174
- }
175
- }
176
- _updateGitIgnore() {
177
- this._gitignoreExists = fs.existsSync(path.join(this._options.addOnDirectory, ".gitignore"));
178
- if (this._gitignoreExists) {
179
- const data = fs.readFileSync(path.join(this._options.addOnDirectory, "gitignore"));
180
- fs.appendFileSync(path.join(this._options.addOnDirectory, ".gitignore"), data);
181
- fs.unlinkSync(path.join(this._options.addOnDirectory, "gitignore"));
182
- }
183
- else {
184
- fs.moveSync(path.join(this._options.addOnDirectory, "gitignore"), path.join(this._options.addOnDirectory, ".gitignore"));
185
- }
186
- }
187
- _updateManifest() {
188
- const manifestJsonPath = path.join(this._options.addOnDirectory, "src", MANIFEST_JSON);
189
- const manifestExists = fs.existsSync(manifestJsonPath);
190
- let createManifestResult;
191
- if (manifestExists) {
192
- const manifestFile = this._require(manifestJsonPath);
193
- const addOnName = this._getAddOnName(this._options.addOnName);
194
- const manifestEntryPoints = manifestFile.entryPoints ?? [];
195
- createManifestResult = AddOnManifest.createManifest({
196
- manifest: {
197
- ...manifestFile,
198
- testId: uuidv4(),
199
- name: addOnName,
200
- version: DEFAULT_ADD_ON_VERSION,
201
- entryPoints: manifestEntryPoints
202
- },
203
- additionalInfo: ADDITIONAL_ADD_ON_INFO
204
- });
205
- fs.unlinkSync(manifestJsonPath);
206
- }
207
- else {
208
- createManifestResult = AddOnManifest.createManifest({
209
- manifest: {
210
- testId: uuidv4(),
211
- name: this._getAddOnName(this._options.addOnName),
212
- version: DEFAULT_ADD_ON_VERSION,
213
- manifestVersion: 2,
214
- requirements: {
215
- apps: [
216
- {
217
- name: "Express",
218
- apiVersion: 1
219
- }
220
- ]
221
- },
222
- entryPoints: [
223
- {
224
- type: EntrypointType.PANEL,
225
- id: this._options.addOnName,
226
- main: ""
227
- }
228
- ]
229
- },
230
- additionalInfo: ADDITIONAL_ADD_ON_INFO
231
- });
232
- }
233
- if (createManifestResult.manifest === undefined) {
234
- return this._logger.warning(format(LOGS.invalidManifestInTemplate, {
235
- templateName: this._options.templateName,
236
- error: getJSONString(createManifestResult.manifestValidationResult)
237
- }));
238
- }
239
- fs.writeFileSync(manifestJsonPath, getJSONString(createManifestResult.manifest.manifestProperties) + os.EOL);
240
- }
241
- _getAddOnName(addOnName) {
242
- const camelCase = addOnName.replace(/[-_]\w/g, text => text.replace(/[-_]/, "").toUpperCase());
243
- const wordCase = camelCase.replace(/([A-Z])/g, " $1");
244
- return wordCase.charAt(0).toUpperCase() + wordCase.slice(1);
245
- }
246
- _removeTemplateTempFiles() {
247
- fs.removeSync(this._templateRootDirectory);
248
- }
249
- };
250
- TemplateAddOnBuilder = __decorate([
251
- injectable(),
252
- __param(1, inject(ICoreTypes.Logger)),
253
- __metadata("design:paramtypes", [Function, Object])
254
- ], TemplateAddOnBuilder);
255
- export { TemplateAddOnBuilder };
256
- const LOGS = {
257
- newLine: "\n",
258
- tab: " ",
259
- couldNotLocateTemplate: "Could not locate template: {templateContentDirectory}",
260
- invalidManifestInTemplate: "Invalid manifest in the template: {templateName}. Error: {error}",
261
- successCreatedAddOn: "Success! Created {addOnName} at {addOnDirectory}.",
262
- insideDirectoryCommandsToRun: "Inside this directory, you can run the following commands:",
263
- npmRunBuild: "npm run build",
264
- npmRunStart: "npm run start",
265
- buildsTheAddOn: "Builds the Add-on.",
266
- startsTheAddOn: "Starts the development server and hosts the Add-on.",
267
- suggestBeginByTyping: "We suggest that you begin by typing:",
268
- changeDirectoryIntoCreatedApp: "cd {cdPath}",
269
- renamedReadme: "You had a 'README.md' file, we renamed it to 'README.OLD.md'",
270
- mergedGitIgnore: "You had a '.gitignore' file, we merged it with the template '.gitignore'",
271
- whatWillYouCreateToday: "So what will you create today?"
272
- };
273
- //# sourceMappingURL=TemplateAddOnBuilder.js.map
@@ -1,63 +0,0 @@
1
- /********************************************************************************
2
- * MIT License
3
-
4
- * © Copyright 2023 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
- import type { Logger, Process } from "@adobe/ccweb-add-on-core";
25
- import type { CommandExecutor as SSLCommandExecutor } from "@adobe/ccweb-add-on-ssl";
26
- import "reflect-metadata";
27
- import type { ScaffolderOptions } from "../models/ScaffolderOptions.js";
28
- import type { TemplateValidator } from "../validators/index.js";
29
- import type { AddOnBuilderFactory } from "./AddOnBuilder.js";
30
- import type { AddOnScaffolder } from "./AddOnScaffolder.js";
31
- import type { PackageBuilderFactory } from "./PackageBuilder.js";
32
- /**
33
- * Add-on scaffolder implementation class for orchestrating the creation of the Add-on project.
34
- */
35
- export declare class TemplateAddOnScaffolder implements AddOnScaffolder {
36
- private readonly _addOnBuilderFactory;
37
- private readonly _packageBuilderFactory;
38
- private readonly _templateValidator;
39
- private readonly _sslCommandExecutor;
40
- private readonly _process;
41
- private readonly _logger;
42
- /**
43
- * Instantiate {@link TemplateAppScaffolder}.
44
- * @param addOnBuilderFactory - {@link AddOnBuilderFactory} reference.
45
- * @param packageBuilderFactory - {@link PackageBuilderFactory} reference.
46
- * @param templateValidator - {@link TemplateValidator} reference.
47
- * @param sslCommandExecutor - {@link SSLCommandExecutor} reference.
48
- * @param cliProcess - {@link Process} reference.
49
- * @param logger - {@link Logger} reference.
50
- * @returns Reference to a new {@link TemplateAppScaffolder} instance.
51
- */
52
- constructor(addOnBuilderFactory: AddOnBuilderFactory, packageBuilderFactory: PackageBuilderFactory, templateValidator: TemplateValidator, sslCommandExecutor: SSLCommandExecutor, cliProcess: Process, logger: Logger);
53
- /**
54
- * Run the scaffolder to create the Add-on project from the provided options.
55
- * @param options - {@link ScaffolderOptions} reference.
56
- * @returns Promise.
57
- */
58
- run(options: ScaffolderOptions): Promise<void>;
59
- private _installDevDependencies;
60
- private _installDependencies;
61
- private _setupSSL;
62
- }
63
- //# sourceMappingURL=TemplateAddOnScaffolder.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"TemplateAddOnScaffolder.d.ts","sourceRoot":"","sources":["../../src/app/TemplateAddOnScaffolder.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;kFAsBkF;AAElF,OAAO,KAAK,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,0BAA0B,CAAC;AAEhE,OAAO,KAAK,EAAE,eAAe,IAAI,kBAAkB,EAAE,MAAM,yBAAyB,CAAC;AAGrF,OAAO,kBAAkB,CAAC;AAE1B,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,gCAAgC,CAAC;AACxE,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,wBAAwB,CAAC;AAChE,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,mBAAmB,CAAC;AAC7D,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,sBAAsB,CAAC;AAC5D,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,qBAAqB,CAAC;AAEjE;;GAEG;AACH,qBACa,uBAAwB,YAAW,eAAe;IAC3D,OAAO,CAAC,QAAQ,CAAC,oBAAoB,CAAsB;IAC3D,OAAO,CAAC,QAAQ,CAAC,sBAAsB,CAAwB;IAC/D,OAAO,CAAC,QAAQ,CAAC,kBAAkB,CAAoB;IAEvD,OAAO,CAAC,QAAQ,CAAC,mBAAmB,CAAqB;IAEzD,OAAO,CAAC,QAAQ,CAAC,QAAQ,CAAU;IACnC,OAAO,CAAC,QAAQ,CAAC,OAAO,CAAS;IAEjC;;;;;;;;;OASG;gBAE8B,mBAAmB,EAAE,mBAAmB,EACtC,qBAAqB,EAAE,qBAAqB,EACzC,iBAAiB,EAAE,iBAAiB,EACnB,kBAAkB,EAAE,kBAAkB,EAC7D,UAAU,EAAE,OAAO,EACpB,MAAM,EAAE,MAAM;IAY7C;;;;OAIG;IACG,GAAG,CAAC,OAAO,EAAE,iBAAiB,GAAG,OAAO,CAAC,IAAI,CAAC;YA4BtC,uBAAuB;YAevB,oBAAoB;YAepB,SAAS;CAI1B"}
@@ -1,130 +0,0 @@
1
- /********************************************************************************
2
- * MIT License
3
-
4
- * © Copyright 2023 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
- import { __decorate, __metadata, __param } from "tslib";
25
- import { DEFAULT_HOST_NAME, ITypes as ICoreTypes } from "@adobe/ccweb-add-on-core";
26
- import { ITypes as ISSLTypes, SetupCommandOptions } from "@adobe/ccweb-add-on-ssl";
27
- import { inject, injectable, named } from "inversify";
28
- import "reflect-metadata";
29
- import { ITypes } from "../config/inversify.types.js";
30
- /**
31
- * Add-on scaffolder implementation class for orchestrating the creation of the Add-on project.
32
- */
33
- let TemplateAddOnScaffolder = class TemplateAddOnScaffolder {
34
- _addOnBuilderFactory;
35
- _packageBuilderFactory;
36
- _templateValidator;
37
- _sslCommandExecutor;
38
- _process;
39
- _logger;
40
- /**
41
- * Instantiate {@link TemplateAppScaffolder}.
42
- * @param addOnBuilderFactory - {@link AddOnBuilderFactory} reference.
43
- * @param packageBuilderFactory - {@link PackageBuilderFactory} reference.
44
- * @param templateValidator - {@link TemplateValidator} reference.
45
- * @param sslCommandExecutor - {@link SSLCommandExecutor} reference.
46
- * @param cliProcess - {@link Process} reference.
47
- * @param logger - {@link Logger} reference.
48
- * @returns Reference to a new {@link TemplateAppScaffolder} instance.
49
- */
50
- constructor(addOnBuilderFactory, packageBuilderFactory, templateValidator, sslCommandExecutor, cliProcess, logger) {
51
- this._addOnBuilderFactory = addOnBuilderFactory;
52
- this._packageBuilderFactory = packageBuilderFactory;
53
- this._templateValidator = templateValidator;
54
- this._sslCommandExecutor = sslCommandExecutor;
55
- this._process = cliProcess;
56
- this._logger = logger;
57
- }
58
- /**
59
- * Run the scaffolder to create the Add-on project from the provided options.
60
- * @param options - {@link ScaffolderOptions} reference.
61
- * @returns Promise.
62
- */
63
- async run(options) {
64
- try {
65
- this._templateValidator.validateTemplate(options.templateName);
66
- const addOnBuilder = this._addOnBuilderFactory(options);
67
- const packageJson = addOnBuilder.getPackageJson();
68
- const templateJson = addOnBuilder.getTemplateJson();
69
- const packageBuilder = this._packageBuilderFactory(packageJson)(templateJson);
70
- const combinedPackage = packageBuilder.build();
71
- addOnBuilder.build(combinedPackage.toJSON());
72
- const templateDevDependencies = addOnBuilder.getDevDependenciesToInstall(templateJson);
73
- await this._installDevDependencies(templateDevDependencies, options.verbose);
74
- const templateDependencies = addOnBuilder.getDependenciesToInstall(templateJson);
75
- await this._installDependencies(templateDependencies, options.verbose);
76
- await this._setupSSL(options.verbose);
77
- addOnBuilder.displaySuccess();
78
- }
79
- catch (error) {
80
- this._process.handleError(error);
81
- process.exit(1);
82
- }
83
- }
84
- async _installDevDependencies(templateDevDependencies, verbose) {
85
- if (templateDevDependencies.size > 0) {
86
- const devDependencyArgs = ["install", "--save-dev", "--save-exact", ...templateDevDependencies];
87
- if (verbose) {
88
- devDependencyArgs.push("--verbose");
89
- }
90
- this._logger.information(LOGS.installingTemplateDevDependencies, {
91
- prefix: LOGS.newLine
92
- });
93
- await this._process.execute("npm", devDependencyArgs, { stdio: "inherit" });
94
- }
95
- }
96
- async _installDependencies(templateDependencies, verbose) {
97
- if (templateDependencies.size > 0) {
98
- const dependencyArgs = ["install", "--save", "--save-exact", ...templateDependencies];
99
- if (verbose) {
100
- dependencyArgs.push("--verbose");
101
- }
102
- this._logger.information(LOGS.installingTemplateDependencies, {
103
- prefix: LOGS.newLine
104
- });
105
- await this._process.execute("npm", dependencyArgs, { stdio: "inherit" });
106
- }
107
- }
108
- async _setupSSL(verbose) {
109
- const setupCommandOptions = new SetupCommandOptions(DEFAULT_HOST_NAME, true, verbose);
110
- await this._sslCommandExecutor.execute(setupCommandOptions);
111
- }
112
- };
113
- TemplateAddOnScaffolder = __decorate([
114
- injectable(),
115
- __param(0, inject(ITypes.AddOnBuilder)),
116
- __param(1, inject(ITypes.PackageBuilder)),
117
- __param(2, inject(ITypes.TemplateValidator)),
118
- __param(3, inject(ISSLTypes.CommandExecutor)),
119
- __param(3, named("setup")),
120
- __param(4, inject(ICoreTypes.Process)),
121
- __param(5, inject(ICoreTypes.Logger)),
122
- __metadata("design:paramtypes", [Function, Function, Object, Object, Object, Object])
123
- ], TemplateAddOnScaffolder);
124
- export { TemplateAddOnScaffolder };
125
- const LOGS = {
126
- newLine: "\n",
127
- installingTemplateDevDependencies: "Installing template dev dependencies ...",
128
- installingTemplateDependencies: "Installing template dependencies ..."
129
- };
130
- //# sourceMappingURL=TemplateAddOnScaffolder.js.map
@@ -1,49 +0,0 @@
1
- /********************************************************************************
2
- * MIT License
3
-
4
- * © Copyright 2023 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
- import type { TemplateJson } from "@adobe/ccweb-add-on-core";
25
- import { PackageJson } from "@adobe/ccweb-add-on-core";
26
- import type { PackageBuilder } from "./PackageBuilder.js";
27
- /**
28
- * Package builder implementation class for constructing the package.json of the Add-on project.
29
- */
30
- export declare class TemplatePackageBuilder implements PackageBuilder {
31
- private _combinedPackage;
32
- private _templateJson;
33
- /**
34
- * Instantiate {@link TemplatePackageBuilder}.
35
- *
36
- * @param packageJson - {@link PackageJson}.
37
- * @param templateJson - {@link TemplateJson}.
38
- * @returns Reference to a new {@link TemplatePackageBuilder} instance.
39
- */
40
- constructor(packageJson: PackageJson, templateJson: TemplateJson);
41
- /**
42
- * Build {@link PackageJson}.
43
- */
44
- build(): PackageJson;
45
- private _buildDevDependencies;
46
- private _buildDependencies;
47
- private _buildScripts;
48
- }
49
- //# sourceMappingURL=TemplatePackageBuilder.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"TemplatePackageBuilder.d.ts","sourceRoot":"","sources":["../../src/app/TemplatePackageBuilder.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;kFAsBkF;AAElF,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,0BAA0B,CAAC;AAC7D,OAAO,EAAE,WAAW,EAAE,MAAM,0BAA0B,CAAC;AAEvD,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,qBAAqB,CAAC;AAE1D;;GAEG;AACH,qBACa,sBAAuB,YAAW,cAAc;IACzD,OAAO,CAAC,gBAAgB,CAAc;IACtC,OAAO,CAAC,aAAa,CAAe;IAEpC;;;;;;OAMG;gBACS,WAAW,EAAE,WAAW,EAAE,YAAY,EAAE,YAAY;IAKhE;;OAEG;IACH,KAAK,IAAI,WAAW;IAQpB,OAAO,CAAC,qBAAqB;IAc7B,OAAO,CAAC,kBAAkB;IAc1B,OAAO,CAAC,aAAa;CAaxB"}
@@ -1,92 +0,0 @@
1
- /********************************************************************************
2
- * MIT License
3
-
4
- * © Copyright 2023 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
- import { __decorate, __metadata } from "tslib";
25
- import { PackageJson } from "@adobe/ccweb-add-on-core";
26
- import { injectable } from "inversify";
27
- /**
28
- * Package builder implementation class for constructing the package.json of the Add-on project.
29
- */
30
- let TemplatePackageBuilder = class TemplatePackageBuilder {
31
- _combinedPackage;
32
- _templateJson;
33
- /**
34
- * Instantiate {@link TemplatePackageBuilder}.
35
- *
36
- * @param packageJson - {@link PackageJson}.
37
- * @param templateJson - {@link TemplateJson}.
38
- * @returns Reference to a new {@link TemplatePackageBuilder} instance.
39
- */
40
- constructor(packageJson, templateJson) {
41
- this._combinedPackage = new PackageJson({ ...packageJson });
42
- this._templateJson = templateJson;
43
- }
44
- /**
45
- * Build {@link PackageJson}.
46
- */
47
- build() {
48
- this._buildDevDependencies();
49
- this._buildDependencies();
50
- this._buildScripts();
51
- return this._combinedPackage;
52
- }
53
- _buildDevDependencies() {
54
- if (!this._templateJson.devDependencies || this._templateJson.devDependencies.size === 0) {
55
- return;
56
- }
57
- this._templateJson.devDependencies.forEach((value, key) => {
58
- if (!this._combinedPackage.devDependencies) {
59
- this._combinedPackage.devDependencies = new Map();
60
- }
61
- this._combinedPackage.devDependencies.set(key, value);
62
- });
63
- }
64
- _buildDependencies() {
65
- if (!this._templateJson.dependencies || this._templateJson.dependencies.size === 0) {
66
- return;
67
- }
68
- this._templateJson.dependencies.forEach((value, key) => {
69
- if (!this._combinedPackage.dependencies) {
70
- this._combinedPackage.dependencies = new Map();
71
- }
72
- this._combinedPackage.dependencies.set(key, value);
73
- });
74
- }
75
- _buildScripts() {
76
- if (!this._templateJson.scripts || this._templateJson.scripts.size === 0) {
77
- return;
78
- }
79
- this._templateJson.scripts.forEach((value, key) => {
80
- if (!this._combinedPackage.scripts) {
81
- this._combinedPackage.scripts = new Map();
82
- }
83
- this._combinedPackage.scripts.set(key, value);
84
- });
85
- }
86
- };
87
- TemplatePackageBuilder = __decorate([
88
- injectable(),
89
- __metadata("design:paramtypes", [PackageJson, Function])
90
- ], TemplatePackageBuilder);
91
- export { TemplatePackageBuilder };
92
- //# sourceMappingURL=TemplatePackageBuilder.js.map
@@ -1,46 +0,0 @@
1
- /********************************************************************************
2
- * MIT License
3
-
4
- * © Copyright 2023 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
- import type { Logger } from "@adobe/ccweb-add-on-core";
25
- import "reflect-metadata";
26
- import type { TemplateValidator } from "./TemplateValidator.js";
27
- /**
28
- * Template validator implementation class to validate user selected template..
29
- */
30
- export declare class AddOnTemplateValidator implements TemplateValidator {
31
- private readonly _logger;
32
- /**
33
- * Instantiate {@link AppTemplateValidator}.
34
- *
35
- * @param logger - {@link Logger} reference.
36
- * @returns Reference to a new {@link AppTemplateValidator} instance.
37
- */
38
- constructor(logger: Logger);
39
- /**
40
- * Validate the template.
41
- *
42
- * @param templateName - Name of the template.
43
- */
44
- validateTemplate(templateName: string): void;
45
- }
46
- //# sourceMappingURL=AddOnTemplateValidator.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"AddOnTemplateValidator.d.ts","sourceRoot":"","sources":["../../src/validators/AddOnTemplateValidator.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;kFAsBkF;AAElF,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,0BAA0B,CAAC;AAIvD,OAAO,kBAAkB,CAAC;AAG1B,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,wBAAwB,CAAC;AAEhE;;GAEG;AACH,qBACa,sBAAuB,YAAW,iBAAiB;IAC5D,OAAO,CAAC,QAAQ,CAAC,OAAO,CAAS;IAEjC;;;;;OAKG;gBACoC,MAAM,EAAE,MAAM;IAIrD;;;;OAIG;IACH,gBAAgB,CAAC,YAAY,EAAE,MAAM,GAAG,IAAI;CAc/C"}