Skip to content

release: cut the 8.20.0 release #2039

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 9 commits into from
Oct 25, 2019
Merged
46 changes: 37 additions & 9 deletions build/pack-scripts/pack-compat.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,36 +2,64 @@ import * as path from "path";
import * as fs from "fs-extra";
import { execSync } from "child_process";

// var myArgs = process.argv.slice(2);
/**
* Use this script to pack .tgz for nativescript-angular package. The first passed param can be:
* 1. Path to .tgz file - in this case the script replaces the scoped dependency (@nativescript/angular) with it in the package.json file. Then packs.
* 2. Tag or exact version - in this case the script does `npm install --save-exact` to save the exact version (in case if tag). Then packs.
* 3. `auto-version` - this is interpreted by getting version from the scoped package.json file (nativescript-angular folder).
*/

var scopedVersion = process.argv[2];

console.log(`Packing nativescript-angular package with @nativescript/angular: ${scopedVersion}`);

const distFolderPath = path.resolve("../../dist");
const tempFolderPath = path.resolve("./temp-compat");
const outFileName = "nativescript-angular-compat.tgz";

const nsAngularScopedPackageJSONPath = path.resolve("../../nativescript-angular/package.json");
const nsAngularPackagePath = path.resolve("../../nativescript-angular-package");
const packageJsonPath = path.resolve(`${nsAngularPackagePath}/package.json`);
console.log("Getting package.json from", packageJsonPath);

let npmInstallParams = "";
if (scopedVersion.indexOf(".tgz") > 0) {
// rewrite dependency in package.json

function prepareCompatPackageJSON(scopedVersion: string) {
const packageJsonObject = JSON.parse(fs.readFileSync(packageJsonPath, { encoding: "utf8" }));
packageJsonObject.dependencies["@nativescript/angular"] = scopedVersion;
fs.writeFileSync(packageJsonPath, JSON.stringify(packageJsonObject, null, 4));
} else {
npmInstallParams = `@nativescript/angular@${scopedVersion}`;
}

execSync(`npm install --save-exact ${npmInstallParams}`, {
cwd: nsAngularPackagePath
});
if (scopedVersion === "auto-version") {
// We use this when build for release. In this case we need to get version from scoped package (nativescript-angular)
// and use it in the compat package.

scopedVersion = JSON.parse(fs.readFileSync(nsAngularScopedPackageJSONPath, { encoding: "utf8" })).version;
prepareCompatPackageJSON(scopedVersion)
} else {
let npmInstallParams = "";

if (scopedVersion.indexOf(".tgz") > 0) {
// If building with .tgz, we need to update the package.json of the compat package
prepareCompatPackageJSON(scopedVersion)
} else {
// If building with tag or exact version, just install it with --save-exact
npmInstallParams = `@nativescript/angular@${scopedVersion}`;
}

execSync(`npm install --save-exact ${npmInstallParams}`, {
cwd: nsAngularPackagePath
});
}

// ensure empty temp and existing dist folders
fs.emptyDirSync(tempFolderPath);
fs.ensureDirSync(distFolderPath);

// Install, run tsc and run ngc
execSync(`npm i && tsc && npm run ngc`, {
cwd: nsAngularPackagePath
});

// create .tgz in temp folder
execSync(`npm pack ${nsAngularPackagePath}`, {
cwd: tempFolderPath
Expand Down
8 changes: 8 additions & 0 deletions e2e/tests-app-ng/app/lazy/lazy.component.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@

.system-background-color-stack-layout {
background-color: white;
}

.ns-dark .system-background-color-stack-layout {
background-color: gray;
}
2 changes: 1 addition & 1 deletion e2e/tests-app-ng/app/lazy/lazy.component.html
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<StackLayout>
<StackLayout class="system-background-color-stack-layout">
<GridLayout rows="auto" columns="auto" [visibility]="isModal ? 'visible' : 'collapsed'">
<Button
automationText="closeModal"
Expand Down
1 change: 1 addition & 0 deletions e2e/tests-app-ng/app/lazy/lazy.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import { ModalDialogParams } from "nativescript-angular/directives/dialogs";
selector: "ns-lazy",
moduleId: module.id,
templateUrl: "./lazy.component.html",
styleUrls: ["./lazy.component.css"]
})
export class LazyComponent {
public isModal: boolean;
Expand Down
2 changes: 1 addition & 1 deletion e2e/tests-app-ng/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
"@angular/platform-browser": "~8.2.0",
"@angular/platform-browser-dynamic": "~8.2.0",
"@angular/router": "~8.2.0",
"nativescript-angular": "file:../../nativescript-angular",
"nativescript-angular": "file:../../nativescript-angular-package",
"nativescript-intl": "~3.0.0",
"nativescript-theme-core": "^1.0.4",
"reflect-metadata": "~0.1.8",
Expand Down
3 changes: 3 additions & 0 deletions e2e/tests-app-ng/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,13 @@
}
},
"include": [
"../../nativescript-angular-package",
"../../nativescript-angular",
"**/*"
],
"exclude": [
"../../nativescript-angular-package/node_modules",
"../../nativescript-angular-package/**/*.d.ts",
"../../nativescript-angular/node_modules",
"../../nativescript-angular/**/*.d.ts",
"node_modules",
Expand Down
2 changes: 1 addition & 1 deletion nativescript-angular-package/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,6 @@
},
"scripts": {
"ngc": "ngc -p tsconfig.json",
"pack-with-scoped-version": "npm i && tsc && npm run ngc && cd ../build/pack-scripts && npm i && npx ts-node pack-compat.ts"
"pack-with-scoped-version": "cd ../build/pack-scripts && npm i && npx ts-node pack-compat.ts"
}
}