@adobe/ccweb-add-on-scaffolder 0.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.
- package/.c8rc.json +7 -0
- package/.mocharc.json +5 -0
- package/CODE_OF_CONDUCT.md +79 -0
- package/CONTRIBUTING.md +47 -0
- package/LICENSE +21 -0
- package/README.md +11 -0
- package/dist/app/AddOnBuilder.d.ts +72 -0
- package/dist/app/AddOnBuilder.d.ts.map +1 -0
- package/dist/app/AddOnBuilder.js +25 -0
- package/dist/app/AddOnScaffolder.d.ts +36 -0
- package/dist/app/AddOnScaffolder.d.ts.map +1 -0
- package/dist/app/AddOnScaffolder.js +25 -0
- package/dist/app/PackageBuilder.d.ts +38 -0
- package/dist/app/PackageBuilder.d.ts.map +1 -0
- package/dist/app/PackageBuilder.js +25 -0
- package/dist/app/TemplateAddOnBuilder.d.ts +90 -0
- package/dist/app/TemplateAddOnBuilder.d.ts.map +1 -0
- package/dist/app/TemplateAddOnBuilder.js +273 -0
- package/dist/app/TemplateAddOnScaffolder.d.ts +63 -0
- package/dist/app/TemplateAddOnScaffolder.d.ts.map +1 -0
- package/dist/app/TemplateAddOnScaffolder.js +130 -0
- package/dist/app/TemplatePackageBuilder.d.ts +49 -0
- package/dist/app/TemplatePackageBuilder.d.ts.map +1 -0
- package/dist/app/TemplatePackageBuilder.js +92 -0
- package/dist/app/index.d.ts +30 -0
- package/dist/app/index.d.ts.map +1 -0
- package/dist/app/index.js +30 -0
- package/dist/config/index.d.ts +26 -0
- package/dist/config/index.d.ts.map +1 -0
- package/dist/config/index.js +26 -0
- package/dist/config/inversify.config.d.ts +27 -0
- package/dist/config/inversify.config.d.ts.map +1 -0
- package/dist/config/inversify.config.js +47 -0
- package/dist/config/inversify.types.d.ts +31 -0
- package/dist/config/inversify.types.d.ts.map +1 -0
- package/dist/config/inversify.types.js +31 -0
- package/dist/constants.d.ts +33 -0
- package/dist/constants.d.ts.map +1 -0
- package/dist/constants.js +34 -0
- package/dist/index.d.ts +28 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +28 -0
- package/dist/models/ScaffolderOptions.d.ts +65 -0
- package/dist/models/ScaffolderOptions.d.ts.map +1 -0
- package/dist/models/ScaffolderOptions.js +71 -0
- package/dist/models/index.d.ts +25 -0
- package/dist/models/index.d.ts.map +1 -0
- package/dist/models/index.js +25 -0
- package/dist/tsconfig.tsbuildinfo +1 -0
- package/dist/validators/AddOnTemplateValidator.d.ts +46 -0
- package/dist/validators/AddOnTemplateValidator.d.ts.map +1 -0
- package/dist/validators/AddOnTemplateValidator.js +78 -0
- package/dist/validators/TemplateValidator.d.ts +35 -0
- package/dist/validators/TemplateValidator.d.ts.map +1 -0
- package/dist/validators/TemplateValidator.js +25 -0
- package/dist/validators/index.d.ts +26 -0
- package/dist/validators/index.d.ts.map +1 -0
- package/dist/validators/index.js +26 -0
- package/package.json +57 -0
- package/src/app/AddOnBuilder.ts +79 -0
- package/src/app/AddOnScaffolder.ts +37 -0
- package/src/app/PackageBuilder.ts +40 -0
- package/src/app/TemplateAddOnBuilder.ts +319 -0
- package/src/app/TemplateAddOnScaffolder.ts +153 -0
- package/src/app/TemplatePackageBuilder.ts +102 -0
- package/src/app/index.ts +30 -0
- package/src/config/index.ts +26 -0
- package/src/config/inversify.config.ts +58 -0
- package/src/config/inversify.types.ts +31 -0
- package/src/constants.ts +36 -0
- package/src/index.ts +28 -0
- package/src/models/ScaffolderOptions.ts +86 -0
- package/src/models/index.ts +25 -0
- package/src/test/app/TemplateAddOnBuilder.spec.ts +1391 -0
- package/src/test/app/TemplateAddOnScaffolder.spec.ts +272 -0
- package/src/test/app/TemplatePackageBuilder.spec.ts +332 -0
- package/src/test/app/data/first-test-app/.template/template.json +10 -0
- package/src/test/app/data/first-test-app/package.json +19 -0
- package/src/test/app/data/first-test-app/src/manifest.json +21 -0
- package/src/test/app/data/first_test_app/.template/template.json +10 -0
- package/src/test/app/data/first_test_app/package.json +19 -0
- package/src/test/app/data/first_test_app/src/manifest.json +21 -0
- package/src/test/app/data/second-test-app/package.json +19 -0
- package/src/test/app/data/second-test-app/src/manifest.json +33 -0
- package/src/test/app/data/third-test-app/.template/template.json +10 -0
- package/src/test/app/data/third-test-app/package.json +19 -0
- package/src/test/app/data/third-test-app/src/manifest.json +23 -0
- package/src/test/models/ScaffolderOptions.spec.ts +61 -0
- package/src/test/validators/AppTemplateValidator.spec.ts +98 -0
- package/src/validators/AddOnTemplateValidator.ts +79 -0
- package/src/validators/TemplateValidator.ts +35 -0
- package/src/validators/index.ts +26 -0
- package/tsconfig.json +28 -0
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "iframe-panel",
|
|
3
|
+
"version": "1.0.0",
|
|
4
|
+
"description": "Iframe Add-on.",
|
|
5
|
+
"scripts": {
|
|
6
|
+
"clean": "ccweb-add-on-scripts clean",
|
|
7
|
+
"build": "ccweb-add-on-scripts build",
|
|
8
|
+
"start": "ccweb-add-on-scripts start"
|
|
9
|
+
},
|
|
10
|
+
"keywords": [
|
|
11
|
+
"Adobe",
|
|
12
|
+
"Horizon",
|
|
13
|
+
"WXP",
|
|
14
|
+
"Iframe",
|
|
15
|
+
"Panel"
|
|
16
|
+
],
|
|
17
|
+
"author": "Adobe Systems Inc.",
|
|
18
|
+
"license": "ISC"
|
|
19
|
+
}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
{
|
|
2
|
+
"testId": "",
|
|
3
|
+
"name": "",
|
|
4
|
+
"version": "",
|
|
5
|
+
"manifestVersion": 2,
|
|
6
|
+
"requirements": {
|
|
7
|
+
"apps": [
|
|
8
|
+
{
|
|
9
|
+
"name": "Express",
|
|
10
|
+
"apiVersion": 1
|
|
11
|
+
}
|
|
12
|
+
]
|
|
13
|
+
},
|
|
14
|
+
"entryPoints": [
|
|
15
|
+
{
|
|
16
|
+
"type": "panel",
|
|
17
|
+
"id": "panel1",
|
|
18
|
+
"main": "index.html"
|
|
19
|
+
}
|
|
20
|
+
]
|
|
21
|
+
}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "iframe-panel",
|
|
3
|
+
"version": "1.0.0",
|
|
4
|
+
"description": "Iframe Add-on.",
|
|
5
|
+
"scripts": {
|
|
6
|
+
"clean": "ccweb-add-on-scripts clean",
|
|
7
|
+
"build": "ccweb-add-on-scripts build",
|
|
8
|
+
"start": "ccweb-add-on-scripts start"
|
|
9
|
+
},
|
|
10
|
+
"keywords": [
|
|
11
|
+
"Adobe",
|
|
12
|
+
"Horizon",
|
|
13
|
+
"WXP",
|
|
14
|
+
"Iframe",
|
|
15
|
+
"Panel"
|
|
16
|
+
],
|
|
17
|
+
"author": "Adobe Systems Inc.",
|
|
18
|
+
"license": "ISC"
|
|
19
|
+
}
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
{
|
|
2
|
+
"id": "",
|
|
3
|
+
"name": "",
|
|
4
|
+
"version": "",
|
|
5
|
+
"manifestVersion": 1,
|
|
6
|
+
"requirements": {
|
|
7
|
+
"apps": ["Express"]
|
|
8
|
+
},
|
|
9
|
+
"icon": [
|
|
10
|
+
{
|
|
11
|
+
"width": 100,
|
|
12
|
+
"height": 100,
|
|
13
|
+
"path": "icon-light.png",
|
|
14
|
+
"theme": ["light"]
|
|
15
|
+
},
|
|
16
|
+
{
|
|
17
|
+
"width": 100,
|
|
18
|
+
"height": 100,
|
|
19
|
+
"path": "icon-dark.png",
|
|
20
|
+
"theme": ["dark"]
|
|
21
|
+
}
|
|
22
|
+
],
|
|
23
|
+
"entryPoints": [
|
|
24
|
+
{
|
|
25
|
+
"type": "panel",
|
|
26
|
+
"id": "panel1",
|
|
27
|
+
"label": {
|
|
28
|
+
"default": ""
|
|
29
|
+
},
|
|
30
|
+
"main": "index.html"
|
|
31
|
+
}
|
|
32
|
+
]
|
|
33
|
+
}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "iframe-panel",
|
|
3
|
+
"version": "1.0.0",
|
|
4
|
+
"description": "Iframe Add-on",
|
|
5
|
+
"scripts": {
|
|
6
|
+
"clean": "ccweb-add-on-scripts clean",
|
|
7
|
+
"build": "ccweb-add-on-scripts build",
|
|
8
|
+
"start": "ccweb-add-on-scripts start"
|
|
9
|
+
},
|
|
10
|
+
"keywords": [
|
|
11
|
+
"Adobe",
|
|
12
|
+
"Horizon",
|
|
13
|
+
"WXP",
|
|
14
|
+
"Iframe",
|
|
15
|
+
"Panel"
|
|
16
|
+
],
|
|
17
|
+
"author": "Adobe Systems Inc.",
|
|
18
|
+
"license": "ISC"
|
|
19
|
+
}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
{
|
|
2
|
+
"id": "",
|
|
3
|
+
"name": "",
|
|
4
|
+
"version": "",
|
|
5
|
+
"manifestVersion": 1,
|
|
6
|
+
"requirements": {
|
|
7
|
+
"apps": ["Express"]
|
|
8
|
+
},
|
|
9
|
+
"icon": [
|
|
10
|
+
{
|
|
11
|
+
"width": 100,
|
|
12
|
+
"height": 100,
|
|
13
|
+
"path": "icon-light.png",
|
|
14
|
+
"theme": ["light"]
|
|
15
|
+
},
|
|
16
|
+
{
|
|
17
|
+
"width": 100,
|
|
18
|
+
"height": 100,
|
|
19
|
+
"path": "icon-dark.png",
|
|
20
|
+
"theme": ["dark"]
|
|
21
|
+
}
|
|
22
|
+
]
|
|
23
|
+
}
|
|
@@ -0,0 +1,61 @@
|
|
|
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
|
+
|
|
25
|
+
import { EntrypointType } from "@adobe/ccweb-add-on-manifest";
|
|
26
|
+
import { assert } from "chai";
|
|
27
|
+
import "mocha";
|
|
28
|
+
import { ScaffolderOptions } from "../../models/index.js";
|
|
29
|
+
|
|
30
|
+
describe("ScaffolderOptions", () => {
|
|
31
|
+
describe("constructor", () => {
|
|
32
|
+
const runs = [
|
|
33
|
+
{
|
|
34
|
+
addOnDirectory: "/apps/test-app",
|
|
35
|
+
addOnName: "test-app",
|
|
36
|
+
addOnKind: EntrypointType.PANEL,
|
|
37
|
+
rootDirectory: "/apps",
|
|
38
|
+
templateName: "javascript",
|
|
39
|
+
verbose: false
|
|
40
|
+
}
|
|
41
|
+
];
|
|
42
|
+
runs.forEach(run => {
|
|
43
|
+
it(`should create a new instance for: ${run.addOnKind}.`, () => {
|
|
44
|
+
const scaffolderOptions = new ScaffolderOptions(
|
|
45
|
+
run.addOnDirectory,
|
|
46
|
+
run.addOnName,
|
|
47
|
+
run.addOnKind as EntrypointType,
|
|
48
|
+
run.rootDirectory,
|
|
49
|
+
run.templateName,
|
|
50
|
+
run.verbose
|
|
51
|
+
);
|
|
52
|
+
assert.equal(scaffolderOptions.addOnDirectory, run.addOnDirectory);
|
|
53
|
+
assert.equal(scaffolderOptions.addOnName, run.addOnName);
|
|
54
|
+
assert.equal(scaffolderOptions.addOnKind, run.addOnKind);
|
|
55
|
+
assert.equal(scaffolderOptions.rootDirectory, run.rootDirectory);
|
|
56
|
+
assert.equal(scaffolderOptions.templateName, run.templateName);
|
|
57
|
+
assert.equal(scaffolderOptions.verbose, run.verbose);
|
|
58
|
+
});
|
|
59
|
+
});
|
|
60
|
+
});
|
|
61
|
+
});
|
|
@@ -0,0 +1,98 @@
|
|
|
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
|
+
|
|
25
|
+
import type { Logger } from "@adobe/ccweb-add-on-core";
|
|
26
|
+
import { assert } from "chai";
|
|
27
|
+
import "mocha";
|
|
28
|
+
import type { SinonSandbox } from "sinon";
|
|
29
|
+
import sinon from "sinon";
|
|
30
|
+
import type { StubbedInstance } from "ts-sinon";
|
|
31
|
+
import { stubInterface } from "ts-sinon";
|
|
32
|
+
import { PROGRAM_NAME } from "../../constants.js";
|
|
33
|
+
import type { TemplateValidator } from "../../validators/index.js";
|
|
34
|
+
import { AddOnTemplateValidator } from "../../validators/index.js";
|
|
35
|
+
|
|
36
|
+
describe("AddOnTemplateValidator", () => {
|
|
37
|
+
describe("validateTemplate ...", () => {
|
|
38
|
+
let sandbox: SinonSandbox;
|
|
39
|
+
let logger: StubbedInstance<Logger>;
|
|
40
|
+
let validator: TemplateValidator;
|
|
41
|
+
|
|
42
|
+
beforeEach(() => {
|
|
43
|
+
sandbox = sinon.createSandbox();
|
|
44
|
+
logger = stubInterface<Logger>();
|
|
45
|
+
validator = new AddOnTemplateValidator(logger);
|
|
46
|
+
});
|
|
47
|
+
|
|
48
|
+
afterEach(() => {
|
|
49
|
+
sandbox.restore();
|
|
50
|
+
});
|
|
51
|
+
|
|
52
|
+
let runs = [{ template: "" }, { template: " " }];
|
|
53
|
+
runs.forEach(run => {
|
|
54
|
+
it(`should exit for empty template: ${run.template}.`, () => {
|
|
55
|
+
const processExitStub = sandbox.stub(process, "exit");
|
|
56
|
+
|
|
57
|
+
validator.validateTemplate(run.template);
|
|
58
|
+
|
|
59
|
+
assert.equal(logger.warning.callCount, 2);
|
|
60
|
+
assert.equal(logger.warning.getCall(0).calledWith("Please specify a valid template name:"), true);
|
|
61
|
+
assert.equal(
|
|
62
|
+
logger.warning
|
|
63
|
+
.getCall(1)
|
|
64
|
+
.calledWith(`${PROGRAM_NAME} --template <template-name>`, { prefix: " " }),
|
|
65
|
+
true
|
|
66
|
+
);
|
|
67
|
+
|
|
68
|
+
assert.equal(logger.message.callCount, 1);
|
|
69
|
+
assert.equal(
|
|
70
|
+
logger.message.calledWith("For example:", {
|
|
71
|
+
prefix: "\n"
|
|
72
|
+
}),
|
|
73
|
+
true
|
|
74
|
+
);
|
|
75
|
+
|
|
76
|
+
assert.equal(logger.information.callCount, 1);
|
|
77
|
+
assert.equal(
|
|
78
|
+
logger.information.calledWith(`${PROGRAM_NAME} --template javascript`, { prefix: " " }),
|
|
79
|
+
true
|
|
80
|
+
);
|
|
81
|
+
|
|
82
|
+
assert.equal(processExitStub.callCount, 1);
|
|
83
|
+
assert.equal(processExitStub.calledWith(1), true);
|
|
84
|
+
});
|
|
85
|
+
});
|
|
86
|
+
|
|
87
|
+
runs = [{ template: "javascript" }];
|
|
88
|
+
runs.forEach(run => {
|
|
89
|
+
it(`should return for non-empty template: ${run.template}.`, () => {
|
|
90
|
+
const processExitStub = sandbox.stub(process, "exit");
|
|
91
|
+
|
|
92
|
+
validator.validateTemplate(run.template);
|
|
93
|
+
|
|
94
|
+
assert.equal(processExitStub.callCount, 0);
|
|
95
|
+
});
|
|
96
|
+
});
|
|
97
|
+
});
|
|
98
|
+
});
|
|
@@ -0,0 +1,79 @@
|
|
|
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
|
+
|
|
25
|
+
import type { Logger } from "@adobe/ccweb-add-on-core";
|
|
26
|
+
import { ITypes as ICoreTypes, isNullOrWhiteSpace } from "@adobe/ccweb-add-on-core";
|
|
27
|
+
import { inject, injectable } from "inversify";
|
|
28
|
+
import process from "process";
|
|
29
|
+
import "reflect-metadata";
|
|
30
|
+
import format from "string-template";
|
|
31
|
+
import { PROGRAM_NAME } from "../constants.js";
|
|
32
|
+
import type { TemplateValidator } from "./TemplateValidator.js";
|
|
33
|
+
|
|
34
|
+
/**
|
|
35
|
+
* Template validator implementation class to validate user selected template..
|
|
36
|
+
*/
|
|
37
|
+
@injectable()
|
|
38
|
+
export class AddOnTemplateValidator implements TemplateValidator {
|
|
39
|
+
private readonly _logger: Logger;
|
|
40
|
+
|
|
41
|
+
/**
|
|
42
|
+
* Instantiate {@link AppTemplateValidator}.
|
|
43
|
+
*
|
|
44
|
+
* @param logger - {@link Logger} reference.
|
|
45
|
+
* @returns Reference to a new {@link AppTemplateValidator} instance.
|
|
46
|
+
*/
|
|
47
|
+
constructor(@inject(ICoreTypes.Logger) logger: Logger) {
|
|
48
|
+
this._logger = logger;
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
/**
|
|
52
|
+
* Validate the template.
|
|
53
|
+
*
|
|
54
|
+
* @param templateName - Name of the template.
|
|
55
|
+
*/
|
|
56
|
+
validateTemplate(templateName: string) {
|
|
57
|
+
if (isNullOrWhiteSpace(templateName)) {
|
|
58
|
+
this._logger.warning(LOGS.specifyValidTemplateName);
|
|
59
|
+
this._logger.warning(format(LOGS.executeProgram, { PROGRAM_NAME }), {
|
|
60
|
+
prefix: LOGS.tab
|
|
61
|
+
});
|
|
62
|
+
this._logger.message(LOGS.forExample, { prefix: LOGS.newLine });
|
|
63
|
+
this._logger.information(format(LOGS.executeProgramExample, { PROGRAM_NAME }), {
|
|
64
|
+
prefix: LOGS.tab
|
|
65
|
+
});
|
|
66
|
+
|
|
67
|
+
process.exit(1);
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
const LOGS = {
|
|
73
|
+
newLine: "\n",
|
|
74
|
+
tab: " ",
|
|
75
|
+
specifyValidTemplateName: "Please specify a valid template name:",
|
|
76
|
+
executeProgram: "{PROGRAM_NAME} --template <template-name>",
|
|
77
|
+
executeProgramExample: "{PROGRAM_NAME} --template javascript",
|
|
78
|
+
forExample: "For example:"
|
|
79
|
+
};
|
|
@@ -0,0 +1,35 @@
|
|
|
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
|
+
|
|
25
|
+
/**
|
|
26
|
+
* Template validator interface to validate user selected template.
|
|
27
|
+
*/
|
|
28
|
+
export interface TemplateValidator {
|
|
29
|
+
/**
|
|
30
|
+
* Validate the template.
|
|
31
|
+
*
|
|
32
|
+
* @param templateName - Name of the template.
|
|
33
|
+
*/
|
|
34
|
+
validateTemplate(templateName: string): void;
|
|
35
|
+
}
|
|
@@ -0,0 +1,26 @@
|
|
|
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
|
+
|
|
25
|
+
export * from "./AddOnTemplateValidator.js";
|
|
26
|
+
export * from "./TemplateValidator.js";
|
package/tsconfig.json
ADDED
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
{
|
|
2
|
+
"compilerOptions": {
|
|
3
|
+
"allowSyntheticDefaultImports": true,
|
|
4
|
+
"declaration": true,
|
|
5
|
+
"declarationMap": true,
|
|
6
|
+
"emitDecoratorMetadata": true,
|
|
7
|
+
"esModuleInterop": true,
|
|
8
|
+
"experimentalDecorators": true,
|
|
9
|
+
"forceConsistentCasingInFileNames": true,
|
|
10
|
+
"importHelpers": true,
|
|
11
|
+
"incremental": true,
|
|
12
|
+
"isolatedModules": true,
|
|
13
|
+
"module": "ESNext",
|
|
14
|
+
"moduleResolution": "node",
|
|
15
|
+
"noImplicitOverride": false,
|
|
16
|
+
"noUnusedLocals": true,
|
|
17
|
+
"outDir": "dist",
|
|
18
|
+
"preserveConstEnums": true,
|
|
19
|
+
"resolveJsonModule": true,
|
|
20
|
+
"sourceMap": true,
|
|
21
|
+
"strict": true,
|
|
22
|
+
"target": "ESNext",
|
|
23
|
+
"types": ["reflect-metadata"],
|
|
24
|
+
"useUnknownInCatchVariables": false
|
|
25
|
+
},
|
|
26
|
+
"exclude": ["node_modules", "src/test/**/*"],
|
|
27
|
+
"include": ["src/**/*"]
|
|
28
|
+
}
|