10000 chore: remove grunt and update build scripts by SvetoslavTsenov · Pull Request #7838 · NativeScript/NativeScript · GitHub
[go: up one dir, main page]

Skip to content

chore: remove grunt and update build scripts #7838

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 3 commits into from
Sep 17, 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
51 changes: 51 additions & 0 deletions build/clear-private-definitions.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
const path = require("path");
const fs = require("fs");
const readdirp = require("readdirp");

const inputFolder = path.resolve(process.argv[2]);

console.log(`Clearing private definitions in ${inputFolder}`);

function filterTypeScriptFiles(content) {
var leadingPrivate = /^.*@private/ig;
if (leadingPrivate.test(content)) {
return { shouldDelete: true };
}

let blockCommentPrivate = /\/\*\*([^](?!\*\/))*@module([^](?!\*\/))*@private[^]*?\*\//g;
if (blockCommentPrivate.test(content)) {
return { shouldDelete: true };
}

let newContent = content;
newContent = newContent.replace(/\/\/[\/\s]*@private[^]*?\/\/[\/\s]*?@endprivate/gm, "");

if (newContent !== content) {
return { shouldReplace: true, newContent: newContent };
}

return { shouldReplace: false, shouldDelete: false };
};

readdirp(inputFolder, {
fileFilter: ["*.d.ts"],
directoryFilter: function (di) { return !di.path.includes("node_modules"); }
}).on("data", (entry) => {
const { fullPath } = entry;
const content = fs.readFileSync(fullPath, "utf8");
const { shouldDelete, shouldReplace, newContent } = filterTypeScriptFiles(content);

if (shouldDelete) {
console.log("[Delete]", fullPath)
fs.unlinkSync(fullPath);
} else if (shouldReplace) {
console.log("[Cleared]", fullPath)
fs.writeFileSync(fullPath, newContent, "utf8", (err) => {
console.log("ERROR writing file: " + fullPath, error);
})
}
})
.on("warn", error => console.error("non-fatal error", error))
.on("error", error => console.error("fatal error", error))
.on("end", () => console.log("done"));

18 changes: 0 additions & 18 deletions build/create-release-changelog-pr.js

This file was deleted.

19 changes: 19 additions & 0 deletions build/pack-dist.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
#!/bin/bash
set -x
set -e

DIST=dist;
ROOT_DIR=$(cd `dirname $0` && pwd)/..;
cd "$ROOT_DIR"

(
cd "$DIST/tns-platform-declarations"
TGZ="$(npm pack)"
mv "$TGZ" "../$TGZ"
)

(
cd "$DIST/tns-core-modules"
TGZ="$(npm pack)"
mv "$TGZ" "../$TGZ"
)
69 changes: 69 additions & 0 deletions build/prepare-dist.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
#!/bin/bash
set -x
set -e

DIST=dist;
ROOT_DIR=$(cd `dirname $0` && pwd)/..;
cd "$ROOT_DIR"

mkdir -p "$DIST"

## NPM INSTALL
(
echo "NPM install in root of the repo"
cd "$ROOT_DIR"
npm install
)

## Prepare Platfrom Declarations
(
PACKAGE=tns-platform-declarations;

echo "Clearing $DIST/$PACKAGE"
npx rimraf "$DIST/$PACKAGE"
npx rimraf "$DIST/$PACKAGE*.tgz"

echo "Copying $PACKAGE $DIST/$PACKAGE..."
npx ncp "$PACKAGE" "$DIST/$PACKAGE"

echo "Copying README and LICENSE to $DIST/$PACKAGE"
npx ncp LICENSE "$DIST/$PACKAGE"/LICENSE

cd "$DIST/$PACKAGE"

echo 'Running npm install...'
npm install

echo 'Running npm test...'
npm test
)

## Prepare Core Modules
(
PACKAGE=tns-core-modules;

echo "Clearing $DIST/$PACKAGE"
npx rimraf "$DIST/$PACKAGE"
npx rimraf "$DIST/$PACKAGE*.tgz"

echo "Copying $PACKAGE $DIST/$PACKAGE..."
npx ncp "$PACKAGE" "$DIST/$PACKAGE"

echo "Cleaning inner readme.md-s ..."
npx rimraf "$DIST/$PACKAGE/**/README.md"
npx rimraf "$DIST/$PACKAGE/**/Readme.md"

echo "Copying README and LICENSE to $DIST/$PACKAGE"
npx ncp LICENSE "$DIST"/"$PACKAGE"/LICENSE
npx ncp README.md "$DIST"/"$PACKAGE"/README.md

(
echo 'TypeScript transpile...'
cd "$DIST/$PACKAGE"
npm install
npx tsc
)

echo "Clearing typescript definitions from private APIs..."
node build/clear-private-definitions "$DIST/$PACKAGE"
)
Loading
0