datagrok-tools 6.7.0 → 6.7.2

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.
@@ -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 {
@@ -3,7 +3,7 @@
3
3
  "tasks": [
4
4
  {
5
5
  "type": "shell",
6
- "command": "cmd.exe /c 'call webpack && call grok publish #{GROK_HOST_ALIAS}'",
6
+ "command": "cmd.exe /c 'call pnpm run build && call grok publish #{GROK_HOST_ALIAS}'",
7
7
  "label": "rebuild"
8
8
  }
9
9
  ]
@@ -4,21 +4,16 @@
4
4
  "version": "0.0.1",
5
5
  "description": "#{PACKAGE_NAME} package",
6
6
  "dependencies": {
7
- "datagrok-api": "^1.26.0",
8
- "cash-dom": "^8.1.5",
9
- "dayjs": "^1.11.13",
10
- "@datagrok-libraries/test": "^1.1.0"
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
- "debug-#{PACKAGE_NAME_LOWERCASE}": "webpack && grok publish",
19
- "release-#{PACKAGE_NAME_LOWERCASE}": "webpack && grok publish --release",
20
- "build-#{PACKAGE_NAME_LOWERCASE}": "webpack",
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
- "compilerOptions": {
3
- /* Visit https://aka.ms/tsconfig.json to read more about this file */
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.0",
7
+ "version": "6.7.2",
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
- "scripts": {
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 bin/__tests__/keypair",
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
- const tsParser = require('@typescript-eslint/typescript-estree');
5
- const generate = require('@babel/generator').default;
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
- const {toCamelCase} = require('../bin/commands/migrate');
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
- const {api} = require('../bin/commands/api');
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
@@ -0,0 +1,9 @@
1
+ {
2
+ "$schema": "https://turbo.build/schema.json",
3
+ "extends": ["//"],
4
+ "tasks": {
5
+ "build": {
6
+ "dependsOn": []
7
+ }
8
+ }
9
+ }
@@ -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
- };