8000 chore: remove grunt and update build scripts (#7838) · NativeScript/NativeScript@25046c7 · GitHub
[go: up one dir, main page]

Skip to content

Commit 25046c7

Browse files
chore: remove grunt and update build scripts (#7838)
* chore: prepare and pack scripts * chore: update @types/node dep * chore: remove prepare-dist command from pack-dist
1 parent a8680f0 commit 25046c7

File tree

13 files changed

+206
-788
lines changed

13 files changed

+206
-788
lines changed

build/clear-private-definitions.js

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
const path = require("path");
2+
const fs = require("fs");
3+
const readdirp = require("readdirp");
4+
5+
const inputFolder = path.resolve(process.argv[2]);
6+
7+
console.log(`Clearing private definitions in ${inputFolder}`);
8+
9+
function filterTypeScriptFiles(content) {
10+
var leadingPrivate = /^.*@private/ig;
11+
if (leadingPrivate.test(content)) {
12+
return { shouldDelete: true };
13+
}
14+
15+
let blockCommentPrivate = /\/\*\*([^](?!\*\/))*@module([^](?!\*\/))*@private[^]*?\*\//g;
16+
if (blockCommentPrivate.test(content)) {
17+
return { shouldDelete: true };
18+
}
19+
20+
let newContent = content;
21+
newContent = newContent.replace(/\/\/[\/\s]*@private[^]*?\/\/[\/\s]*?@endprivate/gm, "");
22+
23+
if (newContent !== content) {
24+
return { shouldReplace: true, newContent: newContent };
25+
}
26+
27+
return { shouldReplace: false, shouldDelete: false };
28+
};
29+
30+
readdirp(inputFolder, {
31+
fileFilter: ["*.d.ts"],
32+
directoryFilter: function (di) { return !di.path.includes("node_modules"); }
33+
}).on("data", (entry) => {
34+
const { fullPath } = entry;
35+
const content = fs.readFileSync(fullPath, "utf8");
36+
const { shouldDelete, shouldReplace, newContent } = filterTypeScriptFiles(content);
37+
38+
if (shouldDelete) {
39+
console.log("[Delete]", fullPath)
40+
fs.unlinkSync(fullPath);
41+
} else if (shouldReplace) {
42+
console.log("[Cleared]", fullPath)
43+
fs.writeFileSync(fullPath, newContent, "utf8", (err) => {
44+
console.log("ERROR writing file: " + fullPath, error);
45+
})
46+
}
47+
})
48+
.on("warn", error => console.error("non-fatal error", error))
49+
.on("error", error => console.error("fatal error", error))
50+
.on("end", () => console.log("done"));
51+

build/create-release-changelog-pr.js

Lines changed: 0 additions & 18 deletions
This file was deleted.

build/pack-dist.sh

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
#!/bin/bash
2+
set -x
3+
set -e
4+
5+
DIST=dist;
6+
ROOT_DIR=$(cd `dirname $0` && pwd)/..;
7+
cd "$ROOT_DIR"
8+
9+
(
10+
cd "$DIST/tns-platform-declarations"
11+
TGZ="$(npm pack)"
12+
mv "$TGZ" "../$TGZ"
13+
)
14+
15+
(
16+
cd "$DIST/tns-core-modules"
17+
TGZ="$(npm pack)"
18+
mv "$TGZ" "../$TGZ"
19+
)

build/prepare-dist.sh

Lines changed: 69 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,69 @@
1+
#!/bin/bash
2+
set -x
3+
set -e
4+
5+
DIST=dist;
6+
ROOT_DIR=$(cd `dirname $0` && pwd)/..;
7+
cd "$ROOT_DIR"
8+
9+
mkdir -p "$DIST"
10+
11+
## NPM INSTALL
12+
(
13+
echo "NPM install in root of the repo"
14+
cd "$ROOT_DIR"
15+
npm install
16+
)
17+
18+
## Prepare Platfrom Declarations
19+
(
20+
PACKAGE=tns-platform-declarations;
21+
22+
echo "Clearing $DIST/$PACKAGE"
23+
npx rimraf "$DIST/$PACKAGE"
24+
npx rimraf "$DIST/$PACKAGE*.tgz"
25+
26+
echo "Copying $PACKAGE $DIST/$PACKAGE..."
27+
npx ncp "$PACKAGE" "$DIST/$PACKAGE"
28+
29+
echo "Copying README and LICENSE to $DIST/$PACKAGE"
30+
npx ncp LICENSE "$DIST/$PACKAGE"/LICENSE
31+
32+
cd "$DIST/$PACKAGE"
33+
34+
echo 'Running npm install...'
35+
npm install
36+
37+
echo 'Running npm test...'
38+
npm test
39+
)
40+
41+
## Prepare Core Modules
42+
(
43+
PACKAGE=tns-core-modules;
44+
45+
echo "Clearing $DIST/$PACKAGE"
46+
npx rimraf "$DIST/$PACKAGE"
47+
npx rimraf "$DIST/$PACKAGE*.tgz"
48+
49+
echo "Copying $PACKAGE $DIST/$PACKAGE..."
50+
npx ncp "$PACKAGE" "$DIST/$PACKAGE"
51+
52+
echo "Cleaning inner readme.md-s ..."
53+
npx rimraf "$DIST/$PACKAGE/**/README.md"
54+
npx rimraf "$DIST/$PACKAGE/**/Readme.md"
55+
56+
echo "Copying README and LICENSE to $DIST/$PACKAGE"
57+
npx ncp LICENSE "$DIST"/"$PACKAGE"/LICENSE
58+
npx ncp README.md "$DIST"/"$PACKAGE"/README.md
59+
60+
(
61+
echo 'TypeScript transpile...'
62+
cd "$DIST/$PACKAGE"
63+
npm install
64+
npx tsc
65+
)
66+
67+
echo "Clearing typescript definitions from private APIs..."
68+
node build/clear-private-definitions "$DIST/$PACKAGE"
69+
)

0 commit comments

Comments
 (0)
0