Skip to content

Commit

Permalink
Build Preview package as part of official build (#337)
Browse files Browse the repository at this point in the history
* Build Preview package as part of official build

* Move telemetry key to package.json, and set value during packageing

* Update description for preview package

* Replace README in preview extension

* PR feedback - rename preview md

* Switch Package to only create one vsix, and run the build twice in the official build to create both packages

* Replace Preview.md and file copying with text replacement

* typo fix

* moved readme header strings into the function that uses them

* Switch to package config objects
  • Loading branch information
tehcrashxor authored Nov 4, 2022
1 parent cfbd3cb commit 6642f65
Show file tree
Hide file tree
Showing 4 changed files with 63 additions and 15 deletions.
8 changes: 7 additions & 1 deletion .azure-pipelines/OfficialBuild.yml
Original file line number Diff line number Diff line change
Expand Up @@ -63,11 +63,17 @@ steps:
# customCommand: run increment-version

- task: Npm@1
displayName: 'Build and package VSIX'
displayName: 'Official Build and Package VSIX'
inputs:
command: custom
customCommand: run dist -- --feedPAT $(AZ_DevOps_Read_PAT) --isOfficialBuild true

- task: Npm@1
displayName: 'Preview Build and Package VSIX'
inputs:
command: custom
customCommand: run dist -- --feedPAT $(AZ_DevOps_Read_PAT) --isPreviewBuild true

# https://microsoft.sharepoint.com/teams/prss/esrp/info/ESRP%20Onboarding%20Wiki/Generating%20Signing%20JSON.aspx
# https://microsoft.sharepoint.com/teams/prss/esrp/info/ESRP%20Onboarding%20Wiki/Selecting%20CodeSign%20Certificates.aspx
- task: SFP.build-tasks.custom-build-task-1.EsrpCodeSigning@1
Expand Down
48 changes: 45 additions & 3 deletions gulpfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ const outdir = path.resolve('./out');
const packagedir = path.resolve('./package');
const feedPAT = argv.feedPAT || process.env['AZ_DevOps_Read_PAT'];
const isOfficialBuild = argv.isOfficialBuild && argv.isOfficialBuild.toLowerCase() == "true";
const isPreviewBuild = argv.isPreviewBuild && argv.isPreviewBuild.toLowerCase() == "true";

async function clean() {
(await pslist())
Expand All @@ -48,7 +49,7 @@ async function clean() {
}

function setTelemetryTarget() {
const telemetryConfigurationSource = isOfficialBuild
const telemetryConfigurationSource = isOfficialBuild && !isPreviewBuild
? 'src/common/telemetry/telemetryConfigurationProd.ts'
: 'src/common/telemetry/telemetryConfigurationDev.ts';

Expand All @@ -58,6 +59,7 @@ function setTelemetryTarget() {
.pipe(gulp.dest(path.join('src', 'common', 'telemetry', 'generated')));
}


function compile() {
return gulp
.src('src/**/*.ts')
Expand Down Expand Up @@ -215,10 +217,44 @@ const test = gulp.series(testUnitTests, testWeb);
const testInt = gulp.series(testDebugger);

async function packageVsix() {
fs.emptyDirSync(packagedir);
return vsce.createVSIX({
const standardHeader = '# Power Platform Extension';
const previewHeader = '# Power Platform Tools [PREVIEW]\n\n## This extension is used for internal testing against targets such as vscode.dev which require Marketplace published extensions, and is not supported.';
const standardPackageOptions = {
name: 'powerplatform-vscode',
displayName: 'Power Platform Tools',
description: 'Tooling to create Power Platform solutions & packages, manage Power Platform environments and edit Power Apps Portals',
readmeHeader: standardHeader,
readmeReplacementTarget: previewHeader,
};
const previewPackageOptions = {
name: 'powerplatform-vscode-preview',
displayName: 'Power Platform Tools [PREVIEW]',
description: 'Unsupported extension for testing Power Platform Tools',
readmeHeader: previewHeader,
readmeReplacementTarget: standardHeader,
};

const setPackageInfo = async function(pkgOptions) {
await npm(['pkg', 'set', `name=${pkgOptions.name}`]);
await npm(['pkg', 'set', `displayName="${pkgOptions.displayName}"`]);
await npm(['pkg', 'set', `description="${pkgOptions.description}"`]);

gulp.src('README.md')
.pipe(replace(pkgOptions.readmeReplacementTarget, pkgOptions.readmeHeader))
.pipe(gulp.dest('./'));
}

await setPackageInfo(isPreviewBuild ? previewPackageOptions : standardPackageOptions);

await vsce.createVSIX({
packagePath: packagedir,
preRelease: isPreviewBuild,
});

// Reset to non-preview settings to prevent polluting git diffs
if (isPreviewBuild) {
await setPackageInfo(standardPackageOptions);
}
}


Expand All @@ -228,6 +264,12 @@ async function git(args) {
return {stdout: stdout, stderr: stderr};
}

async function npm(args) {
args.unshift('npm');
const {stdout, stderr } = await exec(args.join(' '));
return {stdout: stdout, stderr: stderr};
}

async function setGitAuthN() {
const repoUrl = 'https://github.com';
const repoToken = argv.repoToken;
Expand Down
16 changes: 8 additions & 8 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 3 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
"email": "[email protected]"
},
"engines": {
"vscode": "^1.51.0"
"vscode": "^1.72.0"
},
"extensionKind": [
"workspace"
Expand Down Expand Up @@ -723,7 +723,7 @@
"@types/sinon": "^10.0.12",
"@types/unzip-stream": "^0.3.0",
"@types/uuid": "^8.3.0",
"@types/vscode": "^1.51.0",
"@types/vscode": "^1.72.0",
"@types/webpack": "^5.28.0",
"@types/webpack-env": "^1.17.0",
"@typescript-eslint/eslint-plugin": "^5.15.0",
Expand All @@ -739,8 +739,8 @@
"gulp-eslint": "^6.0.0",
"gulp-filter": "^7.0.0",
"gulp-mocha": "^8.0.0",
"gulp-replace": "^1.1.3",
"gulp-rename": "^2.0.0",
"gulp-replace": "^1.1.3",
"gulp-sourcemaps": "^2.6.5",
"gulp-typescript": "^6.0.0-alpha.1",
"mocha": "^9.2.2",
Expand Down

0 comments on commit 6642f65

Please sign in to comment.