Skip to content

Commit e8e83e4

Browse files
authored
chore(doctor): replace grunt with npm scripts and build to dist (#6093)
1 parent 1f679db commit e8e83e4

17 files changed

Lines changed: 105 additions & 243 deletions

packages/doctor/.gitignore

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -17,9 +17,6 @@ coverage
1717
# nyc test coverage
1818
.nyc_output
1919

20-
# Grunt intermediate storage (http://gruntjs.com/creating-plugins#storing-task-files)
21-
.grunt
22-
2320
# node-waf configuration
2421
.lock-wscript
2522

@@ -64,6 +61,8 @@ test-reports.xml
6461

6562
*.js
6663
*.js.map
67-
/src/.d.ts
68-
.d.ts
6964
!/*.js
65+
!/scripts/*.js
66+
67+
/dist/
68+
/dist-test/

packages/doctor/.npmrc

Lines changed: 0 additions & 1 deletion
This file was deleted.

packages/doctor/Gruntfile.js

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

packages/doctor/package.json

Lines changed: 10 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -2,21 +2,24 @@
22
"name": "@nativescript/doctor",
33
"version": "2.0.17",
44
"description": "Library that helps identifying if the environment can be used for development of {N} apps.",
5-
"main": "src/index.js",
5+
"main": "dist/index.js",
66
"types": "./typings/nativescript-doctor.d.ts",
77
"files": [
8-
"src/**/*.js",
8+
"dist/**/*.js",
9+
"dist/**/*.d.ts",
910
"resources",
1011
"typings",
1112
"CHANGELOG.md",
1213
"NOTICE.txt"
1314
],
1415
"scripts": {
15-
"clean": "npx rimraf node_modules package-lock.json && npm i && grunt clean",
16-
"build": "grunt",
17-
"build.all": "grunt ts:devall",
18-
"prepack": "grunt pack",
19-
"test": "istanbul cover ./node_modules/mocha/bin/_mocha -- --recursive",
16+
"clean": "npx rimraf node_modules package-lock.json && npm i && npm run clean.build",
17+
"clean.build": "node scripts/clean.js",
18+
"build": "tsc",
19+
"build.all": "tsc -p tsconfig.test.json && node scripts/copy-test-fixtures.js",
20+
"dev": "tsc --watch",
21+
"prepack": "npm run clean.build && npm test && tsc -p tsconfig.release.json",
22+
"test": "npm run build.all && mocha --recursive dist-test/test",
2023
"changelog": "conventional-changelog -p angular -i CHANGELOG.md -s"
2124
},
2225
"repository": {
@@ -51,17 +54,8 @@
5154
"@types/yauzl": "2.10.3",
5255
"chai": "5.3.3",
5356
"conventional-changelog-cli": "^5.0.0",
54-
"grunt": "1.6.1",
55-
"grunt-contrib-clean": "2.0.1",
56-
"grunt-contrib-watch": "1.1.0",
57-
"grunt-shell": "4.0.0",
58-
"grunt-ts": "6.0.0-beta.22",
59-
"grunt-tslint": "5.0.2",
60-
"istanbul": "0.4.5",
6157
"mocha": "11.7.5",
6258
"rimraf": "6.1.2",
63-
"tslint": "6.1.3",
64-
"tslint-microsoft-contrib": "6.2.0",
6559
"typescript": "~5.9.2"
6660
},
6761
"dependencies": {

packages/doctor/scripts/clean.js

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
const child_process = require("child_process");
2+
const fs = require("fs");
3+
const path = require("path");
4+
5+
const rootDir = path.join(__dirname, "..");
6+
7+
// Older checkouts compiled next to the sources; .gitignore is the source of
8+
// truth for which files under src/ and test/ are leftover compiler output.
9+
const result = child_process.spawnSync("git", ["clean", "-Xdf", "src", "test"], {
10+
cwd: rootDir,
11+
stdio: "inherit",
12+
});
13+
14+
if (result.error) {
15+
throw result.error;
16+
}
17+
18+
if (result.status !== 0) {
19+
throw new Error(`git clean exited with status ${result.status}`);
20+
}
21+
22+
for (const dir of ["dist", "dist-test", "coverage"]) {
23+
fs.rmSync(path.join(rootDir, dir), { recursive: true, force: true });
24+
}
25+
26+
for (const entry of fs.readdirSync(rootDir)) {
27+
if (entry.endsWith(".tgz")) {
28+
fs.rmSync(path.join(rootDir, entry));
29+
}
30+
}
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
const fs = require("fs");
2+
const path = require("path");
3+
4+
const rootDir = path.join(__dirname, "..");
5+
6+
// The tests resolve fixtures relative to __dirname, so they have to sit next to
7+
// the compiled test files rather than in the source tree.
8+
fs.cpSync(path.join(rootDir, "test"), path.join(rootDir, "dist-test", "test"), {
9+
recursive: true,
10+
filter: (src) => !src.endsWith(".ts"),
11+
});

packages/doctor/src/android-tools-info.ts

Lines changed: 0 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -658,20 +658,4 @@ export class AndroidToolsInfo implements NativeScriptDoctor.IAndroidToolsInfo {
658658
this._cachedRuntimeVersion = runtimeVersion;
659659
return runtimeVersion;
660660
}
661-
662-
private getMaxSupportedCompileVersion(
663-
config: Partial<NativeScriptDoctor.IProjectDir> & {
664-
runtimeVersion?: string;
665-
},
666-
): number {
667-
if (
668-
config.runtimeVersion &&
669-
semver.lt(semver.coerce(config.runtimeVersion), "6.1.0")
670-
) {
671-
return 28;
672-
}
673-
return this.parseAndroidSdkString(
674-
_.last(this.getSupportedTargets(config.projectDir).sort()),
675-
);
676-
}
677661
}

0 commit comments

Comments
 (0)