|
1 | | -// import * as path from "path"; |
2 | | -// import * as fs from "fs-extra"; |
3 | | -// import { execSync } from "child_process"; |
4 | | - |
5 | | -// // var myArgs = process.argv.slice(2); |
6 | | -// var scopedVersion = process.argv[2]; |
7 | | -// console.log(`Packing nativescript-angular package with @nativescript/angular: ${scopedVersion}`); |
8 | | - |
9 | | -// const distFolderPath = path.resolve("../../dist"); |
10 | | -// const nsAngularPackagePath = path.resolve("../../nativescript-angular-package"); |
11 | | -// const packageJsonPath = path.resolve(`${nsAngularPackagePath}/package.json`); |
12 | | -// console.log("Getting package.json from", packageJsonPath); |
13 | | - |
14 | | -// // rewrite dependency in package.json |
15 | | -// const packageJsonObject = JSON.parse(fs.readFileSync(packageJsonPath, { encoding: "utf8" })); |
16 | | -// packageJsonObject.dependencies["@nativescript/angular"] = scopedVersion; |
17 | | -// fs.writeFileSync(packageJsonPath, JSON.stringify(packageJsonObject, null, 4)); |
18 | | - |
19 | | -// // create .tgz in dist folder |
20 | | -// execSync(`npm install`, { |
21 | | -// cwd: nsAngularPackagePath |
22 | | -// }); |
23 | | -// // ensures empty ../dist folder |
24 | | -// fs.emptyDirSync(distFolderPath); |
25 | | -// // cd to dist folder |
26 | | -// execSync(`npm pack ${nsAngularPackagePath}`, { |
27 | | -// cwd: distFolderPath |
28 | | -// }); |
29 | | - |
30 | | -// console.log("######" + distFolderPath); |
31 | | -// fs.copySync(distFolderPath + "/nativescript-angular-8.3.0.tgz", distFolderPath + "/nativescript-angular-8.3.0.1.tgz") |
| 1 | +import * as path from "path"; |
| 2 | +import * as fs from "fs-extra"; |
| 3 | +import { execSync } from "child_process"; |
| 4 | + |
| 5 | +console.log(`Packing @nativescript/angular package`); |
| 6 | + |
| 7 | +const distFolderPath = path.resolve("../../dist"); |
| 8 | +const tempFolderPath = path.resolve("./temp-scoped"); |
| 9 | +const outFileName = "nativescript-angular-scoped.tgz"; |
| 10 | + |
| 11 | +const nsAngularPackagePath = path.resolve("../../nativescript-angular"); |
| 12 | + |
| 13 | +execSync(`npm install --save-exact`, { |
| 14 | + cwd: nsAngularPackagePath |
| 15 | +}); |
| 16 | + |
| 17 | +// ensure empty temp and dist folders |
| 18 | +fs.emptyDirSync(tempFolderPath); |
| 19 | +fs.emptyDirSync(distFolderPath); |
| 20 | + |
| 21 | +// create .tgz in temp folder |
| 22 | +execSync(`npm pack ${nsAngularPackagePath}`, { |
| 23 | + cwd: tempFolderPath |
| 24 | +}); |
| 25 | + |
| 26 | +// assume we have a single file built in temp folder, take its name |
| 27 | +const currentFileName = fs.readdirSync(tempFolderPath)[0]; |
| 28 | + |
| 29 | +// move built file and remove temp folder |
| 30 | +fs.moveSync(`${tempFolderPath}/${currentFileName}`, `${distFolderPath}/${outFileName}`); |
| 31 | +fs.removeSync(`${tempFolderPath}`); |
0 commit comments