datagrok-tools 6.6.0 → 6.7.1
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/.devcontainer/entrypoint.sh +0 -0
- package/.turbo/turbo-build.log +5 -0
- package/CHANGELOG.md +11 -1
- package/CLAUDE.md +5 -6
- package/GROK_S.md +10 -2
- package/LICENSE.md +16 -0
- package/README.md +5 -3
- package/bin/commands/build.js +123 -139
- package/bin/commands/check.js +3 -4
- package/bin/commands/config.js +4 -2
- package/bin/commands/create.js +37 -11
- package/bin/commands/help.js +85 -17
- package/bin/commands/link.js +10 -0
- package/bin/commands/login.js +213 -0
- package/bin/commands/publish.js +26 -23
- package/bin/commands/server.js +7 -1
- package/bin/commands/setup.js +139 -0
- package/bin/commands/stress-tests.js +3 -1
- package/bin/commands/tsc.js +26 -0
- package/bin/grok.js +34 -20
- package/bin/utils/color-utils.js +30 -1
- package/bin/utils/dev-key.js +45 -5
- package/bin/utils/keypair.js +292 -0
- package/bin/utils/node-dapi.js +20 -6
- package/bin/utils/playwright-runner.js +9 -3
- package/bin/utils/server-client.js +6 -7
- package/bin/utils/test-utils.js +19 -1
- package/bin/utils/toolchain.js +121 -0
- package/bin/utils/utils.js +9 -0
- package/package-template/.vscode/tasks.json +1 -1
- package/package-template/package.json +9 -14
- package/package-template/tsconfig.json +2 -69
- package/package.json +17 -17
- package/plugins/func-gen-plugin.js +9 -4
- package/turbo.json +9 -0
- package/package-template/.eslintrc.json +0 -38
- package/package-template/ts.webpack.config.js +0 -46
- package/package-template/webpack.config.js +0 -35
package/bin/utils/node-dapi.js
CHANGED
|
@@ -11,6 +11,7 @@ exports.mapPositionalParams = mapPositionalParams;
|
|
|
11
11
|
exports.parseDomainAddress = parseDomainAddress;
|
|
12
12
|
exports.throwIfApiError = throwIfApiError;
|
|
13
13
|
var _crypto = require("crypto");
|
|
14
|
+
var _keypair = require("./keypair");
|
|
14
15
|
/// Docs: [Grok Dapi](/docs/plans/grok-dapi/)
|
|
15
16
|
|
|
16
17
|
function ensureBodyId(body) {
|
|
@@ -62,12 +63,25 @@ async function fetchOrRetry(url, opts, retriable, timeoutMs = setting('TIMEOUT',
|
|
|
62
63
|
class NodeApiClient {
|
|
63
64
|
/** Set by `createClient` when the run asked for an admin session, so a re-login restores it. */
|
|
64
65
|
adminMode = false;
|
|
65
|
-
constructor(baseUrl, token, devKey) {
|
|
66
|
+
constructor(baseUrl, token, devKey, privateKey) {
|
|
66
67
|
this.baseUrl = baseUrl;
|
|
67
68
|
this.token = token;
|
|
68
69
|
this.devKey = devKey;
|
|
70
|
+
this.privateKey = privateKey;
|
|
69
71
|
}
|
|
70
|
-
|
|
72
|
+
|
|
73
|
+
/** [privateKey] from a caller that resolved it by alias; otherwise it is looked up by URL. */
|
|
74
|
+
static async login(baseUrl, devKey, privateKey) {
|
|
75
|
+
privateKey ??= (0, _keypair.keypairFor)(baseUrl, devKey);
|
|
76
|
+
if (privateKey) {
|
|
77
|
+
try {
|
|
78
|
+
return new NodeApiClient(baseUrl, await (0, _keypair.keyLogin)(baseUrl, privateKey), devKey, privateKey);
|
|
79
|
+
} catch (e) {
|
|
80
|
+
// A server without the keypair endpoints is a reason to use the developer key that is
|
|
81
|
+
// still configured, not to stop: the same config often names stands of both vintages.
|
|
82
|
+
if (e?.name !== 'ServerTooOldError' || !devKey) throw e;
|
|
83
|
+
}
|
|
84
|
+
}
|
|
71
85
|
// Servers before 1.28 only knew the key-in-URL form, where it leaked into every
|
|
72
86
|
// access log on the way; they answer 404 or 401 to the key-less route.
|
|
73
87
|
let res = await fetch(`${baseUrl}/users/login/dev`, {
|
|
@@ -87,12 +101,12 @@ class NodeApiClient {
|
|
|
87
101
|
|
|
88
102
|
/**
|
|
89
103
|
* A stand serving several isolates can reject a session one of them does not know, and an
|
|
90
|
-
* hour-long walk has no way to ask the operator to log in again. The
|
|
91
|
-
* for a new session, so one is taken rather than losing the run.
|
|
104
|
+
* hour-long walk has no way to ask the operator to log in again. The keypair (or the
|
|
105
|
+
* developer key) is good for a new session, so one is taken rather than losing the run.
|
|
92
106
|
*/
|
|
93
107
|
async reauthenticate() {
|
|
94
|
-
if (!this.devKey) return false;
|
|
95
|
-
const fresh = await NodeApiClient.login(this.baseUrl, this.devKey).catch(() => null);
|
|
108
|
+
if (!this.devKey && !this.privateKey) return false;
|
|
109
|
+
const fresh = await NodeApiClient.login(this.baseUrl, this.devKey, this.privateKey).catch(() => null);
|
|
96
110
|
if (!fresh) return false;
|
|
97
111
|
this.token = fresh.token;
|
|
98
112
|
if (this.adminMode) this.token = (await fresh.post('/users/sessions/current/admin'))?.token ?? this.token;
|
|
@@ -12,6 +12,7 @@ var _path = _interopRequireDefault(require("path"));
|
|
|
12
12
|
var _papaparse = _interopRequireDefault(require("papaparse"));
|
|
13
13
|
var color = _interopRequireWildcard(require("./color-utils"));
|
|
14
14
|
var testUtils = _interopRequireWildcard(require("./test-utils"));
|
|
15
|
+
var keypair = _interopRequireWildcard(require("./keypair"));
|
|
15
16
|
function _interopRequireWildcard(e, t) { if ("function" == typeof WeakMap) var r = new WeakMap(), n = new WeakMap(); return (_interopRequireWildcard = function (e, t) { if (!t && e && e.__esModule) return e; var o, i, f = { __proto__: null, default: e }; if (null === e || "object" != typeof e && "function" != typeof e) return f; if (o = t ? n : r) { if (o.has(e)) return o.get(e); o.set(e, f); } for (const t in e) "default" !== t && {}.hasOwnProperty.call(e, t) && ((i = (o = Object.defineProperty) && Object.getOwnPropertyDescriptor(e, t)) && (i.get || i.set) ? o(f, t, i) : f[t] = e[t]); return f; })(e, t); }
|
|
16
17
|
function hasPlaywrightTests(pkgDir) {
|
|
17
18
|
const pkgJsonPath = _path.default.join(pkgDir, 'package.json');
|
|
@@ -159,12 +160,17 @@ async function runPlaywrightTests(pkgDir, testDir, args, hostKey) {
|
|
|
159
160
|
} catch {
|
|
160
161
|
webUrl = url.replace(/\/api\/?$/, '');
|
|
161
162
|
}
|
|
163
|
+
|
|
164
|
+
// The second user the multi-user specs need. Its keypair wins over its developer key,
|
|
165
|
+
// the same way the first user's does; both are explicit, so neither picks up the
|
|
166
|
+
// configured identity by accident.
|
|
162
167
|
let token2 = '';
|
|
163
|
-
|
|
168
|
+
const privateKey2 = keypair.keyFromEnv('DATAGROK_PRIVATE_KEY_2');
|
|
169
|
+
if (privateKey2 || process.env.DATAGROK_DEV_KEY_2) {
|
|
164
170
|
try {
|
|
165
|
-
token2 = await testUtils.getToken(url, process.env.DATAGROK_DEV_KEY_2);
|
|
171
|
+
token2 = privateKey2 ? await keypair.keyLogin(url, privateKey2) : await testUtils.getToken(url, process.env.DATAGROK_DEV_KEY_2);
|
|
166
172
|
} catch (e) {
|
|
167
|
-
color.warn(`Playwright:
|
|
173
|
+
color.warn(`Playwright: second-user credentials set but failed to exchange for token: ${e.message || e}`);
|
|
168
174
|
}
|
|
169
175
|
}
|
|
170
176
|
const configPath = _path.default.join(testDir, 'playwright.config.ts');
|
|
@@ -5,7 +5,7 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
5
5
|
});
|
|
6
6
|
exports.createClient = createClient;
|
|
7
7
|
var _nodeDapi = require("./node-dapi");
|
|
8
|
-
var
|
|
8
|
+
var _keypair = require("./keypair");
|
|
9
9
|
/**
|
|
10
10
|
* `--admin` asks the server for an admin session, which lifts the permission filter for this run:
|
|
11
11
|
* without it a stand-wide pull sees only what the key's own account can, and content in other
|
|
@@ -14,14 +14,13 @@ var _testUtils = require("./test-utils");
|
|
|
14
14
|
* the command or reach another session.
|
|
15
15
|
*/
|
|
16
16
|
async function createClient(hostArg, admin = false) {
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
const client = await _nodeDapi.NodeApiClient.login(url, key);
|
|
17
|
+
// Resolved from the alias the caller named, not from its URL: two aliases can point at the
|
|
18
|
+
// same server, and only this side knows which one was asked for.
|
|
19
|
+
const cred = (0, _keypair.getServerCredentials)(hostArg ?? '');
|
|
20
|
+
const client = await _nodeDapi.NodeApiClient.login(cred.url, cred.key ?? '', cred.privateKey);
|
|
22
21
|
if (!admin) return client;
|
|
23
22
|
const token = (await client.post('/users/sessions/current/admin'))?.token;
|
|
24
|
-
if (!token) throw new Error(`${url} refused an admin session — the account behind this key cannot start one`);
|
|
23
|
+
if (!token) throw new Error(`${cred.url} refused an admin session — the account behind this key cannot start one`);
|
|
25
24
|
client.token = token;
|
|
26
25
|
client.adminMode = true;
|
|
27
26
|
return client;
|
package/bin/utils/test-utils.js
CHANGED
|
@@ -36,6 +36,7 @@ var _puppeteer = _interopRequireDefault(require("puppeteer"));
|
|
|
36
36
|
var color = _interopRequireWildcard(require("../utils/color-utils"));
|
|
37
37
|
var _papaparse = _interopRequireDefault(require("papaparse"));
|
|
38
38
|
var _devKey = require("./dev-key");
|
|
39
|
+
var keypair = _interopRequireWildcard(require("./keypair"));
|
|
39
40
|
function _interopRequireWildcard(e, t) { if ("function" == typeof WeakMap) var r = new WeakMap(), n = new WeakMap(); return (_interopRequireWildcard = function (e, t) { if (!t && e && e.__esModule) return e; var o, i, f = { __proto__: null, default: e }; if (null === e || "object" != typeof e && "function" != typeof e) return f; if (o = t ? n : r) { if (o.has(e)) return o.get(e); o.set(e, f); } for (const t in e) "default" !== t && {}.hasOwnProperty.call(e, t) && ((i = (o = Object.defineProperty) && Object.getOwnPropertyDescriptor(e, t)) && (i.get || i.set) ? o(f, t, i) : f[t] = e[t]); return f; })(e, t); }
|
|
40
41
|
const fetch = require('node-fetch');
|
|
41
42
|
const grokDir = _path.default.join(_os.default.homedir(), '.grok');
|
|
@@ -55,9 +56,24 @@ async function getToken(url, key) {
|
|
|
55
56
|
// auth failure (valid JSON with isSuccess=false) is returned immediately, no retry.
|
|
56
57
|
const maxAttempts = 15;
|
|
57
58
|
const delayMs = 3000;
|
|
59
|
+
// Keypair login is the supported path; the developer key remains as a fallback
|
|
60
|
+
// for stands and CI secrets that have not been migrated yet — including when a key is
|
|
61
|
+
// configured but that stand does not know it, which must not take the run down while a
|
|
62
|
+
// working dev key is right there.
|
|
63
|
+
let privateKey = keypair.keypairFor(url, key);
|
|
58
64
|
let lastError;
|
|
59
65
|
for (let attempt = 1; attempt <= maxAttempts; attempt++) {
|
|
60
66
|
try {
|
|
67
|
+
if (privateKey) {
|
|
68
|
+
try {
|
|
69
|
+
return await keypair.keyLogin(url, privateKey);
|
|
70
|
+
} catch (error) {
|
|
71
|
+
const refused = error?.name === 'ServerTooOldError' || error?.message?.startsWith('Key login failed');
|
|
72
|
+
if (!key || !refused) throw error;
|
|
73
|
+
color.warn(`${url}: ${error.message} Falling back to the developer key.`);
|
|
74
|
+
privateKey = undefined;
|
|
75
|
+
}
|
|
76
|
+
}
|
|
61
77
|
const response = await (0, _devKey.devKeyFetch)(`${url}/users/login/dev`, `${url}/users/login/dev/${key}`, key, {
|
|
62
78
|
method: 'POST'
|
|
63
79
|
});
|
|
@@ -80,12 +96,14 @@ async function getToken(url, key) {
|
|
|
80
96
|
throw new Error('Unable to login to server. Check your dev key');
|
|
81
97
|
} catch (error) {
|
|
82
98
|
if (error?.message === 'Unable to login to server. Check your dev key') throw error;
|
|
99
|
+
// A rejected signature is a credential problem, not a readiness one.
|
|
100
|
+
if (error?.message?.startsWith('Key login failed')) throw error;
|
|
83
101
|
lastError = error;
|
|
84
102
|
if (utils.isConnectivityError(error)) color.warn(`Playwright: server not reachable yet (attempt ${attempt}/${maxAttempts}): ${url}`);
|
|
85
103
|
if (attempt < maxAttempts) await new Promise(r => setTimeout(r, delayMs));
|
|
86
104
|
}
|
|
87
105
|
}
|
|
88
|
-
throw lastError ?? new Error(`Unable to
|
|
106
|
+
throw lastError ?? new Error(`Unable to obtain a token from ${url}`);
|
|
89
107
|
}
|
|
90
108
|
async function isPackageOnServer(hostKey, packageName) {
|
|
91
109
|
try {
|
|
@@ -0,0 +1,121 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
+
Object.defineProperty(exports, "__esModule", {
|
|
5
|
+
value: true
|
|
6
|
+
});
|
|
7
|
+
exports.copyLibraryAssets = copyLibraryAssets;
|
|
8
|
+
exports.ensureLibraryExports = ensureLibraryExports;
|
|
9
|
+
exports.toolchain = toolchain;
|
|
10
|
+
var _fs = _interopRequireDefault(require("fs"));
|
|
11
|
+
var _path = _interopRequireDefault(require("path"));
|
|
12
|
+
/**
|
|
13
|
+
* The shared toolchain (`@datagrok/build-config`: rspack factory, TypeScript) as seen from `dir`:
|
|
14
|
+
* the workspace root's copy inside public/, the package's own devDependency in a standalone package.
|
|
15
|
+
*/
|
|
16
|
+
function toolchain(dir) {
|
|
17
|
+
let pkgJson;
|
|
18
|
+
try {
|
|
19
|
+
pkgJson = require.resolve('@datagrok/build-config/package.json', {
|
|
20
|
+
paths: [dir]
|
|
21
|
+
});
|
|
22
|
+
} catch {
|
|
23
|
+
throw new Error('@datagrok/build-config is not installed: run `pnpm install` at the root of public/, ' + 'or add it as a devDependency of a standalone package');
|
|
24
|
+
}
|
|
25
|
+
const buildConfigDir = _path.default.dirname(pkgJson);
|
|
26
|
+
const tsPkg = require.resolve('typescript/package.json', {
|
|
27
|
+
paths: [buildConfigDir]
|
|
28
|
+
});
|
|
29
|
+
return {
|
|
30
|
+
buildConfig: require(buildConfigDir),
|
|
31
|
+
buildConfigDir,
|
|
32
|
+
tsc: _path.default.join(_path.default.dirname(tsPkg), 'bin', 'tsc')
|
|
33
|
+
};
|
|
34
|
+
}
|
|
35
|
+
const ASSET = /\.(css|scss|wasm|js|mjs|cjs|json|png|jpe?g|gif|svg|txt|csv|md|html|sdf|mol)$/i;
|
|
36
|
+
|
|
37
|
+
/**
|
|
38
|
+
* A library's dist/ must be self-contained: the css, wasm, json and plain-js files its sources
|
|
39
|
+
* import relative to themselves are mirrored next to the compiled output. A .js next to a .ts of
|
|
40
|
+
* the same name is a stale in-place compile, not an asset.
|
|
41
|
+
*/
|
|
42
|
+
function copyLibraryAssets(dir) {
|
|
43
|
+
if (!_fs.default.existsSync(_path.default.join(dir, 'dist'))) return 0;
|
|
44
|
+
let n = 0;
|
|
45
|
+
const walk = rel => {
|
|
46
|
+
for (const e of _fs.default.readdirSync(_path.default.join(dir, rel), {
|
|
47
|
+
withFileTypes: true
|
|
48
|
+
})) {
|
|
49
|
+
if (e.name === 'node_modules' || e.name === 'dist' || e.name.startsWith('.')) continue;
|
|
50
|
+
const r = rel ? `${rel}/${e.name}` : e.name;
|
|
51
|
+
if (e.isDirectory()) walk(r);else if (rel && ASSET.test(e.name) && e.name !== 'package.json' && !isCompiledSibling(dir, r)) {
|
|
52
|
+
const to = _path.default.join(dir, 'dist', r);
|
|
53
|
+
_fs.default.mkdirSync(_path.default.dirname(to), {
|
|
54
|
+
recursive: true
|
|
55
|
+
});
|
|
56
|
+
const from = _path.default.join(dir, r);
|
|
57
|
+
if (!_fs.default.existsSync(to) || _fs.default.statSync(to).mtimeMs < _fs.default.statSync(from).mtimeMs) {
|
|
58
|
+
_fs.default.copyFileSync(from, to);
|
|
59
|
+
n++;
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
};
|
|
64
|
+
walk('');
|
|
65
|
+
if (n) console.log(`copied ${n} asset file(s) into dist/`);
|
|
66
|
+
return n;
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
/**
|
|
70
|
+
* Keeps a library's package.json `exports` in step with its source tree. A library that ships dist/
|
|
71
|
+
* has an `exports` map ending in the `./*` wildcard; the wildcard cannot resolve a directory import
|
|
72
|
+
* (`@datagrok-libraries/bio/src/trees`), so every directory with an index.ts needs an explicit entry.
|
|
73
|
+
* Adds the missing ones and leaves everything else (hand-written entries, the wildcards, entries for
|
|
74
|
+
* directories that no longer exist) untouched. Packages without the wildcard are not managed.
|
|
75
|
+
*/
|
|
76
|
+
function ensureLibraryExports(dir) {
|
|
77
|
+
const pj = _path.default.join(dir, 'package.json');
|
|
78
|
+
const p = JSON.parse(_fs.default.readFileSync(pj, 'utf8'));
|
|
79
|
+
const ex = p.exports;
|
|
80
|
+
if (!ex || typeof ex !== 'object' || !ex['./*']) return false;
|
|
81
|
+
const indexDirs = new Set();
|
|
82
|
+
const walk = (d, rel) => {
|
|
83
|
+
for (const e of _fs.default.readdirSync(d, {
|
|
84
|
+
withFileTypes: true
|
|
85
|
+
})) {
|
|
86
|
+
if (e.name === 'node_modules' || e.name === 'dist' || e.name.startsWith('.')) continue;
|
|
87
|
+
const r = rel ? `${rel}/${e.name}` : e.name;
|
|
88
|
+
if (e.isDirectory()) walk(_path.default.join(d, e.name), r);else if (e.name === 'index.ts' && rel) indexDirs.add(rel);
|
|
89
|
+
}
|
|
90
|
+
};
|
|
91
|
+
walk(dir, '');
|
|
92
|
+
// Add-only: hand-written entries (aliases such as js-api's "./u2core") are never touched.
|
|
93
|
+
const next = {
|
|
94
|
+
...ex
|
|
95
|
+
};
|
|
96
|
+
let changed = false;
|
|
97
|
+
for (const rel of [...indexDirs].sort()) {
|
|
98
|
+
const key = `./${rel}`;
|
|
99
|
+
if (!(key in next)) {
|
|
100
|
+
next[key] = {
|
|
101
|
+
types: `./dist/${rel}/index.d.ts`,
|
|
102
|
+
default: `./dist/${rel}/index.js`
|
|
103
|
+
};
|
|
104
|
+
changed = true;
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
if (!changed) return false;
|
|
108
|
+
// wildcards last: exports are matched by specificity, but keeping them last reads better
|
|
109
|
+
const wild = ['./*.js', './*'].filter(k => k in next);
|
|
110
|
+
const ordered = {};
|
|
111
|
+
for (const [k, v] of Object.entries(next)) if (!wild.includes(k)) ordered[k] = v;
|
|
112
|
+
for (const k of wild) ordered[k] = next[k];
|
|
113
|
+
p.exports = ordered;
|
|
114
|
+
_fs.default.writeFileSync(pj, JSON.stringify(p, null, 2) + '\n');
|
|
115
|
+
console.log(`package.json exports updated for ${_path.default.basename(dir)}`);
|
|
116
|
+
return true;
|
|
117
|
+
}
|
|
118
|
+
function isCompiledSibling(dir, rel) {
|
|
119
|
+
const m = rel.match(/^(.*)\.(js|mjs|cjs)$/);
|
|
120
|
+
return !!m && ['.ts', '.tsx'].some(e => _fs.default.existsSync(_path.default.join(dir, m[1] + e)));
|
|
121
|
+
}
|
package/bin/utils/utils.js
CHANGED
|
@@ -23,6 +23,7 @@ exports.headerTags = void 0;
|
|
|
23
23
|
exports.isConnectivityError = isConnectivityError;
|
|
24
24
|
exports.isEmpty = isEmpty;
|
|
25
25
|
exports.isPackageDir = isPackageDir;
|
|
26
|
+
exports.isPnpmWorkspace = isPnpmWorkspace;
|
|
26
27
|
exports.isValidCron = isValidCron;
|
|
27
28
|
exports.jsExtention = void 0;
|
|
28
29
|
exports.kebabToCamelCase = kebabToCamelCase;
|
|
@@ -301,6 +302,14 @@ function isConnectivityError(error) {
|
|
|
301
302
|
const msg = (error?.message ?? '').toLowerCase() + ' ' + (error?.code ?? '').toLowerCase();
|
|
302
303
|
return ['econnrefused', 'enotfound', 'etimedout', 'eai_again', 'econnreset', 'fetch failed', 'network error'].some(token => msg.includes(token));
|
|
303
304
|
}
|
|
305
|
+
|
|
306
|
+
/** True when `dir` is inside a pnpm workspace (a pnpm-workspace.yaml in it or above it). */
|
|
307
|
+
function isPnpmWorkspace(dir) {
|
|
308
|
+
for (let d = _path.default.resolve(dir);; d = _path.default.dirname(d)) {
|
|
309
|
+
if (_fs.default.existsSync(_path.default.join(d, 'pnpm-workspace.yaml'))) return true;
|
|
310
|
+
if (_path.default.dirname(d) === d) return false;
|
|
311
|
+
}
|
|
312
|
+
}
|
|
304
313
|
async function runScript(script, path, verbose = false) {
|
|
305
314
|
try {
|
|
306
315
|
const {
|
|
@@ -4,21 +4,16 @@
|
|
|
4
4
|
"version": "0.0.1",
|
|
5
5
|
"description": "#{PACKAGE_NAME} package",
|
|
6
6
|
"dependencies": {
|
|
7
|
-
"datagrok-api": "
|
|
8
|
-
"cash-dom": "
|
|
9
|
-
"dayjs": "
|
|
10
|
-
"
|
|
11
|
-
|
|
12
|
-
"devDependencies": {
|
|
13
|
-
"datagrok-tools": "^5.1.5",
|
|
14
|
-
"webpack": "^5.95.0",
|
|
15
|
-
"webpack-cli": "^5.1.4"
|
|
7
|
+
"datagrok-api": "workspace:^",
|
|
8
|
+
"cash-dom": "catalog:",
|
|
9
|
+
"dayjs": "catalog:",
|
|
10
|
+
"rxjs": "catalog:",
|
|
11
|
+
"@datagrok-libraries/test": "workspace:^"
|
|
16
12
|
},
|
|
17
13
|
"scripts": {
|
|
18
|
-
"
|
|
19
|
-
"
|
|
20
|
-
"
|
|
21
|
-
"build": "grok api && grok check --soft && webpack",
|
|
14
|
+
"build": "grok build",
|
|
15
|
+
"typecheck": "grok tsc --noEmit -p tsconfig.json",
|
|
16
|
+
"lint": "eslint --ext .ts,.tsx src",
|
|
22
17
|
"test": "grok test"
|
|
23
18
|
},
|
|
24
19
|
"canEdit": [
|
|
@@ -27,4 +22,4 @@
|
|
|
27
22
|
"canView": [
|
|
28
23
|
"All users"
|
|
29
24
|
]
|
|
30
|
-
}
|
|
25
|
+
}
|
|
@@ -1,71 +1,4 @@
|
|
|
1
1
|
{
|
|
2
|
-
"
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
/* Basic Options */
|
|
6
|
-
// "incremental": true, /* Enable incremental compilation */
|
|
7
|
-
"target": "es6", /* Specify ECMAScript target version: 'ES3' (default), 'ES5', 'ES2015', 'ES2016', 'ES2017', 'ES2018', 'ES2019', 'ES2020', or 'ESNEXT'. */
|
|
8
|
-
"module": "es2020", /* Specify module code generation: 'none', 'commonjs', 'amd', 'system', 'umd', 'es2015', 'es2020', or 'ESNext'. */
|
|
9
|
-
"lib": ["ES2022", "dom"], /* Specify library files to be included in the compilation. */
|
|
10
|
-
// "allowJs": true, /* Allow javascript files to be compiled. */
|
|
11
|
-
// "checkJs": true, /* Report errors in .js files. */
|
|
12
|
-
// "jsx": "preserve", /* Specify JSX code generation: 'preserve', 'react-native', 'react', 'react-jsx' or 'react-jsxdev'. */
|
|
13
|
-
// "declaration": true, /* Generates corresponding '.d.ts' file. */
|
|
14
|
-
// "declarationMap": true, /* Generates a sourcemap for each corresponding '.d.ts' file. */
|
|
15
|
-
"sourceMap": true, /* Generates corresponding '.map' file. */
|
|
16
|
-
// "outFile": "./", /* Concatenate and emit output to single file. */
|
|
17
|
-
// "outDir": "./", /* Redirect output structure to the directory. */
|
|
18
|
-
// "rootDir": "./", /* Specify the root directory of input files. Use to control the output directory structure with --outDir. */
|
|
19
|
-
// "composite": true, /* Enable project compilation */
|
|
20
|
-
// "tsBuildInfoFile": "./", /* Specify file to store incremental compilation information */
|
|
21
|
-
// "removeComments": true, /* Do not emit comments to output. */
|
|
22
|
-
// "noEmit": true, /* Do not emit outputs. */
|
|
23
|
-
// "importHelpers": true, /* Import emit helpers from 'tslib'. */
|
|
24
|
-
// "downlevelIteration": true, /* Provide full support for iterables in 'for-of', spread, and destructuring when targeting 'ES5' or 'ES3'. */
|
|
25
|
-
// "isolatedModules": true, /* Transpile each file as a separate module (similar to 'ts.transpileModule'). */
|
|
26
|
-
|
|
27
|
-
/* Strict Type-Checking Options */
|
|
28
|
-
"strict": true, /* Enable all strict type-checking options. */
|
|
29
|
-
// "noImplicitAny": true, /* Raise error on expressions and declarations with an implied 'any' type. */
|
|
30
|
-
// "strictNullChecks": true, /* Enable strict null checks. */
|
|
31
|
-
// "strictFunctionTypes": true, /* Enable strict checking of function types. */
|
|
32
|
-
// "strictBindCallApply": true, /* Enable strict 'bind', 'call', and 'apply' methods on functions. */
|
|
33
|
-
// "strictPropertyInitialization": true, /* Enable strict checking of property initialization in classes. */
|
|
34
|
-
// "noImplicitThis": true, /* Raise error on 'this' expressions with an implied 'any' type. */
|
|
35
|
-
// "alwaysStrict": true, /* Parse in strict mode and emit "use strict" for each source file. */
|
|
36
|
-
|
|
37
|
-
/* Additional Checks */
|
|
38
|
-
// "noUnusedLocals": true, /* Report errors on unused locals. */
|
|
39
|
-
// "noUnusedParameters": true, /* Report errors on unused parameters. */
|
|
40
|
-
// "noImplicitReturns": true, /* Report error when not all code paths in function return a value. */
|
|
41
|
-
// "noFallthroughCasesInSwitch": true, /* Report errors for fallthrough cases in switch statement. */
|
|
42
|
-
// "noUncheckedIndexedAccess": true, /* Include 'undefined' in index signature results */
|
|
43
|
-
// "noPropertyAccessFromIndexSignature": true, /* Require undeclared properties from index signatures to use element accesses. */
|
|
44
|
-
|
|
45
|
-
/* Module Resolution Options */
|
|
46
|
-
"moduleResolution": "bundler", /* Specify how TypeScript looks up a file from a given module specifier. Use 'bundler' for webpack/rollup/etc. */
|
|
47
|
-
// "baseUrl": "./", /* Base directory to resolve non-absolute module names. */
|
|
48
|
-
// "paths": {}, /* A series of entries which re-map imports to lookup locations relative to the 'baseUrl'. */
|
|
49
|
-
// "rootDirs": [], /* List of root folders whose combined content represents the structure of the project at runtime. */
|
|
50
|
-
// "typeRoots": [], /* List of folders to include type definitions from. */
|
|
51
|
-
// "types": [], /* Type declaration files to be included in compilation. */
|
|
52
|
-
// "allowSyntheticDefaultImports": true, /* Allow default imports from modules with no default export. This does not affect code emit, just typechecking. */
|
|
53
|
-
"esModuleInterop": true, /* Enables emit interoperability between CommonJS and ES Modules via creation of namespace objects for all imports. Implies 'allowSyntheticDefaultImports'. */
|
|
54
|
-
// "preserveSymlinks": true, /* Do not resolve the real path of symlinks. */
|
|
55
|
-
// "allowUmdGlobalAccess": true, /* Allow accessing UMD globals from modules. */
|
|
56
|
-
|
|
57
|
-
/* Source Map Options */
|
|
58
|
-
// "sourceRoot": "", /* Specify the location where debugger should locate TypeScript files instead of source locations. */
|
|
59
|
-
// "mapRoot": "", /* Specify the location where debugger should locate map files instead of generated locations. */
|
|
60
|
-
// "inlineSourceMap": true, /* Emit a single file with source maps instead of having a separate file. */
|
|
61
|
-
// "inlineSources": true, /* Emit the source alongside the sourcemaps within a single file; requires '--inlineSourceMap' or '--sourceMap' to be set. */
|
|
62
|
-
|
|
63
|
-
/* Experimental Options */
|
|
64
|
-
"experimentalDecorators": true, /* Enables experimental support for ES7 decorators. */
|
|
65
|
-
"emitDecoratorMetadata": true, /* Enables experimental support for emitting type metadata for decorators. */
|
|
66
|
-
|
|
67
|
-
/* Advanced Options */
|
|
68
|
-
"skipLibCheck": true, /* Skip type checking of declaration files. */
|
|
69
|
-
"forceConsistentCasingInFileNames": true, /* Disallow inconsistently-cased references to the same file. */
|
|
70
|
-
}
|
|
2
|
+
"extends": "@datagrok/build-config/tsconfig.base.json",
|
|
3
|
+
"include": ["src"]
|
|
71
4
|
}
|
package/package.json
CHANGED
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
"type": "git",
|
|
5
5
|
"url": "https://github.com/datagrok-ai/public.git"
|
|
6
6
|
},
|
|
7
|
-
"version": "6.
|
|
7
|
+
"version": "6.7.1",
|
|
8
8
|
"description": "Utility to upload and publish packages to Datagrok",
|
|
9
9
|
"homepage": "https://github.com/datagrok-ai/public/tree/master/tools#readme",
|
|
10
10
|
"dependencies": {
|
|
@@ -16,7 +16,6 @@
|
|
|
16
16
|
"adm-zip": "^0.6.0",
|
|
17
17
|
"ajv": "^8.20.0",
|
|
18
18
|
"archiver": "^7.0.1",
|
|
19
|
-
"datagrok-api": "^1.27.6",
|
|
20
19
|
"estraverse": "^5.3.0",
|
|
21
20
|
"glob": "^13.0.6",
|
|
22
21
|
"ignore-walk": "^6.0.5",
|
|
@@ -26,20 +25,9 @@
|
|
|
26
25
|
"node-fetch": "^2.7.0",
|
|
27
26
|
"papaparse": "^5.5.3",
|
|
28
27
|
"puppeteer": "^24.15.0",
|
|
29
|
-
"ts-morph": "^28.0.0"
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
"link": "npm link",
|
|
33
|
-
"prepublishOnly": "node build.js",
|
|
34
|
-
"babel": "node build.js",
|
|
35
|
-
"build": "node build.js",
|
|
36
|
-
"update:ivp-parser": "esbuild plugins/ivp-parser.entry.mjs --bundle --format=cjs --platform=node --alias:diff-grok=../libraries/compute-utils/node_modules/diff-grok --outfile=plugins/ivp-parser.bundle.cjs",
|
|
37
|
-
"debug-source-map": "node build.js --source-maps",
|
|
38
|
-
"test": "vitest run --project unit",
|
|
39
|
-
"test:server": "vitest run --project unit bin/__tests__/node-dapi bin/__tests__/server bin/__tests__/migrate",
|
|
40
|
-
"test:watch": "vitest --project unit",
|
|
41
|
-
"test:integration": "vitest run --project integration",
|
|
42
|
-
"test:all": "vitest run"
|
|
28
|
+
"ts-morph": "^28.0.0",
|
|
29
|
+
"@babel/generator": "^7.29.0",
|
|
30
|
+
"datagrok-api": "^1.27.11"
|
|
43
31
|
},
|
|
44
32
|
"bin": {
|
|
45
33
|
"datagrok-upload": "./bin/_deprecated/upload.js",
|
|
@@ -94,5 +82,17 @@
|
|
|
94
82
|
"archiver-utils": {
|
|
95
83
|
"glob": "$glob"
|
|
96
84
|
}
|
|
85
|
+
},
|
|
86
|
+
"scripts": {
|
|
87
|
+
"link": "npm link",
|
|
88
|
+
"babel": "node build.js",
|
|
89
|
+
"build": "node build.js",
|
|
90
|
+
"update:ivp-parser": "esbuild plugins/ivp-parser.entry.mjs --bundle --format=cjs --platform=node --alias:diff-grok=../libraries/compute-utils/node_modules/diff-grok --outfile=plugins/ivp-parser.bundle.cjs",
|
|
91
|
+
"debug-source-map": "node build.js --source-maps",
|
|
92
|
+
"test": "vitest run --project unit",
|
|
93
|
+
"test:server": "vitest run --project unit bin/__tests__/node-dapi bin/__tests__/server bin/__tests__/migrate bin/__tests__/keypair",
|
|
94
|
+
"test:watch": "vitest --project unit",
|
|
95
|
+
"test:integration": "vitest run --project integration",
|
|
96
|
+
"test:all": "vitest run"
|
|
97
97
|
}
|
|
98
|
-
}
|
|
98
|
+
}
|
|
@@ -1,8 +1,11 @@
|
|
|
1
1
|
const fs = require('fs');
|
|
2
2
|
const path = require('path');
|
|
3
3
|
|
|
4
|
-
|
|
5
|
-
|
|
4
|
+
// Loaded on first use: the parser and generator cost ~0.3 s, and the plugin is instantiated by every
|
|
5
|
+
// bundle whether or not a file changed.
|
|
6
|
+
let _tsParser; let _generate;
|
|
7
|
+
const tsParser = {parse: (...a) => (_tsParser ??= require('@typescript-eslint/typescript-estree')).parse(...a)};
|
|
8
|
+
const generate = (...a) => (_generate ??= require('@babel/generator').default)(...a);
|
|
6
9
|
|
|
7
10
|
const {
|
|
8
11
|
reservedDecorators,
|
|
@@ -15,9 +18,11 @@ const {
|
|
|
15
18
|
inputOptionsNames,
|
|
16
19
|
} = require('../bin/utils/func-generation');
|
|
17
20
|
|
|
18
|
-
|
|
21
|
+
// Not imported from commands/migrate: that module loads ts-morph (~1.5 s) at require time.
|
|
22
|
+
const toCamelCase = (s) => s.split('-').map((w) => w.charAt(0).toUpperCase() + w.slice(1)).join('');
|
|
19
23
|
|
|
20
|
-
|
|
24
|
+
let _api;
|
|
25
|
+
const api = (...a) => (_api ??= require('../bin/commands/api').api)(...a);
|
|
21
26
|
|
|
22
27
|
// Prebuilt CJS bundle of diff-grok's IVP parser (`getIVP` + a couple constants), tree-shaken
|
|
23
28
|
// to exclude the script-code generator. Regenerate with `npm run update:ivp-parser`.
|
package/turbo.json
ADDED
|
@@ -1,38 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"env": {
|
|
3
|
-
"browser": true,
|
|
4
|
-
"es2022": true
|
|
5
|
-
},
|
|
6
|
-
"extends": [
|
|
7
|
-
"google"
|
|
8
|
-
],
|
|
9
|
-
"parserOptions": {
|
|
10
|
-
"ecmaVersion": 12,
|
|
11
|
-
"sourceType": "module"
|
|
12
|
-
},
|
|
13
|
-
"rules": {
|
|
14
|
-
"indent": [
|
|
15
|
-
"error",
|
|
16
|
-
2
|
|
17
|
-
],
|
|
18
|
-
"max-len": [
|
|
19
|
-
"error",
|
|
20
|
-
120
|
|
21
|
-
],
|
|
22
|
-
"require-jsdoc": "off",
|
|
23
|
-
"spaced-comment": "off",
|
|
24
|
-
"linebreak-style": "off",
|
|
25
|
-
"curly": [
|
|
26
|
-
"error",
|
|
27
|
-
"multi-or-nest"
|
|
28
|
-
],
|
|
29
|
-
"brace-style": [
|
|
30
|
-
"error",
|
|
31
|
-
"1tbs",
|
|
32
|
-
{
|
|
33
|
-
"allowSingleLine": true
|
|
34
|
-
}
|
|
35
|
-
],
|
|
36
|
-
"block-spacing": 2
|
|
37
|
-
}
|
|
38
|
-
}
|
|
@@ -1,46 +0,0 @@
|
|
|
1
|
-
const path = require('path');
|
|
2
|
-
const FuncGeneratorPlugin = require('datagrok-tools/plugins/func-gen-plugin');
|
|
3
|
-
const packageName = path.parse(require('./package.json').name).name.toLowerCase().replace(/-/g, '');
|
|
4
|
-
|
|
5
|
-
module.exports = {
|
|
6
|
-
cache: {
|
|
7
|
-
type: 'filesystem',
|
|
8
|
-
},
|
|
9
|
-
mode: 'development',
|
|
10
|
-
entry: {
|
|
11
|
-
test: {filename: 'package-test.js', library: {type: 'var', name: `${packageName}_test`}, import: './src/package-test.ts'},
|
|
12
|
-
package: './src/package.ts',
|
|
13
|
-
},
|
|
14
|
-
resolve: {
|
|
15
|
-
symlinks: false,
|
|
16
|
-
extensions: ['.wasm', '.mjs', '.ts', '.json', '.js', '.tsx'],
|
|
17
|
-
},
|
|
18
|
-
module: {
|
|
19
|
-
rules: [
|
|
20
|
-
{test: /\.tsx?$/, loader: 'ts-loader', options: {allowTsInNodeModules: true}},
|
|
21
|
-
],
|
|
22
|
-
},
|
|
23
|
-
plugins: [
|
|
24
|
-
new FuncGeneratorPlugin({outputPath: './src/package.g.ts'}),
|
|
25
|
-
],
|
|
26
|
-
devtool: 'source-map',
|
|
27
|
-
externals: {
|
|
28
|
-
'datagrok-api/dg': 'DG',
|
|
29
|
-
'datagrok-api/grok': 'grok',
|
|
30
|
-
'datagrok-api/ui': 'ui',
|
|
31
|
-
'openchemlib/full.js': 'OCL',
|
|
32
|
-
'rxjs': 'rxjs',
|
|
33
|
-
'rxjs/operators': 'rxjs.operators',
|
|
34
|
-
'cash-dom': '$',
|
|
35
|
-
'dayjs': 'dayjs',
|
|
36
|
-
'wu': 'wu',
|
|
37
|
-
'exceljs': 'ExcelJS',
|
|
38
|
-
'html2canvas': 'html2canvas',
|
|
39
|
-
},
|
|
40
|
-
output: {
|
|
41
|
-
filename: '[name].js',
|
|
42
|
-
library: packageName,
|
|
43
|
-
libraryTarget: 'var',
|
|
44
|
-
path: path.resolve(__dirname, 'dist'),
|
|
45
|
-
},
|
|
46
|
-
};
|
|
@@ -1,35 +0,0 @@
|
|
|
1
|
-
const path = require('path');
|
|
2
|
-
const packageName = path.parse(require('./package.json').name).name.toLowerCase().replace(/-/g, '');
|
|
3
|
-
const FuncGeneratorPlugin = require('datagrok-tools/plugins/func-gen-plugin');
|
|
4
|
-
module.exports = {
|
|
5
|
-
cache: {
|
|
6
|
-
type: 'filesystem',
|
|
7
|
-
},
|
|
8
|
-
mode: 'production',
|
|
9
|
-
entry: {
|
|
10
|
-
package: './src/package.js',
|
|
11
|
-
},
|
|
12
|
-
devtool: 'source-map',
|
|
13
|
-
externals: {
|
|
14
|
-
'datagrok-api/dg': 'DG',
|
|
15
|
-
'datagrok-api/grok': 'grok',
|
|
16
|
-
'datagrok-api/ui': 'ui',
|
|
17
|
-
'openchemlib/full.js': 'OCL',
|
|
18
|
-
'rxjs': 'rxjs',
|
|
19
|
-
'rxjs/operators': 'rxjs.operators',
|
|
20
|
-
'cash-dom': '$',
|
|
21
|
-
'dayjs': 'dayjs',
|
|
22
|
-
'wu': 'wu',
|
|
23
|
-
'exceljs': 'ExcelJS',
|
|
24
|
-
'html2canvas': 'html2canvas',
|
|
25
|
-
},
|
|
26
|
-
output: {
|
|
27
|
-
filename: '[name].js',
|
|
28
|
-
library: packageName,
|
|
29
|
-
libraryTarget: 'var',
|
|
30
|
-
path: path.resolve(__dirname, 'dist'),
|
|
31
|
-
},
|
|
32
|
-
plugins: [
|
|
33
|
-
new FuncGeneratorPlugin({outputPath: './src/package.g.ts'}),
|
|
34
|
-
],
|
|
35
|
-
};
|