Skip to content

Commit 24df8dd

Browse files
Added support for upgrading [email protected] projects
1 parent 65b2c66 commit 24df8dd

158 files changed

Lines changed: 3204 additions & 10 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

docs/manual/docs/cmd/spfx/project/project-upgrade.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,11 +26,11 @@ Option|Description
2626

2727
## Remarks
2828

29-
The `spfx project upgrade` command helps you upgrade your SharePoint Framework project to the specified version. If no version is specified, the command will upgrade to the latest version of the SharePoint Framework it supports (v1.9.1).
29+
The `spfx project upgrade` command helps you upgrade your SharePoint Framework project to the specified version. If no version is specified, the command will upgrade to the latest version of the SharePoint Framework it supports (v1.10.0).
3030

3131
This command doesn't change your project files. Instead, it gives you a report with all steps necessary to upgrade your project to the specified version of the SharePoint Framework. Changing project files is error-prone, especially when it comes to updating your solution's code. This is why at this moment, this command produces a report that you can use yourself to perform the necessary updates and verify that everything is working as expected.
3232

33-
Using this command you can upgrade SharePoint Framework projects built using versions: 1.0.0, 1.0.1, 1.0.2, 1.1.0, 1.1.1, 1.1.3, 1.2.0, 1.3.0, 1.3.1, 1.3.2, 1.3.4, 1.4.0, 1.4.1, 1.5.0, 1.5.1, 1.6.0, 1.7.0, 1.7.1, 1.8.0, 1.8.1 and 1.8.2.
33+
Using this command you can upgrade SharePoint Framework projects built using versions: 1.0.0, 1.0.1, 1.0.2, 1.1.0, 1.1.1, 1.1.3, 1.2.0, 1.3.0, 1.3.1, 1.3.2, 1.3.4, 1.4.0, 1.4.1, 1.5.0, 1.5.1, 1.6.0, 1.7.0, 1.7.1, 1.8.0, 1.8.1, 1.8.2 and 1.9.1.
3434

3535
## Examples
3636

src/o365/spfx/commands/project/project-upgrade.spec.ts

Lines changed: 66 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1456,7 +1456,7 @@ describe(commands.PROJECT_UPGRADE, () => {
14561456
cmdInstance.action = command.action();
14571457
cmdInstance.action({ options: { toVersion: '1.8.0', output: 'json' } }, (err?: any) => {
14581458
const findings: Finding[] = log[0];
1459-
assert.equal(findings.length, 17);
1459+
assert.equal(findings.length, 18);
14601460
});
14611461
});
14621462

@@ -1466,7 +1466,7 @@ describe(commands.PROJECT_UPGRADE, () => {
14661466
cmdInstance.action = command.action();
14671467
cmdInstance.action({ options: { toVersion: '1.8.0', output: 'json' } }, (err?: any) => {
14681468
const findings: Finding[] = log[0];
1469-
assert.equal(findings.length, 17);
1469+
assert.equal(findings.length, 18);
14701470
});
14711471
});
14721472

@@ -1476,7 +1476,7 @@ describe(commands.PROJECT_UPGRADE, () => {
14761476
cmdInstance.action = command.action();
14771477
cmdInstance.action({ options: { toVersion: '1.8.0', output: 'json' } }, (err?: any) => {
14781478
const findings: Finding[] = log[0];
1479-
assert.equal(findings.length, 19);
1479+
assert.equal(findings.length, 20);
14801480
});
14811481
});
14821482
//#endregion
@@ -1667,14 +1667,76 @@ describe(commands.PROJECT_UPGRADE, () => {
16671667
});
16681668
//#endregion
16691669

1670+
//#region 1.9.1
1671+
it('e2e: shows correct number of findings for upgrading application customizer 1.9.1 project to 1.10.0', () => {
1672+
sinon.stub(command as any, 'getProjectRoot').callsFake(_ => path.join(process.cwd(), 'src/o365/spfx/commands/project/project-upgrade/test-projects/spfx-191-applicationcustomizer'));
1673+
1674+
cmdInstance.action = command.action();
1675+
cmdInstance.action({ options: { toVersion: '1.10.0', output: 'json' } }, (err?: any) => {
1676+
const findings: Finding[] = log[0];
1677+
assert.equal(findings.length, 12);
1678+
});
1679+
});
1680+
1681+
it('e2e: shows correct number of findings for upgrading field customizer react 1.9.1 project to 1.10.0', () => {
1682+
sinon.stub(command as any, 'getProjectRoot').callsFake(_ => path.join(process.cwd(), 'src/o365/spfx/commands/project/project-upgrade/test-projects/spfx-191-fieldcustomizer-react'));
1683+
1684+
cmdInstance.action = command.action();
1685+
cmdInstance.action({ options: { toVersion: '1.10.0', output: 'json' } }, (err?: any) => {
1686+
const findings: Finding[] = log[0];
1687+
assert.equal(findings.length, 11);
1688+
});
1689+
});
1690+
1691+
it('e2e: shows correct number of findings for upgrading list view command set 1.9.1 project to 1.10.0', () => {
1692+
sinon.stub(command as any, 'getProjectRoot').callsFake(_ => path.join(process.cwd(), 'src/o365/spfx/commands/project/project-upgrade/test-projects/spfx-191-listviewcommandset'));
1693+
1694+
cmdInstance.action = command.action();
1695+
cmdInstance.action({ options: { toVersion: '1.10.0', output: 'json' } }, (err?: any) => {
1696+
const findings: Finding[] = log[0];
1697+
assert.equal(findings.length, 12);
1698+
});
1699+
});
1700+
1701+
it('e2e: shows correct number of findings for upgrading ko web part 1.9.1 project to 1.10.0', () => {
1702+
sinon.stub(command as any, 'getProjectRoot').callsFake(_ => path.join(process.cwd(), 'src/o365/spfx/commands/project/project-upgrade/test-projects/spfx-191-webpart-ko'));
1703+
1704+
cmdInstance.action = command.action();
1705+
cmdInstance.action({ options: { toVersion: '1.10.0', output: 'json' } }, (err?: any) => {
1706+
const findings: Finding[] = log[0];
1707+
assert.equal(findings.length, 14);
1708+
});
1709+
});
1710+
1711+
it('e2e: shows correct number of findings for upgrading no framework web part 1.9.1 project to 1.10.0', () => {
1712+
sinon.stub(command as any, 'getProjectRoot').callsFake(_ => path.join(process.cwd(), 'src/o365/spfx/commands/project/project-upgrade/test-projects/spfx-191-webpart-nolib'));
1713+
1714+
cmdInstance.action = command.action();
1715+
cmdInstance.action({ options: { toVersion: '1.10.0', output: 'json' } }, (err?: any) => {
1716+
const findings: Finding[] = log[0];
1717+
assert.equal(findings.length, 14);
1718+
});
1719+
});
1720+
1721+
it('e2e: shows correct number of findings for upgrading react web part 1.9.1 project to 1.10.0', () => {
1722+
sinon.stub(command as any, 'getProjectRoot').callsFake(_ => path.join(process.cwd(), 'src/o365/spfx/commands/project/project-upgrade/test-projects/spfx-191-webpart-react'));
1723+
1724+
cmdInstance.action = command.action();
1725+
cmdInstance.action({ options: { toVersion: '1.10.0', output: 'json' } }, (err?: any) => {
1726+
const findings: Finding[] = log[0];
1727+
assert.equal(findings.length, 14);
1728+
});
1729+
});
1730+
//#endregion
1731+
16701732
//#region superseded rules
16711733
it('ignores superseded findings (1.7.1 > 1.8.2)', () => {
16721734
sinon.stub(command as any, 'getProjectRoot').callsFake(_ => path.join(process.cwd(), 'src/o365/spfx/commands/project/project-upgrade/test-projects/spfx-171-webpart-react'));
16731735

16741736
cmdInstance.action = command.action();
16751737
cmdInstance.action({ options: { toVersion: '1.8.2', output: 'json' } }, (err?: any) => {
16761738
const findings: Finding[] = log[0];
1677-
assert.equal(findings.length, 23);
1739+
assert.equal(findings.length, 24);
16781740
});
16791741
});
16801742

src/o365/spfx/commands/project/project-upgrade.ts

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,8 @@ class SpfxProjectUpgradeCommand extends Command {
5555
'1.8.0',
5656
'1.8.1',
5757
'1.8.2',
58-
'1.9.1'
58+
'1.9.1',
59+
'1.10.0'
5960
];
6061
private static packageCommands = {
6162
npm: {
@@ -848,7 +849,7 @@ ${f.resolution}
848849
The ${this.name} command helps you upgrade your SharePoint Framework
849850
project to the specified version. If no version is specified, the command
850851
will upgrade to the latest version of the SharePoint Framework it supports
851-
(v1.8.2).
852+
(v1.10.0).
852853
853854
This command doesn't change your project files. Instead, it gives you
854855
a report with all steps necessary to upgrade your project to the specified
@@ -860,8 +861,8 @@ ${f.resolution}
860861
861862
Using this command you can upgrade SharePoint Framework projects built using
862863
versions: 1.0.0, 1.0.1, 1.0.2, 1.1.0, 1.1.1, 1.1.3, 1.2.0, 1.3.0, 1.3.1,
863-
1.3.2, 1.3.4, 1.4.0, 1.4.1, 1.5.0, 1.5.1, 1.6.0, 1.7.0, 1.7.1, 1.8.0 and
864-
1.8.1, 1.8.2.
864+
1.3.2, 1.3.4, 1.4.0, 1.4.1, 1.5.0, 1.5.1, 1.6.0, 1.7.0, 1.7.1, 1.8.0,
865+
1.8.1, 1.8.2 and 1.9.1.
865866
866867
Examples:
867868

src/o365/spfx/commands/project/project-upgrade/rules/FN001021_DEP_microsoft_sp_property_pane.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import { DependencyRule } from "./DependencyRule";
2+
import { Project } from "../model";
23

34
export class FN001021_DEP_microsoft_sp_property_pane extends DependencyRule {
45
constructor(packageVersion: string) {
@@ -9,4 +10,9 @@ export class FN001021_DEP_microsoft_sp_property_pane extends DependencyRule {
910
get id(): string {
1011
return 'FN001021';
1112
}
13+
14+
customCondition(project: Project): boolean {
15+
return !!project.packageJson &&
16+
!!project.packageJson.dependencies['@microsoft/sp-webpart-base'];
17+
}
1218
}
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
import { DependencyRule } from "./DependencyRule";
2+
3+
export class FN002012_DEVDEP_microsoft_rush_stack_compiler_3_3 extends DependencyRule {
4+
constructor(packageVersion: string) {
5+
/* istanbul ignore next */
6+
super('@microsoft/rush-stack-compiler-3.3', packageVersion, true);
7+
}
8+
9+
get id(): string {
10+
return 'FN002012';
11+
}
12+
13+
get supersedes(): string[] {
14+
return ['FN002010', 'FN002011'];
15+
}
16+
}
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
# EditorConfig helps developers define and maintain consistent
2+
# coding styles between different editors and IDEs
3+
# editorconfig.org
4+
5+
root = true
6+
7+
8+
[*]
9+
10+
# change these settings to your own preference
11+
indent_style = space
12+
indent_size = 2
13+
14+
# we recommend you to keep these unchanged
15+
end_of_line = lf
16+
charset = utf-8
17+
trim_trailing_whitespace = true
18+
insert_final_newline = true
19+
20+
[*.md]
21+
trim_trailing_whitespace = false
22+
23+
[{package,bower}.json]
24+
indent_style = space
25+
indent_size = 2
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
# Logs
2+
logs
3+
*.log
4+
npm-debug.log*
5+
6+
# Dependency directories
7+
node_modules
8+
9+
# Build generated files
10+
dist
11+
lib
12+
solution
13+
temp
14+
*.sppkg
15+
16+
# Coverage directory used by tools like istanbul
17+
coverage
18+
19+
# OSX
20+
.DS_Store
21+
22+
# Visual Studio files
23+
.ntvs_analysis.dat
24+
.vs
25+
bin
26+
obj
27+
28+
# Resx Generated Code
29+
*.resx.ts
30+
31+
# Styles Generated Code
32+
*.scss.ts
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
{
2+
"recommendations": [
3+
"msjsdiag.debugger-for-chrome"
4+
]
5+
}
Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
{
2+
/**
3+
* Install Chrome Debugger Extension for Visual Studio Code to debug your components with the
4+
* Chrome browser: https://aka.ms/spfx-debugger-extensions
5+
*/
6+
"version": "0.2.0",
7+
"configurations": [{
8+
"name": "Local workbench",
9+
"type": "chrome",
10+
"request": "launch",
11+
"url": "https://localhost:4321/temp/workbench.html",
12+
"webRoot": "${workspaceRoot}",
13+
"sourceMaps": true,
14+
"sourceMapPathOverrides": {
15+
"webpack:///.././src/*": "${webRoot}/src/*",
16+
"webpack:///../../../src/*": "${webRoot}/src/*",
17+
"webpack:///../../../../src/*": "${webRoot}/src/*",
18+
"webpack:///../../../../../src/*": "${webRoot}/src/*"
19+
},
20+
"runtimeArgs": [
21+
"--remote-debugging-port=9222"
22+
]
23+
},
24+
{
25+
"name": "Hosted workbench",
26+
"type": "chrome",
27+
"request": "launch",
28+
"url": "https://enter-your-SharePoint-site/_layouts/workbench.aspx",
29+
"webRoot": "${workspaceRoot}",
30+
"sourceMaps": true,
31+
"sourceMapPathOverrides": {
32+
"webpack:///.././src/*": "${webRoot}/src/*",
33+
"webpack:///../../../src/*": "${webRoot}/src/*",
34+
"webpack:///../../../../src/*": "${webRoot}/src/*",
35+
"webpack:///../../../../../src/*": "${webRoot}/src/*"
36+
},
37+
"runtimeArgs": [
38+
"--remote-debugging-port=9222",
39+
"-incognito"
40+
]
41+
}
42+
]
43+
}
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
// Place your settings in this file to overwrite default and user settings.
2+
{
3+
// Configure glob patterns for excluding files and folders in the file explorer.
4+
"files.exclude": {
5+
"**/.git": true,
6+
"**/.DS_Store": true,
7+
"**/bower_components": true,
8+
"**/coverage": true,
9+
"**/lib-amd": true,
10+
"src/**/*.scss.ts": true
11+
},
12+
"typescript.tsdk": ".\\node_modules\\typescript\\lib"
13+
}

0 commit comments

Comments
 (0)