@lsbjordao/type-taxon-script 1.1.15 → 1.1.17
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/export.js +15 -2
- package/dist/exportOntology.js +36 -30
- package/dist/exportToCsv.js +15 -2
- package/package.json +1 -1
package/dist/export.js
CHANGED
|
@@ -17,6 +17,7 @@ const path_1 = __importDefault(require("path"));
|
|
|
17
17
|
const child_process_1 = require("child_process");
|
|
18
18
|
const csv_parser_1 = __importDefault(require("csv-parser"));
|
|
19
19
|
const cli_spinner_1 = require("cli-spinner");
|
|
20
|
+
const tscBin = require.resolve('typescript/bin/tsc');
|
|
20
21
|
function deleteJSFiles(folderPath) {
|
|
21
22
|
return __awaiter(this, void 0, void 0, function* () {
|
|
22
23
|
try {
|
|
@@ -84,7 +85,12 @@ console.log(jsonData)
|
|
|
84
85
|
const tempFilePath = './temp/exportTemp.ts';
|
|
85
86
|
fs_1.default.writeFileSync(tempFilePath, fileContent, 'utf-8');
|
|
86
87
|
const fileToTranspile = 'exportTemp';
|
|
87
|
-
|
|
88
|
+
const tempTsConfig = JSON.stringify({
|
|
89
|
+
compilerOptions: { target: 'ES2016', module: 'commonjs', esModuleInterop: true, skipLibCheck: true },
|
|
90
|
+
files: [`./${fileToTranspile}.ts`]
|
|
91
|
+
});
|
|
92
|
+
fs_1.default.writeFileSync('./temp/tsconfig.json', tempTsConfig, 'utf-8');
|
|
93
|
+
(0, child_process_1.exec)(`node "${tscBin}" -p ./temp/tsconfig.json`, (error, stdout, stderr) => {
|
|
88
94
|
if (stdout) {
|
|
89
95
|
spinner.stop();
|
|
90
96
|
console.error('\x1b[31m✖ TS Error:\x1b[0m\n\n' + `${stdout}`);
|
|
@@ -97,6 +103,7 @@ console.log(jsonData)
|
|
|
97
103
|
}
|
|
98
104
|
try {
|
|
99
105
|
fs_1.default.unlinkSync(`./temp/${fileToTranspile}.ts`);
|
|
106
|
+
fs_1.default.unlinkSync('./temp/tsconfig.json');
|
|
100
107
|
}
|
|
101
108
|
catch (err) {
|
|
102
109
|
spinner.stop();
|
|
@@ -176,7 +183,12 @@ console.log(jsonData)
|
|
|
176
183
|
// console.log('\\x1b[1m\\x1b[32m✔ Process finished.\\x1b[0m')`;
|
|
177
184
|
fs_1.default.writeFileSync(tempFilePath, fileContent, 'utf-8');
|
|
178
185
|
const fileToTranspile = 'exportTemp';
|
|
179
|
-
|
|
186
|
+
const tempTsConfig = JSON.stringify({
|
|
187
|
+
compilerOptions: { target: 'ES2016', module: 'commonjs', esModuleInterop: true, skipLibCheck: true },
|
|
188
|
+
files: [`./${fileToTranspile}.ts`]
|
|
189
|
+
});
|
|
190
|
+
fs_1.default.writeFileSync('./temp/tsconfig.json', tempTsConfig, 'utf-8');
|
|
191
|
+
(0, child_process_1.exec)(`node "${tscBin}" -p ./temp/tsconfig.json`, (error, stdout, stderr) => {
|
|
180
192
|
if (stdout) {
|
|
181
193
|
spinner.stop();
|
|
182
194
|
console.error('\x1b[31m✖ TS Error:\x1b[0m\n\n' + `${stdout}`);
|
|
@@ -189,6 +201,7 @@ console.log(jsonData)
|
|
|
189
201
|
}
|
|
190
202
|
try {
|
|
191
203
|
fs_1.default.unlinkSync(`./temp/${fileToTranspile}.ts`);
|
|
204
|
+
fs_1.default.unlinkSync('./temp/tsconfig.json');
|
|
192
205
|
}
|
|
193
206
|
catch (err) {
|
|
194
207
|
spinner.stop();
|
package/dist/exportOntology.js
CHANGED
|
@@ -1,27 +1,4 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
-
if (k2 === undefined) k2 = k;
|
|
4
|
-
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
-
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
-
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
-
}
|
|
8
|
-
Object.defineProperty(o, k2, desc);
|
|
9
|
-
}) : (function(o, m, k, k2) {
|
|
10
|
-
if (k2 === undefined) k2 = k;
|
|
11
|
-
o[k2] = m[k];
|
|
12
|
-
}));
|
|
13
|
-
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
-
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
-
}) : function(o, v) {
|
|
16
|
-
o["default"] = v;
|
|
17
|
-
});
|
|
18
|
-
var __importStar = (this && this.__importStar) || function (mod) {
|
|
19
|
-
if (mod && mod.__esModule) return mod;
|
|
20
|
-
var result = {};
|
|
21
|
-
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
22
|
-
__setModuleDefault(result, mod);
|
|
23
|
-
return result;
|
|
24
|
-
};
|
|
25
2
|
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
26
3
|
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
27
4
|
return new (P || (P = Promise))(function (resolve, reject) {
|
|
@@ -37,8 +14,10 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
37
14
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
38
15
|
const fs_1 = __importDefault(require("fs"));
|
|
39
16
|
const path_1 = __importDefault(require("path"));
|
|
17
|
+
const child_process_1 = require("child_process");
|
|
40
18
|
const fast_glob_1 = __importDefault(require("fast-glob"));
|
|
41
19
|
const n3_1 = require("n3");
|
|
20
|
+
const tscBin = require.resolve('typescript/bin/tsc');
|
|
42
21
|
const { namedNode, literal, quad, blankNode } = n3_1.DataFactory;
|
|
43
22
|
const NS = {
|
|
44
23
|
tts: 'https://tts.example.org/ontology/',
|
|
@@ -147,19 +126,46 @@ function primitiveToLiteral(value) {
|
|
|
147
126
|
return literal(String(value), xsd('boolean'));
|
|
148
127
|
}
|
|
149
128
|
function importModules(pattern) {
|
|
129
|
+
var _a, _b;
|
|
150
130
|
return __awaiter(this, void 0, void 0, function* () {
|
|
151
|
-
const
|
|
131
|
+
const tsFiles = yield (0, fast_glob_1.default)(pattern, { absolute: true });
|
|
132
|
+
if (tsFiles.length === 0)
|
|
133
|
+
return [];
|
|
134
|
+
const tempDir = path_1.default.join(process.cwd(), 'temp');
|
|
135
|
+
fs_1.default.mkdirSync(tempDir, { recursive: true });
|
|
136
|
+
const tempTsConfigPath = path_1.default.join(tempDir, 'tsconfig.ontology.json');
|
|
137
|
+
fs_1.default.writeFileSync(tempTsConfigPath, JSON.stringify({
|
|
138
|
+
compilerOptions: { target: 'ES2016', module: 'commonjs', esModuleInterop: true, skipLibCheck: true },
|
|
139
|
+
files: tsFiles
|
|
140
|
+
}), 'utf-8');
|
|
141
|
+
try {
|
|
142
|
+
(0, child_process_1.execSync)(`node "${tscBin}" -p "${tempTsConfigPath}"`);
|
|
143
|
+
}
|
|
144
|
+
catch (e) {
|
|
145
|
+
fs_1.default.unlinkSync(tempTsConfigPath);
|
|
146
|
+
throw new Error(((_a = e.stdout) === null || _a === void 0 ? void 0 : _a.toString()) || ((_b = e.stderr) === null || _b === void 0 ? void 0 : _b.toString()) || e.message);
|
|
147
|
+
}
|
|
148
|
+
fs_1.default.unlinkSync(tempTsConfigPath);
|
|
152
149
|
const modules = [];
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
150
|
+
const jsFiles = [];
|
|
151
|
+
for (const file of tsFiles) {
|
|
152
|
+
const jsFile = file.replace(/\.ts$/, '.js');
|
|
153
|
+
jsFiles.push(jsFile);
|
|
154
|
+
modules.push({ file, mod: require(jsFile) });
|
|
156
155
|
}
|
|
156
|
+
for (const jsFile of jsFiles) {
|
|
157
|
+
try {
|
|
158
|
+
fs_1.default.unlinkSync(jsFile);
|
|
159
|
+
}
|
|
160
|
+
catch ( /* ignore */_c) { /* ignore */ }
|
|
161
|
+
}
|
|
162
|
+
try {
|
|
163
|
+
fs_1.default.rmdirSync(tempDir);
|
|
164
|
+
}
|
|
165
|
+
catch ( /* ignore if not empty */_d) { /* ignore if not empty */ }
|
|
157
166
|
return modules;
|
|
158
167
|
});
|
|
159
168
|
}
|
|
160
|
-
function toFileUrl(filePath) {
|
|
161
|
-
return `file://${path_1.default.resolve(filePath)}`;
|
|
162
|
-
}
|
|
163
169
|
function inferRangeFromValue(value) {
|
|
164
170
|
if (typeof value === 'number')
|
|
165
171
|
return xsd('decimal');
|
package/dist/exportToCsv.js
CHANGED
|
@@ -18,6 +18,7 @@ const child_process_1 = require("child_process");
|
|
|
18
18
|
const csv_parser_1 = __importDefault(require("csv-parser"));
|
|
19
19
|
const plainjs_1 = require("@json2csv/plainjs");
|
|
20
20
|
const transforms_1 = require("@json2csv/transforms");
|
|
21
|
+
const tscBin = require.resolve('typescript/bin/tsc');
|
|
21
22
|
const cli_spinner_1 = require("cli-spinner");
|
|
22
23
|
function deleteJSFiles(folderPath) {
|
|
23
24
|
return __awaiter(this, void 0, void 0, function* () {
|
|
@@ -86,7 +87,12 @@ console.log(jsonData)
|
|
|
86
87
|
const tempFilePath = './temp/exportTemp.ts';
|
|
87
88
|
fs_1.default.writeFileSync(tempFilePath, fileContent, 'utf-8');
|
|
88
89
|
const fileToTranspile = 'exportTemp';
|
|
89
|
-
|
|
90
|
+
const tempTsConfig = JSON.stringify({
|
|
91
|
+
compilerOptions: { target: 'ES2016', module: 'commonjs', esModuleInterop: true, skipLibCheck: true },
|
|
92
|
+
files: [`./${fileToTranspile}.ts`]
|
|
93
|
+
});
|
|
94
|
+
fs_1.default.writeFileSync('./temp/tsconfig.json', tempTsConfig, 'utf-8');
|
|
95
|
+
(0, child_process_1.exec)(`node "${tscBin}" -p ./temp/tsconfig.json`, (error, stdout, stderr) => {
|
|
90
96
|
if (stdout) {
|
|
91
97
|
spinner.stop();
|
|
92
98
|
console.error('\x1b[31m✖ TS Error:\x1b[0m\n\n' + `${stdout}`);
|
|
@@ -99,6 +105,7 @@ console.log(jsonData)
|
|
|
99
105
|
}
|
|
100
106
|
try {
|
|
101
107
|
fs_1.default.unlinkSync(`./temp/${fileToTranspile}.ts`);
|
|
108
|
+
fs_1.default.unlinkSync('./temp/tsconfig.json');
|
|
102
109
|
}
|
|
103
110
|
catch (err) {
|
|
104
111
|
spinner.stop();
|
|
@@ -192,7 +199,12 @@ console.log(jsonData)
|
|
|
192
199
|
// console.log('\\x1b[1m\\x1b[32m✔ Process finished.\\x1b[0m')`;
|
|
193
200
|
fs_1.default.writeFileSync(tempFilePath, fileContent, 'utf-8');
|
|
194
201
|
const fileToTranspile = 'exportTemp';
|
|
195
|
-
|
|
202
|
+
const tempTsConfig = JSON.stringify({
|
|
203
|
+
compilerOptions: { target: 'ES2016', module: 'commonjs', esModuleInterop: true, skipLibCheck: true },
|
|
204
|
+
files: [`./${fileToTranspile}.ts`]
|
|
205
|
+
});
|
|
206
|
+
fs_1.default.writeFileSync('./temp/tsconfig.json', tempTsConfig, 'utf-8');
|
|
207
|
+
(0, child_process_1.exec)(`node "${tscBin}" -p ./temp/tsconfig.json`, (error, stdout, stderr) => {
|
|
196
208
|
if (stdout) {
|
|
197
209
|
spinner.stop();
|
|
198
210
|
console.error('\x1b[31m✖ TS Error:\x1b[0m\n\n' + `${stdout}`);
|
|
@@ -205,6 +217,7 @@ console.log(jsonData)
|
|
|
205
217
|
}
|
|
206
218
|
try {
|
|
207
219
|
fs_1.default.unlinkSync(`./temp/${fileToTranspile}.ts`);
|
|
220
|
+
fs_1.default.unlinkSync('./temp/tsconfig.json');
|
|
208
221
|
}
|
|
209
222
|
catch (err) {
|
|
210
223
|
spinner.stop();
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@lsbjordao/type-taxon-script",
|
|
3
|
-
"version": "1.1.
|
|
3
|
+
"version": "1.1.17",
|
|
4
4
|
"author": "Lucas Jordão <tucarj@gmail.com> & André Eppinghaus <andreeppinghaus@gmail.com> & Vicente Calfo <vicentecalfo@gmail.com>",
|
|
5
5
|
"license": "ISC",
|
|
6
6
|
"description": "TypeTaxonScript",
|