@microsoft/generator-sharepoint 1.20.0 → 1.21.0-beta.2
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/lib/common/BaseGenerator.js +161 -121
- package/lib/common/ConfigJsonManager.js +45 -29
- package/lib/common/JsonManager.js +70 -29
- package/lib/common/PackageJsonManager.js +28 -8
- package/lib/common/PackageSolutionJsonManager.js +41 -23
- package/lib/common/ServeJsonManager.js +69 -31
- package/lib/common/TeamsManifestJsonManager.js +33 -21
- package/lib/common/YeomanConfiguration.js +25 -8
- package/lib/common/bundles-versions.json +1 -4
- package/lib/common/dependencies.json +62 -100
- package/lib/common/spsay.js +32 -19
- package/lib/common/utilities.js +97 -63
- package/lib/generators/adaptiveCardExtension/BaseAdaptiveCardExtensionGenerator.js +86 -41
- package/lib/generators/adaptiveCardExtension/index.js +103 -62
- package/lib/generators/app/index.js +138 -117
- package/lib/generators/applicationCustomizer/index.js +89 -45
- package/lib/generators/commandSet/index.js +89 -45
- package/lib/generators/component/BaseComponentGenerator.js +130 -77
- package/lib/generators/component/index.js +108 -69
- package/lib/generators/dataVisualizationAdaptiveCardExtension/index.js +72 -43
- package/lib/generators/extension/BaseExtensionGenerator.js +95 -49
- package/lib/generators/extension/index.js +104 -64
- package/lib/generators/fieldCustomizer/index.js +97 -50
- package/lib/generators/formCustomizer/index.js +99 -52
- package/lib/generators/formCustomizer/templates/none/{componentClassName}.ts +6 -2
- package/lib/generators/genericAdaptiveCardExtension/index.js +80 -46
- package/lib/generators/library/index.js +89 -43
- package/lib/generators/searchAdaptiveCardExtension/index.js +72 -43
- package/lib/generators/searchQueryModifier/index.js +89 -45
- package/lib/generators/solution/heft.package.json +1 -1
- package/lib/generators/solution/index.js +110 -80
- package/lib/generators/solution/non-heft.package.json +1 -1
- package/lib/generators/webpart/index.js +99 -50
- package/lib/generators/webpart/initial.teamsManifest.json +2 -4
- package/package.json +38 -12
- package/lib/common/BaseGenerator.d.ts +0 -59
- package/lib/common/BaseGenerator.d.ts.map +0 -1
- package/lib/common/ConfigJsonManager.d.ts +0 -16
- package/lib/common/ConfigJsonManager.d.ts.map +0 -1
- package/lib/common/JsonManager.d.ts +0 -12
- package/lib/common/JsonManager.d.ts.map +0 -1
- package/lib/common/PackageJsonManager.d.ts +0 -18
- package/lib/common/PackageJsonManager.d.ts.map +0 -1
- package/lib/common/PackageSolutionJsonManager.d.ts +0 -20
- package/lib/common/PackageSolutionJsonManager.d.ts.map +0 -1
- package/lib/common/ServeJsonManager.d.ts +0 -12
- package/lib/common/ServeJsonManager.d.ts.map +0 -1
- package/lib/common/TeamsManifestJsonManager.d.ts +0 -51
- package/lib/common/TeamsManifestJsonManager.d.ts.map +0 -1
- package/lib/common/YeomanConfiguration.d.ts +0 -25
- package/lib/common/YeomanConfiguration.d.ts.map +0 -1
- package/lib/common/spsay.d.ts +0 -2
- package/lib/common/spsay.d.ts.map +0 -1
- package/lib/common/utilities.d.ts +0 -9
- package/lib/common/utilities.d.ts.map +0 -1
- package/lib/generators/adaptiveCardExtension/BaseAdaptiveCardExtensionGenerator.d.ts +0 -18
- package/lib/generators/adaptiveCardExtension/BaseAdaptiveCardExtensionGenerator.d.ts.map +0 -1
- package/lib/generators/adaptiveCardExtension/index.d.ts +0 -23
- package/lib/generators/adaptiveCardExtension/index.d.ts.map +0 -1
- package/lib/generators/app/index.d.ts +0 -10
- package/lib/generators/app/index.d.ts.map +0 -1
- package/lib/generators/applicationCustomizer/index.d.ts +0 -24
- package/lib/generators/applicationCustomizer/index.d.ts.map +0 -1
- package/lib/generators/commandSet/index.d.ts +0 -23
- package/lib/generators/commandSet/index.d.ts.map +0 -1
- package/lib/generators/component/BaseComponentGenerator.d.ts +0 -56
- package/lib/generators/component/BaseComponentGenerator.d.ts.map +0 -1
- package/lib/generators/component/index.d.ts +0 -23
- package/lib/generators/component/index.d.ts.map +0 -1
- package/lib/generators/dataVisualizationAdaptiveCardExtension/index.d.ts +0 -19
- package/lib/generators/dataVisualizationAdaptiveCardExtension/index.d.ts.map +0 -1
- package/lib/generators/extension/BaseExtensionGenerator.d.ts +0 -19
- package/lib/generators/extension/BaseExtensionGenerator.d.ts.map +0 -1
- package/lib/generators/extension/index.d.ts +0 -26
- package/lib/generators/extension/index.d.ts.map +0 -1
- package/lib/generators/fieldCustomizer/index.d.ts +0 -24
- package/lib/generators/fieldCustomizer/index.d.ts.map +0 -1
- package/lib/generators/formCustomizer/index.d.ts +0 -24
- package/lib/generators/formCustomizer/index.d.ts.map +0 -1
- package/lib/generators/genericAdaptiveCardExtension/index.d.ts +0 -21
- package/lib/generators/genericAdaptiveCardExtension/index.d.ts.map +0 -1
- package/lib/generators/library/index.d.ts +0 -23
- package/lib/generators/library/index.d.ts.map +0 -1
- package/lib/generators/searchAdaptiveCardExtension/index.d.ts +0 -19
- package/lib/generators/searchAdaptiveCardExtension/index.d.ts.map +0 -1
- package/lib/generators/searchQueryModifier/index.d.ts +0 -23
- package/lib/generators/searchQueryModifier/index.d.ts.map +0 -1
- package/lib/generators/solution/index.d.ts +0 -19
- package/lib/generators/solution/index.d.ts.map +0 -1
- package/lib/generators/webpart/index.d.ts +0 -23
- package/lib/generators/webpart/index.d.ts.map +0 -1
|
@@ -1,44 +1,90 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
2
|
+
Object.defineProperty(exports, "__esModule", {
|
|
3
|
+
value: true
|
|
4
|
+
});
|
|
5
|
+
function _export(target, all) {
|
|
6
|
+
for(var name in all)Object.defineProperty(target, name, {
|
|
7
|
+
enumerable: true,
|
|
8
|
+
get: all[name]
|
|
9
|
+
});
|
|
10
|
+
}
|
|
11
|
+
_export(exports, {
|
|
12
|
+
CommandSetGenerator: function() {
|
|
13
|
+
return CommandSetGenerator;
|
|
14
|
+
},
|
|
15
|
+
composeWith: function() {
|
|
16
|
+
return composeWith;
|
|
17
|
+
},
|
|
18
|
+
defineOptions: function() {
|
|
19
|
+
return defineOptions;
|
|
7
20
|
}
|
|
8
|
-
Object.defineProperty(o, k2, desc);
|
|
9
|
-
}) : (function(o, m, k, k2) {
|
|
10
|
-
if (k2 === undefined) k2 = k;
|
|
11
|
-
o[k2] = m[k];
|
|
12
|
-
}));
|
|
13
|
-
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
-
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
-
}) : function(o, v) {
|
|
16
|
-
o["default"] = v;
|
|
17
21
|
});
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
22
|
+
const _path = /*#__PURE__*/ _interop_require_wildcard(require("path"));
|
|
23
|
+
const _utilities = /*#__PURE__*/ _interop_require_wildcard(require("../../common/utilities"));
|
|
24
|
+
const _BaseExtensionGenerator = /*#__PURE__*/ _interop_require_wildcard(require("../extension/BaseExtensionGenerator"));
|
|
25
|
+
function _define_property(obj, key, value) {
|
|
26
|
+
if (key in obj) {
|
|
27
|
+
Object.defineProperty(obj, key, {
|
|
28
|
+
value: value,
|
|
29
|
+
enumerable: true,
|
|
30
|
+
configurable: true,
|
|
31
|
+
writable: true
|
|
32
|
+
});
|
|
33
|
+
} else {
|
|
34
|
+
obj[key] = value;
|
|
35
|
+
}
|
|
36
|
+
return obj;
|
|
37
|
+
}
|
|
38
|
+
function _getRequireWildcardCache(nodeInterop) {
|
|
39
|
+
if (typeof WeakMap !== "function") return null;
|
|
40
|
+
var cacheBabelInterop = new WeakMap();
|
|
41
|
+
var cacheNodeInterop = new WeakMap();
|
|
42
|
+
return (_getRequireWildcardCache = function(nodeInterop) {
|
|
43
|
+
return nodeInterop ? cacheNodeInterop : cacheBabelInterop;
|
|
44
|
+
})(nodeInterop);
|
|
45
|
+
}
|
|
46
|
+
function _interop_require_wildcard(obj, nodeInterop) {
|
|
47
|
+
if (!nodeInterop && obj && obj.__esModule) {
|
|
48
|
+
return obj;
|
|
49
|
+
}
|
|
50
|
+
if (obj === null || typeof obj !== "object" && typeof obj !== "function") {
|
|
51
|
+
return {
|
|
52
|
+
default: obj
|
|
53
|
+
};
|
|
54
|
+
}
|
|
55
|
+
var cache = _getRequireWildcardCache(nodeInterop);
|
|
56
|
+
if (cache && cache.has(obj)) {
|
|
57
|
+
return cache.get(obj);
|
|
58
|
+
}
|
|
59
|
+
var newObj = {
|
|
60
|
+
__proto__: null
|
|
61
|
+
};
|
|
62
|
+
var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor;
|
|
63
|
+
for(var key in obj){
|
|
64
|
+
if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) {
|
|
65
|
+
var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null;
|
|
66
|
+
if (desc && (desc.get || desc.set)) {
|
|
67
|
+
Object.defineProperty(newObj, key, desc);
|
|
68
|
+
} else {
|
|
69
|
+
newObj[key] = obj[key];
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
newObj.default = obj;
|
|
74
|
+
if (cache) {
|
|
75
|
+
cache.set(obj, newObj);
|
|
76
|
+
}
|
|
77
|
+
return newObj;
|
|
78
|
+
}
|
|
30
79
|
function composeWith(base, options) {
|
|
31
|
-
|
|
80
|
+
_utilities.compose(_path.basename(__dirname), base, options);
|
|
32
81
|
}
|
|
33
|
-
exports.composeWith = composeWith;
|
|
34
82
|
function defineOptions(generator) {
|
|
35
|
-
|
|
83
|
+
_BaseExtensionGenerator.defineOptions(generator, 'Command Set');
|
|
36
84
|
}
|
|
37
|
-
|
|
38
|
-
class CommandSetGenerator extends BaseExtension.BaseExtensionGenerator {
|
|
85
|
+
class CommandSetGenerator extends _BaseExtensionGenerator.BaseExtensionGenerator {
|
|
39
86
|
initializing() {
|
|
40
|
-
|
|
41
|
-
}
|
|
87
|
+
/* no-op */ }
|
|
42
88
|
async prompting() {
|
|
43
89
|
this.ensureCorrectFolder();
|
|
44
90
|
if (this._shouldExecute()) {
|
|
@@ -76,26 +122,24 @@ class CommandSetGenerator extends BaseExtension.BaseExtensionGenerator {
|
|
|
76
122
|
end() {
|
|
77
123
|
super.end();
|
|
78
124
|
}
|
|
79
|
-
constructor(args, options) {
|
|
80
|
-
super(args, options);
|
|
81
|
-
this.friendlyName = 'Command Set';
|
|
82
|
-
this.codeName = 'CommandSet';
|
|
83
|
-
this.allowedTemplates = [];
|
|
84
|
-
defineOptions(this);
|
|
85
|
-
}
|
|
86
125
|
includeClientSideInstances() {
|
|
87
126
|
return true;
|
|
88
127
|
}
|
|
89
128
|
_shouldExecute() {
|
|
90
|
-
return
|
|
91
|
-
|
|
92
|
-
|
|
129
|
+
return this.config.get('environment') === 'spo' && this.config.get('componentType') === 'extension' && this.config.get('extensionType') === 'ListViewCommandSet';
|
|
130
|
+
}
|
|
131
|
+
constructor(args, options){
|
|
132
|
+
super(args, options);
|
|
133
|
+
_define_property(this, "friendlyName", 'Command Set');
|
|
134
|
+
_define_property(this, "codeName", 'CommandSet');
|
|
135
|
+
_define_property(this, "allowedTemplates", []);
|
|
136
|
+
defineOptions(this);
|
|
93
137
|
}
|
|
94
138
|
}
|
|
95
|
-
exports.CommandSetGenerator = CommandSetGenerator;
|
|
96
139
|
// Yeoman expects exports of this type, which overrides the TS exports above
|
|
97
140
|
// Ensure that anything marked as export above is also listed here
|
|
98
141
|
module.exports = CommandSetGenerator;
|
|
99
142
|
module.exports.defineOptions = defineOptions;
|
|
100
143
|
module.exports.composeWith = composeWith;
|
|
101
|
-
|
|
144
|
+
|
|
145
|
+
//#sourceMappingUrl=./index.js.map
|
|
@@ -1,39 +1,90 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
-
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
-
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
-
}
|
|
8
|
-
Object.defineProperty(o, k2, desc);
|
|
9
|
-
}) : (function(o, m, k, k2) {
|
|
10
|
-
if (k2 === undefined) k2 = k;
|
|
11
|
-
o[k2] = m[k];
|
|
12
|
-
}));
|
|
13
|
-
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
-
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
-
}) : function(o, v) {
|
|
16
|
-
o["default"] = v;
|
|
2
|
+
Object.defineProperty(exports, "__esModule", {
|
|
3
|
+
value: true
|
|
17
4
|
});
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
const
|
|
36
|
-
const
|
|
5
|
+
function _export(target, all) {
|
|
6
|
+
for(var name in all)Object.defineProperty(target, name, {
|
|
7
|
+
enumerable: true,
|
|
8
|
+
get: all[name]
|
|
9
|
+
});
|
|
10
|
+
}
|
|
11
|
+
_export(exports, {
|
|
12
|
+
BaseComponentGenerator: function() {
|
|
13
|
+
return BaseComponentGenerator;
|
|
14
|
+
},
|
|
15
|
+
defineOptions: function() {
|
|
16
|
+
return defineOptions;
|
|
17
|
+
},
|
|
18
|
+
normalizeComponentNames: function() {
|
|
19
|
+
return normalizeComponentNames;
|
|
20
|
+
}
|
|
21
|
+
});
|
|
22
|
+
const _nodecorelibrary = require("@rushstack/node-core-library");
|
|
23
|
+
const _colors = /*#__PURE__*/ _interop_require_default(require("colors"));
|
|
24
|
+
const _lodash = /*#__PURE__*/ _interop_require_wildcard(require("lodash"));
|
|
25
|
+
const _path = /*#__PURE__*/ _interop_require_wildcard(require("path"));
|
|
26
|
+
const _BaseGenerator = require("../../common/BaseGenerator");
|
|
27
|
+
const _utilities = /*#__PURE__*/ _interop_require_wildcard(require("../../common/utilities"));
|
|
28
|
+
const _YeomanConfiguration = require("../../common/YeomanConfiguration");
|
|
29
|
+
function _define_property(obj, key, value) {
|
|
30
|
+
if (key in obj) {
|
|
31
|
+
Object.defineProperty(obj, key, {
|
|
32
|
+
value: value,
|
|
33
|
+
enumerable: true,
|
|
34
|
+
configurable: true,
|
|
35
|
+
writable: true
|
|
36
|
+
});
|
|
37
|
+
} else {
|
|
38
|
+
obj[key] = value;
|
|
39
|
+
}
|
|
40
|
+
return obj;
|
|
41
|
+
}
|
|
42
|
+
function _interop_require_default(obj) {
|
|
43
|
+
return obj && obj.__esModule ? obj : {
|
|
44
|
+
default: obj
|
|
45
|
+
};
|
|
46
|
+
}
|
|
47
|
+
function _getRequireWildcardCache(nodeInterop) {
|
|
48
|
+
if (typeof WeakMap !== "function") return null;
|
|
49
|
+
var cacheBabelInterop = new WeakMap();
|
|
50
|
+
var cacheNodeInterop = new WeakMap();
|
|
51
|
+
return (_getRequireWildcardCache = function(nodeInterop) {
|
|
52
|
+
return nodeInterop ? cacheNodeInterop : cacheBabelInterop;
|
|
53
|
+
})(nodeInterop);
|
|
54
|
+
}
|
|
55
|
+
function _interop_require_wildcard(obj, nodeInterop) {
|
|
56
|
+
if (!nodeInterop && obj && obj.__esModule) {
|
|
57
|
+
return obj;
|
|
58
|
+
}
|
|
59
|
+
if (obj === null || typeof obj !== "object" && typeof obj !== "function") {
|
|
60
|
+
return {
|
|
61
|
+
default: obj
|
|
62
|
+
};
|
|
63
|
+
}
|
|
64
|
+
var cache = _getRequireWildcardCache(nodeInterop);
|
|
65
|
+
if (cache && cache.has(obj)) {
|
|
66
|
+
return cache.get(obj);
|
|
67
|
+
}
|
|
68
|
+
var newObj = {
|
|
69
|
+
__proto__: null
|
|
70
|
+
};
|
|
71
|
+
var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor;
|
|
72
|
+
for(var key in obj){
|
|
73
|
+
if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) {
|
|
74
|
+
var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null;
|
|
75
|
+
if (desc && (desc.get || desc.set)) {
|
|
76
|
+
Object.defineProperty(newObj, key, desc);
|
|
77
|
+
} else {
|
|
78
|
+
newObj[key] = obj[key];
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
newObj.default = obj;
|
|
83
|
+
if (cache) {
|
|
84
|
+
cache.set(obj, newObj);
|
|
85
|
+
}
|
|
86
|
+
return newObj;
|
|
87
|
+
}
|
|
37
88
|
function defineOptions(generator, type) {
|
|
38
89
|
generator.option('component-description', {
|
|
39
90
|
description: `${type} description`,
|
|
@@ -53,61 +104,63 @@ function defineOptions(generator, type) {
|
|
|
53
104
|
type: Boolean
|
|
54
105
|
});
|
|
55
106
|
}
|
|
56
|
-
|
|
57
|
-
class BaseComponentGenerator extends BaseGenerator_1.BaseGenerator {
|
|
58
|
-
constructor() {
|
|
59
|
-
super(...arguments);
|
|
60
|
-
this._shouldLogESLintWarning = false;
|
|
61
|
-
}
|
|
107
|
+
class BaseComponentGenerator extends _BaseGenerator.BaseGenerator {
|
|
62
108
|
async prompting() {
|
|
63
109
|
await this._checkSolutionAsync();
|
|
64
|
-
const availableTemplates = [
|
|
110
|
+
const availableTemplates = [
|
|
111
|
+
{
|
|
112
|
+
name: 'No framework',
|
|
113
|
+
value: 'none'
|
|
114
|
+
}
|
|
115
|
+
];
|
|
65
116
|
if (this.allowedTemplates.indexOf('react') !== -1) {
|
|
66
|
-
availableTemplates.push({
|
|
117
|
+
availableTemplates.push({
|
|
118
|
+
name: 'React',
|
|
119
|
+
value: 'react'
|
|
120
|
+
});
|
|
67
121
|
}
|
|
68
122
|
if (this.allowedTemplates.indexOf('minimal') !== -1) {
|
|
69
|
-
availableTemplates.unshift({
|
|
123
|
+
availableTemplates.unshift({
|
|
124
|
+
name: 'Minimal',
|
|
125
|
+
value: 'minimal'
|
|
126
|
+
});
|
|
70
127
|
}
|
|
71
128
|
const answers = await this.prompt([
|
|
72
129
|
{
|
|
73
130
|
type: 'input',
|
|
74
131
|
name: 'componentName',
|
|
75
132
|
default: 'HelloWorld',
|
|
76
|
-
when: ()
|
|
133
|
+
when: ()=>!this.config.get('componentName'),
|
|
77
134
|
message: `What is your ${this.friendlyName} name?`,
|
|
78
|
-
validate: (input)
|
|
135
|
+
validate: (input)=>{
|
|
79
136
|
const normalizedNamesForValidation = normalizeComponentNames(input, this.codeName);
|
|
80
137
|
const outputFolderPathForValidation = this._getOutputFolder(normalizedNamesForValidation.componentNameCamelCase);
|
|
81
|
-
if (
|
|
138
|
+
if (_nodecorelibrary.FileSystem.exists(outputFolderPathForValidation)) {
|
|
82
139
|
// eslint-disable-next-line no-console
|
|
83
|
-
console.log(
|
|
84
|
-
` Please choose a different name for your component.`));
|
|
140
|
+
console.log(_colors.default.yellow(`\nThe folder "${outputFolderPathForValidation}" already exists.` + ` Please choose a different name for your component.`));
|
|
85
141
|
return false;
|
|
86
142
|
}
|
|
87
143
|
// disallow quotes, since this will mess with the JSON we put this string into
|
|
88
144
|
if (input.indexOf('"') !== -1) {
|
|
89
145
|
// eslint-disable-next-line no-console
|
|
90
|
-
console.log(
|
|
146
|
+
console.log(_colors.default.yellow(`\nDo not use double quotes in your title.`));
|
|
91
147
|
return false;
|
|
92
148
|
}
|
|
93
149
|
return true;
|
|
94
150
|
}
|
|
95
|
-
// required: true
|
|
96
151
|
},
|
|
97
152
|
{
|
|
98
153
|
type: 'list',
|
|
99
154
|
name: 'template',
|
|
100
|
-
when: ()
|
|
155
|
+
when: ()=>!this.config.get('framework') && !this.config.get('template') && availableTemplates.length !== 1,
|
|
101
156
|
message: 'Which template would you like to use?',
|
|
102
157
|
choices: availableTemplates
|
|
103
158
|
}
|
|
104
159
|
]);
|
|
105
160
|
const componentName = this.config.get('componentName') || answers.componentName;
|
|
106
|
-
this.context.template =
|
|
107
|
-
|
|
108
|
-
this.context.
|
|
109
|
-
this.config.get('componentDescription') || `${componentName} description`;
|
|
110
|
-
this.context.componentId = Utils.generateGuid();
|
|
161
|
+
this.context.template = this.config.get('framework') || this.config.get('template') || answers.template || 'none';
|
|
162
|
+
this.context.componentDescription = this.config.get('componentDescription') || `${componentName} description`;
|
|
163
|
+
this.context.componentId = _utilities.generateGuid();
|
|
111
164
|
const normalizedNames = normalizeComponentNames(componentName, this.codeName);
|
|
112
165
|
this.context.componentNameUnescaped = normalizedNames.componentNameUnescaped;
|
|
113
166
|
this.context.componentName = normalizedNames.componentName;
|
|
@@ -119,9 +172,8 @@ class BaseComponentGenerator extends BaseGenerator_1.BaseGenerator {
|
|
|
119
172
|
this.context.eslintProfile = this.context.template === 'react' ? 'react' : 'default';
|
|
120
173
|
// the folder where we will drop the information
|
|
121
174
|
const outputFolderPath = this._getOutputFolder(this.context.componentNameCamelCase);
|
|
122
|
-
if (
|
|
123
|
-
throw new Error(`The folder "${outputFolderPath}" already exists.` +
|
|
124
|
-
` Please choose a different name for your component.`);
|
|
175
|
+
if (_nodecorelibrary.FileSystem.exists(outputFolderPath)) {
|
|
176
|
+
throw new Error(`The folder "${outputFolderPath}" already exists.` + ` Please choose a different name for your component.`);
|
|
125
177
|
}
|
|
126
178
|
}
|
|
127
179
|
configuring(bundleEntry) {
|
|
@@ -135,8 +187,7 @@ class BaseComponentGenerator extends BaseGenerator_1.BaseGenerator {
|
|
|
135
187
|
try {
|
|
136
188
|
if (bundleEntry) {
|
|
137
189
|
this.configJson.addEntry(bundleEntry, this.context.componentClassNameKebabCase);
|
|
138
|
-
}
|
|
139
|
-
else {
|
|
190
|
+
} else {
|
|
140
191
|
this.configJson.addEntry({
|
|
141
192
|
components: [
|
|
142
193
|
{
|
|
@@ -146,10 +197,9 @@ class BaseComponentGenerator extends BaseGenerator_1.BaseGenerator {
|
|
|
146
197
|
]
|
|
147
198
|
}, this.context.componentClassNameKebabCase);
|
|
148
199
|
}
|
|
149
|
-
}
|
|
150
|
-
catch (error) {
|
|
200
|
+
} catch (error) {
|
|
151
201
|
// @todo move this error to occur during prompting
|
|
152
|
-
this.log(
|
|
202
|
+
this.log(_colors.default.red(`Cannot create two ${this.friendlyName}s with the same name.`));
|
|
153
203
|
throw error;
|
|
154
204
|
}
|
|
155
205
|
const localizedResourcePath = `lib/${this.folderName}/${this.context.componentNameCamelCase}/loc/{locale}.js`;
|
|
@@ -159,11 +209,11 @@ class BaseComponentGenerator extends BaseGenerator_1.BaseGenerator {
|
|
|
159
209
|
super.writing(false);
|
|
160
210
|
if (shouldWrite) {
|
|
161
211
|
const dest = this._getOutputFolder(this.context.componentNameCamelCase);
|
|
162
|
-
this.copyTemplate(
|
|
163
|
-
this.copyTemplate(
|
|
212
|
+
this.copyTemplate(_path.join(this.sourceRoot(), this.context.template), dest);
|
|
213
|
+
this.copyTemplate(_path.join(this.sourceRoot(), 'base'), dest);
|
|
164
214
|
}
|
|
165
215
|
// we need to write the eslint config anyway
|
|
166
|
-
this.copyTemplate(
|
|
216
|
+
this.copyTemplate(_path.join(`${__dirname}/templates`, 'eslint'), this.destinationRoot());
|
|
167
217
|
}
|
|
168
218
|
install() {
|
|
169
219
|
if (!this.tryInstall()) {
|
|
@@ -173,32 +223,35 @@ class BaseComponentGenerator extends BaseGenerator_1.BaseGenerator {
|
|
|
173
223
|
}
|
|
174
224
|
end() {
|
|
175
225
|
if (this._shouldLogESLintWarning) {
|
|
176
|
-
this.log(
|
|
226
|
+
this.log(_colors.default.yellow(`Found an existing ".eslintrc.js" file. Consider updating it if you are adding React component to non-React solution.`));
|
|
177
227
|
}
|
|
178
228
|
}
|
|
179
229
|
_getOutputFolder(componentNameCamelCase) {
|
|
180
|
-
return
|
|
230
|
+
return _path.join(this.destinationRoot(), 'src', this.folderName, componentNameCamelCase);
|
|
181
231
|
}
|
|
182
232
|
async _checkSolutionAsync() {
|
|
183
233
|
if (this.config.get('creatingSolution')) {
|
|
184
234
|
return;
|
|
185
235
|
}
|
|
186
|
-
const solutionName = await
|
|
187
|
-
this.log(`Add new ${this.friendlyName} to solution ${
|
|
236
|
+
const solutionName = await _utilities.checkSolutionFolder(this, _YeomanConfiguration.YeomanConfiguration.libraryName);
|
|
237
|
+
this.log(`Add new ${this.friendlyName} to solution ${_colors.default.cyan(solutionName)}.`);
|
|
238
|
+
}
|
|
239
|
+
constructor(...args){
|
|
240
|
+
super(...args);
|
|
241
|
+
_define_property(this, "_shouldLogESLintWarning", false);
|
|
188
242
|
}
|
|
189
243
|
}
|
|
190
|
-
exports.BaseComponentGenerator = BaseComponentGenerator;
|
|
191
244
|
function normalizeComponentNames(componentNameUnescaped, componentType) {
|
|
192
245
|
// title-case: Hello, World! => HelloWorld
|
|
193
|
-
const componentName =
|
|
246
|
+
const componentName = _utilities.titleCase(componentNameUnescaped);
|
|
194
247
|
// camel-case: HelloWorld => helloWorld
|
|
195
|
-
const componentNameCamelCase =
|
|
248
|
+
const componentNameCamelCase = _lodash.camelCase(componentName);
|
|
196
249
|
// class-name: HelloWorld => HelloWorldWebPart
|
|
197
250
|
const componentClassName = componentName + componentType;
|
|
198
251
|
// strings: HelloWorldWebPart => HelloWorldWebPartStrings
|
|
199
252
|
const componentStrings = componentClassName + 'Strings';
|
|
200
253
|
// kebab-case: HelloWorldWebPart => hello-world-web-part
|
|
201
|
-
let componentClassNameKebabCase =
|
|
254
|
+
let componentClassNameKebabCase = _lodash.kebabCase(componentClassName);
|
|
202
255
|
const MAX_BUNDLE_NAME_LENGTH = 64;
|
|
203
256
|
if (componentClassNameKebabCase.length > MAX_BUNDLE_NAME_LENGTH) {
|
|
204
257
|
componentClassNameKebabCase = componentClassNameKebabCase.substring(0, MAX_BUNDLE_NAME_LENGTH);
|
|
@@ -224,5 +277,5 @@ function normalizeComponentNames(componentNameUnescaped, componentType) {
|
|
|
224
277
|
componentAlias
|
|
225
278
|
};
|
|
226
279
|
}
|
|
227
|
-
|
|
228
|
-
//#
|
|
280
|
+
|
|
281
|
+
//#sourceMappingUrl=./BaseComponentGenerator.js.map
|