Skip to content

Commit 1cb22db

Browse files
committed
chore: pack script for compat package
1 parent fdad1c9 commit 1cb22db

File tree

7 files changed

+108
-57
lines changed

7 files changed

+108
-57
lines changed

.gitignore

+2
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ node_modules
22
platforms
33
hooks
44
tags
5+
dist
56
**/*.js.map
67
**/*.metadata.json
78

@@ -46,3 +47,4 @@ tsconfig.tns.json
4647
!.vscode/tasks.json
4748
!.vscode/launch.json
4849
!.vscode/extensions.json
50+

build/pack-script/index.ts

-6
This file was deleted.

build/pack-scripts/pack-compat.ts

+28
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
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+
});

build/pack-scripts/pack-scoped.ts

+28
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
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+
});

build/pack-script/package.json renamed to build/pack-scripts/package.json

+4-1
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,9 @@
1010
"license": "ISC",
1111
"devDependencies": {
1212
"@types/node": "^12.7.12",
13-
"ts-node": "^8.4.1"
13+
"fs-extra": "^8.1.0",
14+
"rimraf": "^3.0.0",
15+
"ts-node": "^8.4.1",
16+
"typescript": "^3.6.4"
1417
}
1518
}

build/pack-script/tsconfig.json renamed to build/pack-scripts/tsconfig.json

+8-12
Original file line numberDiff line numberDiff line change
@@ -11,19 +11,15 @@
1111
"dom",
1212
"es2015.iterable"
1313
],
14-
"baseUrl": ".",
15-
"paths": {
16-
"*": [
17-
"./node_modules/*"
18-
]
19-
},
2014
"types": [
2115
"node"
2216
],
23-
"typeRoots": [
24-
// add path to @types
25-
"node_modules/@types"
26-
],
27-
"strict": false
28-
}
17+
"typeRoots": [ "./node_modules/@types" ]
18+
},
19+
"include": [
20+
"./**/*.ts"
21+
],
22+
"exclude": [
23+
"node_modules"
24+
]
2925
}
+38-38
Original file line numberDiff line numberDiff line change
@@ -1,40 +1,40 @@
11
{
2-
"name": "nativescript-angular",
3-
"version": "8.3.0",
4-
"description": "An Angular renderer that lets you build mobile apps with NativeScript.",
5-
"homepage": "https://www.nativescript.org/",
6-
"bugs": "https://github.com/NativeScript/nativescript-angular/issues",
7-
"author": {
8-
"name": "NativeScript Team"
9-
},
10-
"contributors": [
11-
"Hristo Deshev <[email protected]>",
12-
"Alexander Vakrilov <[email protected]>",
13-
"Stanimira Vlaeva <[email protected]>"
14-
],
15-
"nativescript": {
16-
"platforms": {
17-
"android": "6.0.0",
18-
"ios": "6.0.0"
2+
"name": "nativescript-angular",
3+
"version": "8.3.0",
4+
"description": "An Angular renderer that lets you build mobile apps with NativeScript.",
5+
"homepage": "https://www.nativescript.org/",
6+
"bugs": "https://github.com/NativeScript/nativescript-angular/issues",
7+
"author": {
8+
"name": "NativeScript Team"
9+
},
10+
"contributors": [
11+
"Hristo Deshev <[email protected]>",
12+
"Alexander Vakrilov <[email protected]>",
13+
"Stanimira Vlaeva <[email protected]>"
14+
],
15+
"nativescript": {
16+
"platforms": {
17+
"android": "6.0.0",
18+
"ios": "6.0.0"
19+
}
20+
},
21+
"keywords": [
22+
"NativeScript",
23+
"Angular"
24+
],
25+
"license": "Apache-2.0",
26+
"repository": {
27+
"type": "git",
28+
"url": "https://github.com/NativeScript/nativescript-angular.git"
29+
},
30+
"bin": {
31+
"update-app-ng-deps": "node_modules/@nativescript/angular/bin/update-app-ng-deps"
32+
},
33+
"dependencies": {
34+
"@nativescript/angular": "file:../nativescript-angular"
35+
},
36+
"scripts": {
37+
"pack": "cd ../build && npm pack ../nativescript-angular-package",
38+
"pack-with-scoped-version": "cd ../build/pack-scripts && npm i && npx ts-node pack-compat.ts"
1939
}
20-
},
21-
"keywords": [
22-
"NativeScript",
23-
"Angular"
24-
],
25-
"license": "Apache-2.0",
26-
"repository": {
27-
"type": "git",
28-
"url": "https://github.com/NativeScript/nativescript-angular.git"
29-
},
30-
"bin": {
31-
"update-app-ng-deps": "node_modules/@nativescript/angular/bin/update-app-ng-deps"
32-
},
33-
"dependencies": {
34-
"@nativescript/angular": "file:../nativescript-angular"
35-
},
36-
"scripts": {
37-
"pack": "cd ../build && npm pack ../nativescript-angular-package",
38-
"pack-with-scoped-version": "cd ../build/pack-script && npx ts-node index.ts"
39-
}
40-
}
40+
}

0 commit comments

Comments
 (0)