Skip to content

chore: change script to pack compat package for release #2035

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 1 commit into from
Oct 24, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 13 additions & 4 deletions build/pack-scripts/pack-compat.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import { execSync } from "child_process";

// var myArgs = process.argv.slice(2);
var scopedVersion = process.argv[2];
var skipInstall = process.argv[3];
console.log(`Packing nativescript-angular package with @nativescript/angular: ${scopedVersion}`);

const distFolderPath = path.resolve("../../dist");
Expand All @@ -15,7 +16,8 @@ const packageJsonPath = path.resolve(`${nsAngularPackagePath}/package.json`);
console.log("Getting package.json from", packageJsonPath);

let npmInstallParams = "";
if (scopedVersion.indexOf(".tgz") > 0) {

if (scopedVersion.indexOf(".tgz") > 0 || skipInstall === "no-save-exact") {
// rewrite dependency in package.json
const packageJsonObject = JSON.parse(fs.readFileSync(packageJsonPath, { encoding: "utf8" }));
packageJsonObject.dependencies["@nativescript/angular"] = scopedVersion;
Expand All @@ -24,14 +26,21 @@ if (scopedVersion.indexOf(".tgz") > 0) {
npmInstallParams = `@nativescript/angular@${scopedVersion}`;
}

execSync(`npm install --save-exact ${npmInstallParams}`, {
cwd: nsAngularPackagePath
});
if (skipInstall !== "no-save-exact") {
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
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"
}
}