@pnp/cli-microsoft365-spfx-toolkit 1.13.0 → 1.14.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/.eslintcache +1 -1
- package/dist/autocomplete.js +1 -1
- package/dist/chili/index.js +1 -1
- package/dist/index.js +1 -1
- package/dist/m365/spfx/commands/project/DeployWorkflow.js +18 -22
- package/dist/m365/spfx/commands/project/base-project-command.js +22 -0
- package/dist/m365/spfx/commands/project/project-azuredevops-pipeline-add.js +53 -11
- package/dist/m365/spfx/commands/project/project-github-workflow-add.js +40 -12
- package/dist/utils/spfx.js +59 -0
- package/npm-shrinkwrap.json +12 -11
- package/package.json +1 -1
package/dist/autocomplete.js
CHANGED
package/dist/chili/index.js
CHANGED
package/dist/index.js
CHANGED
|
@@ -14,16 +14,16 @@ exports.workflow = {
|
|
|
14
14
|
"build-and-deploy": {
|
|
15
15
|
"runs-on": "ubuntu-latest",
|
|
16
16
|
env: {
|
|
17
|
-
NodeVersion: "
|
|
17
|
+
NodeVersion: ""
|
|
18
18
|
},
|
|
19
19
|
steps: [
|
|
20
20
|
{
|
|
21
21
|
name: "Checkout",
|
|
22
|
-
uses: "actions/checkout@
|
|
22
|
+
uses: "actions/checkout@v6"
|
|
23
23
|
},
|
|
24
24
|
{
|
|
25
25
|
name: "Use Node.js",
|
|
26
|
-
uses: "actions/setup-node@
|
|
26
|
+
uses: "actions/setup-node@v6",
|
|
27
27
|
with: {
|
|
28
28
|
"node-version": "${{ env.NodeVersion }}"
|
|
29
29
|
}
|
|
@@ -33,12 +33,12 @@ exports.workflow = {
|
|
|
33
33
|
run: "npm ci"
|
|
34
34
|
},
|
|
35
35
|
{
|
|
36
|
-
name: "
|
|
37
|
-
run: "
|
|
36
|
+
name: "Build & Package",
|
|
37
|
+
run: "npm run build"
|
|
38
38
|
},
|
|
39
39
|
{
|
|
40
40
|
name: "CLI for Microsoft 365 Login",
|
|
41
|
-
uses: "pnp/action-cli-login@
|
|
41
|
+
uses: "pnp/action-cli-login@v4",
|
|
42
42
|
with: {
|
|
43
43
|
"CERTIFICATE_ENCODED": "${{ secrets.CERTIFICATE_ENCODED }}",
|
|
44
44
|
"CERTIFICATE_PASSWORD": "${{ secrets.CERTIFICATE_PASSWORD }}",
|
|
@@ -48,9 +48,9 @@ exports.workflow = {
|
|
|
48
48
|
},
|
|
49
49
|
{
|
|
50
50
|
name: "CLI for Microsoft 365 Deploy App",
|
|
51
|
-
uses: "pnp/action-cli-deploy@
|
|
51
|
+
uses: "pnp/action-cli-deploy@v6",
|
|
52
52
|
with: {
|
|
53
|
-
"APP_FILE_PATH": "sharepoint/
|
|
53
|
+
"APP_FILE_PATH": "sharepoint/{{ sppkgPath }}",
|
|
54
54
|
"SKIP_FEATURE_DEPLOYMENT": false,
|
|
55
55
|
"OVERWRITE": false
|
|
56
56
|
}
|
|
@@ -108,13 +108,17 @@ exports.pipeline = {
|
|
|
108
108
|
name: "PackageName",
|
|
109
109
|
value: ""
|
|
110
110
|
},
|
|
111
|
+
{
|
|
112
|
+
name: "SppkgPath",
|
|
113
|
+
value: ""
|
|
114
|
+
},
|
|
111
115
|
{
|
|
112
116
|
name: "SiteAppCatalogUrl",
|
|
113
117
|
value: ""
|
|
114
118
|
},
|
|
115
119
|
{
|
|
116
120
|
name: "NodeVersion",
|
|
117
|
-
value: "
|
|
121
|
+
value: ""
|
|
118
122
|
}
|
|
119
123
|
],
|
|
120
124
|
stages: [
|
|
@@ -139,20 +143,12 @@ exports.pipeline = {
|
|
|
139
143
|
}
|
|
140
144
|
},
|
|
141
145
|
{
|
|
142
|
-
task: "
|
|
143
|
-
displayName: "
|
|
144
|
-
inputs: {
|
|
145
|
-
gulpFile: "./gulpfile.js",
|
|
146
|
-
targets: "bundle",
|
|
147
|
-
arguments: "--ship"
|
|
148
|
-
}
|
|
149
|
-
},
|
|
150
|
-
{
|
|
151
|
-
task: "Gulp@0",
|
|
152
|
-
displayName: "Gulp package",
|
|
146
|
+
task: "Npm@1",
|
|
147
|
+
displayName: "Build and package",
|
|
153
148
|
inputs: {
|
|
154
|
-
|
|
155
|
-
|
|
149
|
+
command: "custom",
|
|
150
|
+
verbose: false,
|
|
151
|
+
customCommand: "run build"
|
|
156
152
|
}
|
|
157
153
|
},
|
|
158
154
|
{
|
|
@@ -7,6 +7,7 @@ const formatting_1 = require("../../../../utils/formatting");
|
|
|
7
7
|
const fsUtil_1 = require("../../../../utils/fsUtil");
|
|
8
8
|
const AnonymousCommand_1 = require("../../../base/AnonymousCommand");
|
|
9
9
|
const project_model_1 = require("./project-model");
|
|
10
|
+
const Command_1 = require("../../../../Command");
|
|
10
11
|
class BaseProjectCommand extends AnonymousCommand_1.default {
|
|
11
12
|
constructor() {
|
|
12
13
|
super(...arguments);
|
|
@@ -236,6 +237,27 @@ class BaseProjectCommand extends AnonymousCommand_1.default {
|
|
|
236
237
|
catch (_b) { }
|
|
237
238
|
return undefined;
|
|
238
239
|
}
|
|
240
|
+
readAndParseJsonFile(filePath, project, keyPath) {
|
|
241
|
+
if (fs.existsSync(filePath)) {
|
|
242
|
+
try {
|
|
243
|
+
const source = formatting_1.formatting.removeSingleLineComments(fs.readFileSync(filePath, 'utf-8'));
|
|
244
|
+
const keys = keyPath.split('.');
|
|
245
|
+
let current = project;
|
|
246
|
+
for (let i = 0; i < keys.length - 1; i++) {
|
|
247
|
+
current = current[keys[i]];
|
|
248
|
+
}
|
|
249
|
+
const finalKey = keys[keys.length - 1];
|
|
250
|
+
current[finalKey] = JSON.parse(source);
|
|
251
|
+
if (typeof current[finalKey] === 'object' && current[finalKey] !== null) {
|
|
252
|
+
current[finalKey].source = source;
|
|
253
|
+
}
|
|
254
|
+
}
|
|
255
|
+
catch (error) {
|
|
256
|
+
throw new Command_1.CommandError(`The file ${filePath} is not a valid JSON file or is not utf-8 encoded. Error: ${error}`);
|
|
257
|
+
}
|
|
258
|
+
}
|
|
259
|
+
return project;
|
|
260
|
+
}
|
|
239
261
|
}
|
|
240
262
|
exports.BaseProjectCommand = BaseProjectCommand;
|
|
241
263
|
//# sourceMappingURL=base-project-command.js.map
|
|
@@ -23,6 +23,8 @@ const commands_1 = require("../../commands");
|
|
|
23
23
|
const base_project_command_1 = require("./base-project-command");
|
|
24
24
|
const validation_1 = require("../../../../utils/validation");
|
|
25
25
|
const fsUtil_1 = require("../../../../utils/fsUtil");
|
|
26
|
+
const SpfxCompatibilityMatrix_1 = require("../SpfxCompatibilityMatrix");
|
|
27
|
+
const spfx_1 = require("../../../../utils/spfx");
|
|
26
28
|
class SpfxProjectAzureDevOpsPipelineAddCommand extends base_project_command_1.BaseProjectCommand {
|
|
27
29
|
get name() {
|
|
28
30
|
return commands_1.default.PROJECT_AZUREDEVOPS_PIPELINE_ADD;
|
|
@@ -38,14 +40,12 @@ class SpfxProjectAzureDevOpsPipelineAddCommand extends base_project_command_1.Ba
|
|
|
38
40
|
__classPrivateFieldGet(this, _SpfxProjectAzureDevOpsPipelineAddCommand_instances, "m", _SpfxProjectAzureDevOpsPipelineAddCommand_initValidators).call(this);
|
|
39
41
|
}
|
|
40
42
|
commandAction(logger, args) {
|
|
43
|
+
var _a, _b;
|
|
41
44
|
return __awaiter(this, void 0, void 0, function* () {
|
|
42
45
|
this.projectRootPath = this.getProjectRoot(process.cwd());
|
|
43
46
|
if (this.projectRootPath === null) {
|
|
44
47
|
throw new Command_1.CommandError(`Couldn't find project root folder`, SpfxProjectAzureDevOpsPipelineAddCommand.ERROR_NO_PROJECT_ROOT_FOLDER);
|
|
45
48
|
}
|
|
46
|
-
const solutionPackageJsonFile = path.join(this.projectRootPath, 'package.json');
|
|
47
|
-
const packageJson = fs.readFileSync(solutionPackageJsonFile, 'utf-8');
|
|
48
|
-
const solutionName = JSON.parse(packageJson).name;
|
|
49
49
|
if (this.debug) {
|
|
50
50
|
logger.logToStderr(`Adding Azure DevOps pipeline in the current SPFx project`);
|
|
51
51
|
}
|
|
@@ -53,11 +53,15 @@ class SpfxProjectAzureDevOpsPipelineAddCommand extends base_project_command_1.Ba
|
|
|
53
53
|
delete require.cache[require.resolve('./DeployWorkflow')];
|
|
54
54
|
const deployWorkflow = require('./DeployWorkflow');
|
|
55
55
|
const pipeline = deployWorkflow.pipeline;
|
|
56
|
-
this.
|
|
57
|
-
this.
|
|
56
|
+
const project = { path: this.projectRootPath };
|
|
57
|
+
this.readAndParseJsonFile(path.join(this.projectRootPath, 'config', 'package-solution.json'), project, 'packageSolutionJson');
|
|
58
|
+
const sppkgPath = (_b = (_a = project.packageSolutionJson) === null || _a === void 0 ? void 0 : _a.paths) === null || _b === void 0 ? void 0 : _b.zippedPackage;
|
|
59
|
+
const pipelineToSave = structuredClone(pipeline);
|
|
60
|
+
this.updatePipeline(sppkgPath, pipelineToSave, args.options);
|
|
61
|
+
this.savePipeline(pipelineToSave);
|
|
58
62
|
}
|
|
59
63
|
catch (error) {
|
|
60
|
-
|
|
64
|
+
this.handleError(error);
|
|
61
65
|
}
|
|
62
66
|
});
|
|
63
67
|
}
|
|
@@ -69,7 +73,7 @@ class SpfxProjectAzureDevOpsPipelineAddCommand extends base_project_command_1.Ba
|
|
|
69
73
|
const pipelineFile = path.join(pipelinesPath, 'deploy-spfx-solution.yml');
|
|
70
74
|
fs.writeFileSync(path.resolve(pipelineFile), yaml.stringify(pipeline), 'utf-8');
|
|
71
75
|
}
|
|
72
|
-
updatePipeline(
|
|
76
|
+
updatePipeline(sppkgPath, pipeline, options) {
|
|
73
77
|
if (options.name) {
|
|
74
78
|
pipeline.name = options.name;
|
|
75
79
|
}
|
|
@@ -79,6 +83,16 @@ class SpfxProjectAzureDevOpsPipelineAddCommand extends base_project_command_1.Ba
|
|
|
79
83
|
if (options.branchName) {
|
|
80
84
|
pipeline.trigger.branches.include[0] = options.branchName;
|
|
81
85
|
}
|
|
86
|
+
const version = this.getProjectVersion();
|
|
87
|
+
if (!version) {
|
|
88
|
+
throw 'Unable to determine the version of the current SharePoint Framework project. Could not find the correct version based on the version property in the .yo-rc.json file.';
|
|
89
|
+
}
|
|
90
|
+
const versionRequirements = SpfxCompatibilityMatrix_1.versions[version];
|
|
91
|
+
if (!versionRequirements) {
|
|
92
|
+
throw `Could not find Node version for version '${version}' of SharePoint Framework.`;
|
|
93
|
+
}
|
|
94
|
+
const nodeVersion = spfx_1.spfx.getHighestNodeVersion(versionRequirements.node.range);
|
|
95
|
+
this.assignPipelineVariables(pipeline, 'NodeVersion', nodeVersion);
|
|
82
96
|
const script = this.getScriptAction(pipeline);
|
|
83
97
|
if (script.script) {
|
|
84
98
|
if (options.loginMethod === 'user') {
|
|
@@ -96,20 +110,48 @@ class SpfxProjectAzureDevOpsPipelineAddCommand extends base_project_command_1.Ba
|
|
|
96
110
|
}
|
|
97
111
|
if (options.scope === 'sitecollection') {
|
|
98
112
|
script.script = script.script.replace(`{{deploy}}`, `m365 spo app deploy --name '$(PackageName)' --appCatalogScope sitecollection --appCatalogUrl '$(SiteAppCatalogUrl)'`);
|
|
99
|
-
script.script = script.script.replace(`{{addApp}}`, `m365 spo app add --filePath '$(Build.SourcesDirectory)/sharepoint
|
|
113
|
+
script.script = script.script.replace(`{{addApp}}`, `m365 spo app add --filePath '$(Build.SourcesDirectory)/sharepoint/$(SppkgPath)' --appCatalogScope sitecollection --appCatalogUrl '$(SiteAppCatalogUrl)' --overwrite`);
|
|
100
114
|
this.assignPipelineVariables(pipeline, 'SiteAppCatalogUrl', options.siteUrl);
|
|
101
115
|
}
|
|
102
116
|
else {
|
|
103
117
|
script.script = script.script.replace(`{{deploy}}`, `m365 spo app deploy --name '$(PackageName)' --appCatalogScope 'tenant'`);
|
|
104
|
-
script.script = script.script.replace(`{{addApp}}`, `m365 spo app add --filePath '$(Build.SourcesDirectory)/sharepoint
|
|
118
|
+
script.script = script.script.replace(`{{addApp}}`, `m365 spo app add --filePath '$(Build.SourcesDirectory)/sharepoint/$(SppkgPath)' --overwrite`);
|
|
105
119
|
pipeline.variables = pipeline.variables.filter(v => v.name !== 'SiteAppCatalogUrl');
|
|
106
120
|
}
|
|
107
|
-
if (
|
|
108
|
-
this.assignPipelineVariables(pipeline, '
|
|
121
|
+
if (sppkgPath) {
|
|
122
|
+
this.assignPipelineVariables(pipeline, 'SppkgPath', sppkgPath);
|
|
123
|
+
this.assignPipelineVariables(pipeline, 'PackageName', path.basename(sppkgPath));
|
|
109
124
|
}
|
|
110
125
|
if (options.skipFeatureDeployment) {
|
|
111
126
|
script.script = script.script.replace(`m365 spo app deploy `, `m365 spo app deploy --skipFeatureDeployment `);
|
|
112
127
|
}
|
|
128
|
+
if (versionRequirements.heft === undefined) {
|
|
129
|
+
let steps = this.getPipelineSteps(pipeline);
|
|
130
|
+
const npmBuildScript = steps.find(step => step.task && step.displayName === 'Build and package');
|
|
131
|
+
if (npmBuildScript) {
|
|
132
|
+
pipeline.stages[0].jobs[0].steps = steps.filter(step => step !== npmBuildScript);
|
|
133
|
+
}
|
|
134
|
+
const gulpBundleStep = {
|
|
135
|
+
task: 'Gulp@0',
|
|
136
|
+
displayName: 'Gulp bundle',
|
|
137
|
+
inputs: {
|
|
138
|
+
gulpFile: './gulpfile.js',
|
|
139
|
+
targets: 'bundle',
|
|
140
|
+
arguments: '--ship'
|
|
141
|
+
}
|
|
142
|
+
};
|
|
143
|
+
const gulpPackageStep = {
|
|
144
|
+
task: 'Gulp@0',
|
|
145
|
+
displayName: 'Gulp package',
|
|
146
|
+
inputs: {
|
|
147
|
+
targets: 'package-solution',
|
|
148
|
+
arguments: '--ship'
|
|
149
|
+
}
|
|
150
|
+
};
|
|
151
|
+
steps = this.getPipelineSteps(pipeline);
|
|
152
|
+
const installCLIStepIndex = steps.findIndex(step => step.task === 'Npm@1' && step.displayName === 'Install CLI for Microsoft 365');
|
|
153
|
+
pipeline.stages[0].jobs[0].steps.splice(installCLIStepIndex, 0, gulpBundleStep, gulpPackageStep);
|
|
154
|
+
}
|
|
113
155
|
}
|
|
114
156
|
}
|
|
115
157
|
assignPipelineVariables(pipeline, variableName, newVariableValue) {
|
|
@@ -23,6 +23,8 @@ const fsUtil_1 = require("../../../../utils/fsUtil");
|
|
|
23
23
|
const validation_1 = require("../../../../utils/validation");
|
|
24
24
|
const commands_1 = require("../../commands");
|
|
25
25
|
const base_project_command_1 = require("./base-project-command");
|
|
26
|
+
const SpfxCompatibilityMatrix_1 = require("../SpfxCompatibilityMatrix");
|
|
27
|
+
const spfx_1 = require("../../../../utils/spfx");
|
|
26
28
|
class SpfxProjectGithubWorkflowAddCommand extends base_project_command_1.BaseProjectCommand {
|
|
27
29
|
get name() {
|
|
28
30
|
return commands_1.default.PROJECT_GITHUB_WORKFLOW_ADD;
|
|
@@ -38,26 +40,30 @@ class SpfxProjectGithubWorkflowAddCommand extends base_project_command_1.BasePro
|
|
|
38
40
|
__classPrivateFieldGet(this, _SpfxProjectGithubWorkflowAddCommand_instances, "m", _SpfxProjectGithubWorkflowAddCommand_initValidators).call(this);
|
|
39
41
|
}
|
|
40
42
|
commandAction(logger, args) {
|
|
43
|
+
var _a, _b;
|
|
41
44
|
return __awaiter(this, void 0, void 0, function* () {
|
|
42
45
|
this.projectRootPath = this.getProjectRoot(process.cwd());
|
|
43
46
|
if (this.projectRootPath === null) {
|
|
44
47
|
throw new Command_1.CommandError(`Couldn't find project root folder`, SpfxProjectGithubWorkflowAddCommand.ERROR_NO_PROJECT_ROOT_FOLDER);
|
|
45
48
|
}
|
|
46
|
-
const solutionPackageJsonFile = path.join(this.projectRootPath, 'package.json');
|
|
47
|
-
const packageJson = fs.readFileSync(solutionPackageJsonFile, 'utf-8');
|
|
48
|
-
const solutionName = JSON.parse(packageJson).name;
|
|
49
|
-
if (this.debug) {
|
|
50
|
-
logger.logToStderr(`Adding GitHub workflow in the current SPFx project`);
|
|
51
|
-
}
|
|
52
49
|
try {
|
|
50
|
+
const project = { path: this.projectRootPath };
|
|
51
|
+
this.readAndParseJsonFile(path.join(this.projectRootPath, 'package.json'), project, 'packageJson');
|
|
52
|
+
this.readAndParseJsonFile(path.join(this.projectRootPath, 'config', 'package-solution.json'), project, 'packageSolutionJson');
|
|
53
|
+
const solutionName = project.packageJson.name;
|
|
54
|
+
const sppkgPath = (_b = (_a = project.packageSolutionJson) === null || _a === void 0 ? void 0 : _a.paths) === null || _b === void 0 ? void 0 : _b.zippedPackage;
|
|
55
|
+
if (this.debug) {
|
|
56
|
+
logger.logToStderr(`Adding GitHub workflow in the current SPFx project`);
|
|
57
|
+
}
|
|
53
58
|
delete require.cache[require.resolve('./DeployWorkflow')];
|
|
54
59
|
const deployWorkflow = require('./DeployWorkflow');
|
|
55
60
|
const workflow = deployWorkflow.workflow;
|
|
56
|
-
|
|
57
|
-
this.
|
|
61
|
+
const workflowToSave = structuredClone(workflow);
|
|
62
|
+
this.updateWorkflow(solutionName, sppkgPath, workflowToSave, args.options);
|
|
63
|
+
this.saveWorkflow(workflowToSave);
|
|
58
64
|
}
|
|
59
65
|
catch (error) {
|
|
60
|
-
|
|
66
|
+
this.handleError(error);
|
|
61
67
|
}
|
|
62
68
|
});
|
|
63
69
|
}
|
|
@@ -69,11 +75,21 @@ class SpfxProjectGithubWorkflowAddCommand extends base_project_command_1.BasePro
|
|
|
69
75
|
const workflowFile = path.join(workflowPath, 'deploy-spfx-solution.yml');
|
|
70
76
|
fs.writeFileSync(path.resolve(workflowFile), yaml.stringify(workflow), 'utf-8');
|
|
71
77
|
}
|
|
72
|
-
updateWorkflow(solutionName, workflow, options) {
|
|
78
|
+
updateWorkflow(solutionName, sppkgPath, workflow, options) {
|
|
73
79
|
workflow.name = options.name ? options.name : workflow.name.replace('{{ name }}', solutionName);
|
|
74
80
|
if (options.branchName) {
|
|
75
81
|
workflow.on.push.branches[0] = options.branchName;
|
|
76
82
|
}
|
|
83
|
+
const version = this.getProjectVersion();
|
|
84
|
+
if (!version) {
|
|
85
|
+
throw 'Unable to determine the version of the current SharePoint Framework project. Could not find the correct version based on the version property in the .yo-rc.json file.';
|
|
86
|
+
}
|
|
87
|
+
const versionRequirements = SpfxCompatibilityMatrix_1.versions[version];
|
|
88
|
+
if (!versionRequirements) {
|
|
89
|
+
throw `Could not find Node version for version '${version}' of SharePoint Framework.`;
|
|
90
|
+
}
|
|
91
|
+
const nodeVersion = spfx_1.spfx.getHighestNodeVersion(versionRequirements.node.range);
|
|
92
|
+
this.assignNodeVersion(workflow, nodeVersion);
|
|
77
93
|
if (options.manuallyTrigger) {
|
|
78
94
|
// eslint-disable-next-line camelcase
|
|
79
95
|
workflow.on.workflow_dispatch = null;
|
|
@@ -96,11 +112,23 @@ class SpfxProjectGithubWorkflowAddCommand extends base_project_command_1.BasePro
|
|
|
96
112
|
deployAction.with.SCOPE = 'sitecollection';
|
|
97
113
|
deployAction.with.SITE_COLLECTION_URL = options.siteUrl;
|
|
98
114
|
}
|
|
99
|
-
if (
|
|
115
|
+
if (sppkgPath) {
|
|
100
116
|
const deployAction = this.getDeployAction(workflow);
|
|
101
|
-
deployAction.with.APP_FILE_PATH = deployAction.with.APP_FILE_PATH.replace('{{
|
|
117
|
+
deployAction.with.APP_FILE_PATH = deployAction.with.APP_FILE_PATH.replace('{{ sppkgPath }}', sppkgPath);
|
|
118
|
+
}
|
|
119
|
+
if (versionRequirements.heft === undefined) {
|
|
120
|
+
const buildAndPackageStep = this.getBuildAndPackageStep(workflow);
|
|
121
|
+
buildAndPackageStep.run = `gulp bundle --ship\ngulp package-solution --ship\n`;
|
|
122
|
+
buildAndPackageStep.name = 'Bundle & Package';
|
|
102
123
|
}
|
|
103
124
|
}
|
|
125
|
+
assignNodeVersion(workflow, nodeVersion) {
|
|
126
|
+
workflow.jobs['build-and-deploy'].env.NodeVersion = nodeVersion;
|
|
127
|
+
}
|
|
128
|
+
getBuildAndPackageStep(workflow) {
|
|
129
|
+
const steps = this.getWorkFlowSteps(workflow);
|
|
130
|
+
return steps.find(step => step.run && step.name === 'Build & Package');
|
|
131
|
+
}
|
|
104
132
|
getLoginAction(workflow) {
|
|
105
133
|
const steps = this.getWorkFlowSteps(workflow);
|
|
106
134
|
return steps.find(step => step.uses && step.uses.indexOf('action-cli-login') >= 0);
|
package/dist/utils/spfx.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.spfx = void 0;
|
|
4
|
+
const semver_1 = require("semver");
|
|
4
5
|
exports.spfx = {
|
|
5
6
|
isReactProject(project) {
|
|
6
7
|
var _a, _b;
|
|
@@ -16,6 +17,64 @@ exports.spfx = {
|
|
|
16
17
|
typeof project.yoRcJson['@microsoft/generator-sharepoint'] !== 'undefined' &&
|
|
17
18
|
project.yoRcJson["@microsoft/generator-sharepoint"].framework === 'knockout') ||
|
|
18
19
|
typeof ((_b = (_a = project.packageJson) === null || _a === void 0 ? void 0 : _a.dependencies) === null || _b === void 0 ? void 0 : _b['knockout']) !== 'undefined';
|
|
20
|
+
},
|
|
21
|
+
getHighestNodeVersion(versionRange) {
|
|
22
|
+
if (!versionRange) {
|
|
23
|
+
throw new Error('Node version range was not provided.');
|
|
24
|
+
}
|
|
25
|
+
const ranges = versionRange
|
|
26
|
+
.split('||')
|
|
27
|
+
.map(range => range.trim())
|
|
28
|
+
.filter(range => range.length > 0);
|
|
29
|
+
let highestMajor = null;
|
|
30
|
+
let exactVersion = null;
|
|
31
|
+
const simpleVersionPattern = /^\d+(\.\d+(\.\d+)?)?$/;
|
|
32
|
+
if (ranges.every(r => simpleVersionPattern.test(r))) {
|
|
33
|
+
const highest = ranges.reduce((best, curr) => (0, semver_1.gt)((0, semver_1.coerce)(curr), (0, semver_1.coerce)(best)) ? curr : best);
|
|
34
|
+
const parts = highest.split('.');
|
|
35
|
+
if (parts.length >= 3) {
|
|
36
|
+
return highest;
|
|
37
|
+
}
|
|
38
|
+
if (parts.length === 2) {
|
|
39
|
+
return `${highest}.x`;
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
for (const rangeString of ranges) {
|
|
43
|
+
const normalized = (0, semver_1.validRange)(rangeString);
|
|
44
|
+
if (!normalized) {
|
|
45
|
+
continue;
|
|
46
|
+
}
|
|
47
|
+
const rangeObj = new semver_1.Range(normalized);
|
|
48
|
+
let maxMajor = 0;
|
|
49
|
+
// Analyze the range to find the maximum major version
|
|
50
|
+
for (const comparatorSet of rangeObj.set) {
|
|
51
|
+
for (const comparator of comparatorSet) {
|
|
52
|
+
if (comparator.operator === '<') {
|
|
53
|
+
// Exclusive upper bound: <17.0.0 means max major is 16
|
|
54
|
+
maxMajor = Math.max(maxMajor, comparator.semver.major - 1);
|
|
55
|
+
}
|
|
56
|
+
else if (comparator.operator === '<=') {
|
|
57
|
+
// Inclusive upper bound: <=17.0.0 means we can use exactly that version
|
|
58
|
+
maxMajor = Math.max(maxMajor, comparator.semver.major);
|
|
59
|
+
// Store the exact version for <= comparator
|
|
60
|
+
if (highestMajor === null || comparator.semver.major > highestMajor) {
|
|
61
|
+
exactVersion = comparator.semver.version;
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
else if (comparator.operator === '>=' || comparator.operator === '>') {
|
|
65
|
+
// For lower bounds use the major version
|
|
66
|
+
maxMajor = Math.max(maxMajor, comparator.semver.major);
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
// Track the highest major version across all ranges
|
|
71
|
+
highestMajor = Math.max(highestMajor !== null && highestMajor !== void 0 ? highestMajor : 0, maxMajor);
|
|
72
|
+
}
|
|
73
|
+
if (highestMajor === null) {
|
|
74
|
+
throw new Error(`Unable to resolve the highest Node version for range '${versionRange}'.`);
|
|
75
|
+
}
|
|
76
|
+
// Return exact version if we have a <= comparator, otherwise use .x
|
|
77
|
+
return exactVersion || `${highestMajor}.x`;
|
|
19
78
|
}
|
|
20
79
|
};
|
|
21
80
|
//# sourceMappingURL=spfx.js.map
|
package/npm-shrinkwrap.json
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@pnp/cli-microsoft365-spfx-toolkit",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.14.0",
|
|
4
4
|
"lockfileVersion": 3,
|
|
5
5
|
"requires": true,
|
|
6
6
|
"packages": {
|
|
7
7
|
"": {
|
|
8
8
|
"name": "@pnp/cli-microsoft365-spfx-toolkit",
|
|
9
|
-
"version": "1.
|
|
9
|
+
"version": "1.14.0",
|
|
10
10
|
"license": "MIT",
|
|
11
11
|
"dependencies": {
|
|
12
12
|
"@azure/msal-common": "^13.2.1",
|
|
@@ -427,7 +427,6 @@
|
|
|
427
427
|
"resolved": "https://registry.npmjs.org/@opentelemetry/api/-/api-1.9.0.tgz",
|
|
428
428
|
"integrity": "sha512-3giAOQvZiH5F9bMlMiv8+GSPMeqg0dbaeo58/0SlA9sxSqZhnUtxzX9/2FzyhS9sWQf5S0GJE0AKBrFqjpeYcg==",
|
|
429
429
|
"license": "Apache-2.0",
|
|
430
|
-
"peer": true,
|
|
431
430
|
"engines": {
|
|
432
431
|
"node": ">=8.0.0"
|
|
433
432
|
}
|
|
@@ -930,7 +929,6 @@
|
|
|
930
929
|
"resolved": "https://registry.npmjs.org/@typescript-eslint/parser/-/parser-5.62.0.tgz",
|
|
931
930
|
"integrity": "sha512-VlJEV0fOQ7BExOsHYAGrgbEiZoi8D+Bl2+f6V2RrXerRSylnp+ZBHmPvaIa8cz0Ajx7WO7Z5RqfgYg7ED1nRhA==",
|
|
932
931
|
"dev": true,
|
|
933
|
-
"peer": true,
|
|
934
932
|
"dependencies": {
|
|
935
933
|
"@typescript-eslint/scope-manager": "5.62.0",
|
|
936
934
|
"@typescript-eslint/types": "5.62.0",
|
|
@@ -1139,7 +1137,6 @@
|
|
|
1139
1137
|
"resolved": "https://registry.npmjs.org/acorn/-/acorn-8.15.0.tgz",
|
|
1140
1138
|
"integrity": "sha512-NZyJarBfL7nWwIq+FDL6Zp/yHEhePMNnnJ0y3qfieCrmNvYct8uvtiV41UvlSe6apAfk0fY1FbWx+NwfmpvtTg==",
|
|
1141
1139
|
"license": "MIT",
|
|
1142
|
-
"peer": true,
|
|
1143
1140
|
"bin": {
|
|
1144
1141
|
"acorn": "bin/acorn"
|
|
1145
1142
|
},
|
|
@@ -1772,6 +1769,7 @@
|
|
|
1772
1769
|
"integrity": "sha512-zhaCDicdLuWN5UbN5IMnFqNMhNfo919sH85y2/ea+5Yg9TsTkeZxpL+JLbp6cgYFS4sRLp3YV4S6yDuqVWHYOw==",
|
|
1773
1770
|
"dev": true,
|
|
1774
1771
|
"license": "MIT",
|
|
1772
|
+
"peer": true,
|
|
1775
1773
|
"engines": {
|
|
1776
1774
|
"node": ">=6"
|
|
1777
1775
|
},
|
|
@@ -1785,6 +1783,7 @@
|
|
|
1785
1783
|
"integrity": "sha512-SW9lzGTLvWTP1AY8xeAMZimqDrIaSdLQUcVr9DMef51niJ022Ri87SwRRKYm4A6iHfkPaiVUu/Duw2Wc4J7kKg==",
|
|
1786
1784
|
"dev": true,
|
|
1787
1785
|
"license": "MIT",
|
|
1786
|
+
"peer": true,
|
|
1788
1787
|
"dependencies": {
|
|
1789
1788
|
"semver": "^7.0.0"
|
|
1790
1789
|
}
|
|
@@ -2397,7 +2396,6 @@
|
|
|
2397
2396
|
"resolved": "https://registry.npmjs.org/diagnostic-channel/-/diagnostic-channel-1.1.1.tgz",
|
|
2398
2397
|
"integrity": "sha512-r2HV5qFkUICyoaKlBEpLKHjxMXATUf/l+h8UZPGBHGLy4DDiY2sOLcIctax4eRnTw5wH2jTMExLntGPJ8eOJxw==",
|
|
2399
2398
|
"license": "MIT",
|
|
2400
|
-
"peer": true,
|
|
2401
2399
|
"dependencies": {
|
|
2402
2400
|
"semver": "^7.5.3"
|
|
2403
2401
|
}
|
|
@@ -2450,6 +2448,7 @@
|
|
|
2450
2448
|
"version": "4.0.6",
|
|
2451
2449
|
"resolved": "https://registry.npmjs.org/dom7/-/dom7-4.0.6.tgz",
|
|
2452
2450
|
"integrity": "sha512-emjdpPLhpNubapLFdjNL9tP06Sr+GZkrIHEXLWvOGsytACUrkbeIdjO5g77m00BrHTznnlcNqgmn7pCN192TBA==",
|
|
2451
|
+
"peer": true,
|
|
2453
2452
|
"dependencies": {
|
|
2454
2453
|
"ssr-window": "^4.0.0"
|
|
2455
2454
|
}
|
|
@@ -2705,7 +2704,6 @@
|
|
|
2705
2704
|
"deprecated": "This version is no longer supported. Please see https://eslint.org/version-support for other options.",
|
|
2706
2705
|
"dev": true,
|
|
2707
2706
|
"license": "MIT",
|
|
2708
|
-
"peer": true,
|
|
2709
2707
|
"dependencies": {
|
|
2710
2708
|
"@eslint-community/eslint-utils": "^4.2.0",
|
|
2711
2709
|
"@eslint-community/regexpp": "^4.6.1",
|
|
@@ -2762,6 +2760,7 @@
|
|
|
2762
2760
|
"integrity": "sha512-3z3vFexKIEnjHE3zCMRo6fn/e44U7T1khUjg+Hp0ZQMCigh28rALD0nPFBcGZuiLC5rLZa2ubQHDRln09JfU2Q==",
|
|
2763
2761
|
"dev": true,
|
|
2764
2762
|
"license": "MIT",
|
|
2763
|
+
"peer": true,
|
|
2765
2764
|
"dependencies": {
|
|
2766
2765
|
"semver": "^7.5.4"
|
|
2767
2766
|
},
|
|
@@ -2882,6 +2881,7 @@
|
|
|
2882
2881
|
"https://opencollective.com/eslint"
|
|
2883
2882
|
],
|
|
2884
2883
|
"license": "MIT",
|
|
2884
|
+
"peer": true,
|
|
2885
2885
|
"dependencies": {
|
|
2886
2886
|
"@eslint-community/eslint-utils": "^4.1.2",
|
|
2887
2887
|
"@eslint-community/regexpp": "^4.11.0",
|
|
@@ -2926,7 +2926,6 @@
|
|
|
2926
2926
|
"integrity": "sha512-whOE1HFo/qJDyX4SnXzP4N6zOWn79WhnCUY/iDR0mPfQZO8wcYE4JClzI2oZrhBnnMUCBCHZhO6VQyoBU95mZA==",
|
|
2927
2927
|
"dev": true,
|
|
2928
2928
|
"license": "MIT",
|
|
2929
|
-
"peer": true,
|
|
2930
2929
|
"dependencies": {
|
|
2931
2930
|
"@rtsao/scc": "^1.1.0",
|
|
2932
2931
|
"array-includes": "^3.1.9",
|
|
@@ -3097,7 +3096,6 @@
|
|
|
3097
3096
|
"integrity": "sha512-57Zzfw8G6+Gq7axm2Pdo3gW/Rx3h9Yywgn61uE/3elTCOePEHVrn2i5CdfBwA1BLK0Q0WqctICIUSqXZW/VprQ==",
|
|
3098
3097
|
"dev": true,
|
|
3099
3098
|
"license": "ISC",
|
|
3100
|
-
"peer": true,
|
|
3101
3099
|
"engines": {
|
|
3102
3100
|
"node": "^12.22.0 || ^14.17.0 || >=16.0.0"
|
|
3103
3101
|
},
|
|
@@ -3710,6 +3708,7 @@
|
|
|
3710
3708
|
"integrity": "sha512-auHyJ4AgMz7vgS8Hp3N6HXSmlMdUyhSUrfBF16w153rxtLIEOE+HGqaBppczZvnHLqQJfiHotCYpNhl0lUROFQ==",
|
|
3711
3709
|
"dev": true,
|
|
3712
3710
|
"license": "MIT",
|
|
3711
|
+
"peer": true,
|
|
3713
3712
|
"dependencies": {
|
|
3714
3713
|
"resolve-pkg-maps": "^1.0.0"
|
|
3715
3714
|
},
|
|
@@ -4271,6 +4270,7 @@
|
|
|
4271
4270
|
"integrity": "sha512-BSLE3HnV2syZ0FK0iMA/yUGplUeMmNz4AW5fnTunbCIqZi4vG3WjJT9FHMy5D69xmAYBHXQhJdALdpwVxV501A==",
|
|
4272
4271
|
"dev": true,
|
|
4273
4272
|
"license": "MIT",
|
|
4273
|
+
"peer": true,
|
|
4274
4274
|
"dependencies": {
|
|
4275
4275
|
"builtin-modules": "^3.3.0"
|
|
4276
4276
|
},
|
|
@@ -5922,6 +5922,7 @@
|
|
|
5922
5922
|
"integrity": "sha512-seS2Tj26TBVOC2NIc2rOe2y2ZO7efxITtLZcGSOnHHNOQ7CkiUBfw0Iw2ck6xkIhPwLhKNLS8BO+hEpngQlqzw==",
|
|
5923
5923
|
"dev": true,
|
|
5924
5924
|
"license": "MIT",
|
|
5925
|
+
"peer": true,
|
|
5925
5926
|
"funding": {
|
|
5926
5927
|
"url": "https://github.com/privatenumber/resolve-pkg-maps?sponsor=1"
|
|
5927
5928
|
}
|
|
@@ -6376,7 +6377,8 @@
|
|
|
6376
6377
|
"node_modules/ssr-window": {
|
|
6377
6378
|
"version": "4.0.2",
|
|
6378
6379
|
"resolved": "https://registry.npmjs.org/ssr-window/-/ssr-window-4.0.2.tgz",
|
|
6379
|
-
"integrity": "sha512-ISv/Ch+ig7SOtw7G2+qkwfVASzazUnvlDTwypdLoPoySv+6MqlOV10VwPSE6EWkGjhW50lUmghPmpYZXMu/+AQ=="
|
|
6380
|
+
"integrity": "sha512-ISv/Ch+ig7SOtw7G2+qkwfVASzazUnvlDTwypdLoPoySv+6MqlOV10VwPSE6EWkGjhW50lUmghPmpYZXMu/+AQ==",
|
|
6381
|
+
"peer": true
|
|
6380
6382
|
},
|
|
6381
6383
|
"node_modules/stack-chain": {
|
|
6382
6384
|
"version": "1.3.7",
|
|
@@ -6804,7 +6806,6 @@
|
|
|
6804
6806
|
"version": "4.9.5",
|
|
6805
6807
|
"resolved": "https://registry.npmjs.org/typescript/-/typescript-4.9.5.tgz",
|
|
6806
6808
|
"integrity": "sha512-1FXk9E2Hm+QzZQ7z+McJiHL4NW1F2EzMu9Nq9i3zAaGqibafqYwCVU6WyWAuyQRRzOlxou8xZSyXLEN8oKj24g==",
|
|
6807
|
-
"peer": true,
|
|
6808
6809
|
"bin": {
|
|
6809
6810
|
"tsc": "bin/tsc",
|
|
6810
6811
|
"tsserver": "bin/tsserver"
|