Skip to content

Commit 1adaf8f

Browse files
committed
Create a package for the non-included TypeScript declarations
Find out the missed TypeScript declarations in the package Clean the package.json from devDeps Pack and copy the platform declarations Set version to 1.7.1
1 parent 16c3fb2 commit 1adaf8f

File tree

4 files changed

+186
-0
lines changed

4 files changed

+186
-0
lines changed
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
/diffs/
2+
/actuals/
3+
/extracted/
4+
*.tgz
Lines changed: 141 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,141 @@
1+
module.exports = function(grunt) {
2+
3+
var fsModule = require("fs");
4+
5+
function cleanDeps(content, srcPath) {
6+
var contentAsJson = JSON.parse(content);
7+
delete contentAsJson.devDependencies;
8+
return JSON.stringify(contentAsJson, null, "\t");
9+
}
10+
11+
function isDiff(content, srcPath) {
12+
var relativePath = srcPath.replace(/actuals\//, "");
13+
var extractedRelativePath = "extracted/package/" + relativePath;
14+
grunt.log.fail(extractedRelativePath);
15+
try {
16+
if (fsModule.statSync(extractedRelativePath)) {
17+
return false;
18+
}
19+
} catch (ex) {
20+
if (content.match(/\s*\/\/@private.*/)) {
21+
return false;
22+
}
23+
return content;
24+
}
25+
26+
return false;
27+
}
28+
29+
grunt.initConfig({
30+
copy: {
31+
package: {
32+
src: "../../bin/dist/tns-core-modules*.tgz",
33+
dest: "./tns-core-modules.tgz"
34+
},
35+
packagejson: {
36+
expand: true,
37+
src: "./package.json",
38+
dest: "./diffs/",
39+
options: {
40+
process: cleanDeps
41+
}
42+
},
43+
actualDeclaraions: {
44+
expand: true,
45+
src: [
46+
"**/*.d.ts",
47+
"!bin/**/*.*",
48+
"!.git/**/*.*",
49+
"!node_modules/**/*.*",
50+
"!apps/**/*.*",
51+
"!node-tests/**/*.*",
52+
"!**/*.android.d.ts",
53+
"!**/*.ios.d.ts",
54+
"!build/**/*.*"
55+
],
56+
dest: "./actuals",
57+
cwd: "../../"
58+
},
59+
differentNoPrivateFiles: {
60+
expand: true,
61+
src: "./**/*.*",
62+
dest: "./diffs/",
63+
cwd: "./actuals",
64+
options: {
65+
process: isDiff
66+
}
67+
},
68+
packeddeclarations: {
69+
expand: true,
70+
src: "./*.tgz",
71+
dest: "./",
72+
cwd: "./diffs"
73+
}
74+
},
75+
shell: {
76+
unpackPackage: {
77+
command: "tar -zxvf tns-core-modules.tgz -C ./extracted"
78+
},
79+
createExtractedDir: {
80+
command: "mkdir ./extracted"
81+
},
82+
createActualsDir: {
83+
command: "mkdir ./actuals"
84+
},
85+
createDiffsDir: {
86+
command: "mkdir ./diffs"
87+
},
88+
packdeclarations: {
89+
command: "npm pack",
90+
options: {
91+
execOptions: {
92+
cwd: "./diffs"
93+
}
94+
}
95+
}
96+
},
97+
clean: {
98+
package: {
99+
src: "./tns-core-modules.tgz"
100+
},
101+
extractedDir: {
102+
src: "./extracted"
103+
},
104+
actualsDir: {
105+
src: "./actuals"
106+
},
107+
diffsDir: {
108+
src: ["./diffs/**/*.*", "./diffs"]
109+
},
110+
extractedNonDeclarations: {
111+
src: ["./extracted/**/*.*", "!./extracted/**/*.d.ts"]
112+
}
113+
}
114+
});
115+
116+
grunt.loadNpmTasks("grunt-shell");
117+
grunt.loadNpmTasks("grunt-contrib-copy");
118+
grunt.loadNpmTasks("grunt-contrib-clean");
119+
120+
grunt.registerTask("default", [
121+
"clean:extractedDir",
122+
"clean:actualsDir",
123+
"clean:diffsDir",
124+
"clean:package",
125+
"copy:package",
126+
"shell:createExtractedDir",
127+
"shell:unpackPackage",
128+
"clean:package",
129+
"clean:extractedNonDeclarations",
130+
"shell:createActualsDir",
131+
"copy:actualDeclaraions",
132+
"shell:createDiffsDir",
133+
"copy:differentNoPrivateFiles",
134+
"clean:extractedDir",
135+
"clean:actualsDir",
136+
"copy:packagejson",
137+
"shell:packdeclarations",
138+
"copy:packeddeclarations",
139+
"clean:diffsDir",
140+
]);
141+
}
Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
{
2+
"name": "tns-platform-declarations",
3+
"version": "1.7.1",
4+
"description": "Platform-specific TypeScript declarations for NativeScript for accessing native objects",
5+
"main": "",
6+
"scripts": {
7+
"test": "echo \"Error: no test specified\" && exit 1"
8+
},
9+
"repository": {
10+
"type": "git",
11+
"url": "git+ssh://git@github.com/NativeScript/NativeScript.git"
12+
},
13+
"keywords": [
14+
"NativeScript",
15+
"TypeScript",
16+
"declarations",
17+
"native",
18+
"platform-specific",
19+
"tns",
20+
"ts",
21+
"ns"
22+
],
23+
"author": {
24+
"name": "Telerik",
25+
"email": "support@telerik.com",
26+
"url": "http://www.telerik.com"
27+
},
28+
"license": "Apache-2.0",
29+
"bugs": {
30+
"url": "https://github.com/NativeScript/NativeScript/issues"
31+
},
32+
"homepage": "https://github.com/NativeScript/NativeScript#readme",
33+
"devDependencies": {
34+
"grunt": "^0.4.5",
35+
"grunt-contrib-clean": "^0.7.0",
36+
"grunt-contrib-copy": "git+https://github.com/ErjanGavalji/grunt-contrib-copy.git#1c976a133210be4ce8c96313f5daf14833f7f8f9",
37+
"grunt-shell": "^1.1.2"
38+
}
39+
}

build/platform-declarations/run.sh

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
#!/usr/bin/env bash
2+
grunt --verbose

0 commit comments

Comments
 (0)