datagrok-tools 4.8.4 → 4.9.0
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/README.md +1 -1
- package/bin/commands/create.js +3 -3
- package/bin/commands/help.js +2 -4
- package/bin/commands/link.js +142 -137
- package/bin/grok.js +0 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -118,4 +118,4 @@ Read more about package development in [Datagrok's documentation](https://datagr
|
|
|
118
118
|
save a test run result, add the `--csv` flag (the report will be saved in a
|
|
119
119
|
CSV file in the package folder). You can find more details in [local package testing
|
|
120
120
|
instructions](https://datagrok.ai/help/develop/how-to/test-packages#local-testing).
|
|
121
|
-
- `link`
|
|
121
|
+
- `link` command is used for public plugins development to link `datagrok-api` and libraries.
|
package/bin/commands/create.js
CHANGED
|
@@ -132,7 +132,7 @@ function createDirectoryContents(name, config, templateDir, packageDir) {
|
|
|
132
132
|
dependencies.push("".concat(module, "@").concat(tag));
|
|
133
133
|
}
|
|
134
134
|
|
|
135
|
-
contents = JSON.stringify(_package, null,
|
|
135
|
+
contents = JSON.stringify(_package, null, 2);
|
|
136
136
|
}
|
|
137
137
|
|
|
138
138
|
if (file === 'package.js' && ts) copyFilePath = _path["default"].join(packageDir, 'package.ts');
|
|
@@ -148,7 +148,7 @@ function createDirectoryContents(name, config, templateDir, packageDir) {
|
|
|
148
148
|
var eslintConf = JSON.parse(contents);
|
|
149
149
|
eslintConf.parser = '@typescript-eslint/parser';
|
|
150
150
|
eslintConf.plugins = ['@typescript-eslint'];
|
|
151
|
-
contents = JSON.stringify(eslintConf, null,
|
|
151
|
+
contents = JSON.stringify(eslintConf, null, 2);
|
|
152
152
|
}
|
|
153
153
|
}
|
|
154
154
|
|
|
@@ -248,7 +248,7 @@ function create(args) {
|
|
|
248
248
|
var p = JSON.parse(_fs["default"].readFileSync(packagePath, 'utf-8'));
|
|
249
249
|
p.repository = repositoryInfo;
|
|
250
250
|
|
|
251
|
-
_fs["default"].writeFileSync(packagePath, JSON.stringify(p, null,
|
|
251
|
+
_fs["default"].writeFileSync(packagePath, JSON.stringify(p, null, 2), 'utf-8');
|
|
252
252
|
}
|
|
253
253
|
|
|
254
254
|
process.exit();
|
package/bin/commands/help.js
CHANGED
|
@@ -4,7 +4,7 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.help = void 0;
|
|
7
|
-
var HELP = "\nUsage: grok <command>\n\nDatagrok's package management tool\n\nCommands:\n add Add an object template\n api Create wrapper functions\n check Check package content (function signatures, etc.)\n config Create and manage config files\n create Create a package\n init Modify a package template\n link Link `datagrok-api` and libraries for local development\n
|
|
7
|
+
var HELP = "\nUsage: grok <command>\n\nDatagrok's package management tool\n\nCommands:\n add Add an object template\n api Create wrapper functions\n check Check package content (function signatures, etc.)\n config Create and manage config files\n create Create a package\n init Modify a package template\n link Link `datagrok-api` and libraries for local development\n publish Upload a package\n test Run package tests\n\nTo get help on a particular command, use:\n grok <command> --help\n\nRead more about the package development workflow:\nhttps://datagrok.ai/help/develop/develop\n";
|
|
8
8
|
var HELP_ADD = "\nUsage: grok add <entity> <name>\n\nAdd an object template to your package:\n\ngrok add app <name>\ngrok add connection <name>\ngrok add detector <semantic-type-name>\ngrok add function [tag] <name>\ngrok add query <name>\ngrok add script [tag] <language> <name>\ngrok add view <name>\ngrok add viewer <name>\ngrok add tests\n\nPlease note that entity names may only include letters and numbers\n\nSupported languages for scripts:\njavascript, julia, node, octave, python, r\n\nAvailable tags:\npanel, init\n";
|
|
9
9
|
var HELP_INIT = "\nUsage: grok init\n\nModify a package template by adding config files for linters, IDE, etc.\n\nOptions:\n[--eslint] [--ide] [--test] [--ts]\n\n--eslint Add a configuration for eslint\n--ide Add an IDE-specific configuration for debugging (vscode)\n--test Add tests support (TypeScript packages only)\n--ts Convert a JavaScript package to TypeScript\n";
|
|
10
10
|
var HELP_API = "\nUsage: grok api\n\nCreate wrapper functions for package scripts and queries\n";
|
|
@@ -13,8 +13,7 @@ var HELP_CREATE = "\nUsage: grok create [name]\n\nCreate a package:\n\ngrok crea
|
|
|
13
13
|
var HELP_PUBLISH = "\nUsage: grok publish [host]\n\nUpload a package\n\nOptions:\n[--build|--rebuild] [--debug|--release] [-k | --key] [--suffix]\n\nRunning `grok publish` is the same as running `grok publish defaultHost --build --debug`\n";
|
|
14
14
|
var HELP_CHECK = "\nUsage: grok check\n\nOptions:\n[-r | --recursive]\n\n--recursive Check all packages in the current directory\n\nCheck package content (function signatures, import statements of external modules, etc.)\n";
|
|
15
15
|
var HELP_TEST = "\nUsage: grok test\n\nOptions:\n[--host] [--csv]\n\n--host Host alias as in the config file\n--csv Save the test report in a CSV file\n--gui Launch graphical interface (non-headless mode)\n--skip-build Skip the package build step\n--skip-publish Skip the package publication step\n\nRun package tests\n\nSee instructions:\nhttps://datagrok.ai/help/develop/how-to/test-packages#local-testing\n";
|
|
16
|
-
var HELP_LINK = "\nUsage: grok link\n\nLink `datagrok-api` and libraries for local development\n";
|
|
17
|
-
var HELP_UNLINK = "\nUsage: grok unlink\n\nRevert `grok link`\n";
|
|
16
|
+
var HELP_LINK = "\nUsage: grok link\n\nLink `datagrok-api` and libraries for local development\n\nOptions:\n[--local | --npm]\n\n--local Default. Links libraries and updates package scripts (\"link-all\", \"build-all\")\n--npm Unlinks local packages and runs `npm i`\n";
|
|
18
17
|
var HELP_MIGRATE = "\nUsage: grok migrate\n\nSwitch to `grok` tools by copying your keys to the config\nfile and converting your scripts in the `package.json` file\n";
|
|
19
18
|
var help = {
|
|
20
19
|
add: HELP_ADD,
|
|
@@ -24,7 +23,6 @@ var help = {
|
|
|
24
23
|
create: HELP_CREATE,
|
|
25
24
|
init: HELP_INIT,
|
|
26
25
|
link: HELP_LINK,
|
|
27
|
-
unlink: HELP_UNLINK,
|
|
28
26
|
publish: HELP_PUBLISH,
|
|
29
27
|
test: HELP_TEST,
|
|
30
28
|
help: HELP
|
package/bin/commands/link.js
CHANGED
|
@@ -8,7 +8,6 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
8
8
|
value: true
|
|
9
9
|
});
|
|
10
10
|
exports.link = link;
|
|
11
|
-
exports.unlink = unlink;
|
|
12
11
|
|
|
13
12
|
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
|
|
14
13
|
|
|
@@ -34,22 +33,20 @@ function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o =
|
|
|
34
33
|
|
|
35
34
|
function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) { arr2[i] = arr[i]; } return arr2; }
|
|
36
35
|
|
|
37
|
-
/**
|
|
38
|
-
* Link: api > utils > other libs - npm install, npm run build, npm link
|
|
39
|
-
* Unlink: npm install in the package and its dependencies, npm unlink
|
|
40
|
-
*/
|
|
41
36
|
var curDir = process.cwd();
|
|
42
37
|
|
|
43
|
-
var
|
|
38
|
+
var repositoryDir = _path["default"].dirname(_path["default"].dirname(curDir));
|
|
44
39
|
|
|
45
40
|
var apiPackageName = 'datagrok-api';
|
|
46
41
|
var libScope = '@datagrok-libraries';
|
|
47
|
-
var paths = (_paths = {}, (0, _defineProperty2["default"])(_paths, apiPackageName, _path["default"].join(
|
|
42
|
+
var paths = (_paths = {}, (0, _defineProperty2["default"])(_paths, apiPackageName, _path["default"].join(repositoryDir, 'js-api')), (0, _defineProperty2["default"])(_paths, libScope, _path["default"].join(repositoryDir, 'libraries')), _paths);
|
|
43
|
+
var packageDependencies = {};
|
|
48
44
|
/** Links local packages. */
|
|
49
45
|
|
|
50
46
|
function link(args) {
|
|
51
47
|
var nOptions = Object.keys(args).length - 1;
|
|
52
|
-
if (nOptions >
|
|
48
|
+
if (nOptions > 1 || args['_'].length > 1 || nOptions === 1 && !args.local && !args.npm) return false;
|
|
49
|
+
var local = args.npm ? false : true; // args.local is default
|
|
53
50
|
|
|
54
51
|
if (!utils.isPackageDir(curDir)) {
|
|
55
52
|
color.error('File `package.json` not found. Run the command from the package directory');
|
|
@@ -65,173 +62,181 @@ function link(args) {
|
|
|
65
62
|
}
|
|
66
63
|
}
|
|
67
64
|
|
|
68
|
-
var dependencies = readDependencies(
|
|
65
|
+
var dependencies = readDependencies(curDir);
|
|
69
66
|
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
console.log('Running `npm install` to get the required dependencies...\n');
|
|
74
|
-
(0, _child_process.exec)('npm install', function (err, stdout, stderr) {
|
|
75
|
-
if (err) throw err;else console.log(stderr, stdout);
|
|
76
|
-
});
|
|
77
|
-
} // The order should start with js-api, then libraries/utils, then other libraries
|
|
67
|
+
if (local) {
|
|
68
|
+
var _link = function _link(packagePath) {
|
|
69
|
+
var packageJsonPath = _path["default"].join(packagePath, 'package.json');
|
|
78
70
|
|
|
71
|
+
var json = JSON.parse(_fs["default"].readFileSync(packageJsonPath, 'utf-8'));
|
|
72
|
+
json.scripts['link-all'] = generateLinkScript(packagePath, packageHierarchy);
|
|
73
|
+
json.scripts['build-all'] = generateBuildScript(packagePath, packageHierarchy);
|
|
79
74
|
|
|
80
|
-
|
|
81
|
-
var hasUtils = false;
|
|
82
|
-
var libs = [];
|
|
75
|
+
_fs["default"].writeFileSync(packageJsonPath, JSON.stringify(json, null, 2), 'utf-8');
|
|
83
76
|
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
_step;
|
|
77
|
+
(0, _child_process.exec)('npm install && npm link && npm run link-all', {
|
|
78
|
+
cwd: packagePath
|
|
79
|
+
}, function (err, stdout, stderr) {
|
|
80
|
+
if (err) throw err;else console.log(stderr, stdout);
|
|
81
|
+
});
|
|
82
|
+
};
|
|
91
83
|
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
libs = _fs["default"].readdirSync(_path["default"].join(modulesDir, m.name), {
|
|
97
|
-
encoding: 'utf-8',
|
|
98
|
-
withFileTypes: true
|
|
99
|
-
});
|
|
84
|
+
var packageHierarchy = getHierarchy(curDir);
|
|
85
|
+
packageHierarchy.forEach(function (packageName) {
|
|
86
|
+
return _link(getPackagePath(packageName));
|
|
87
|
+
});
|
|
100
88
|
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
if (lib.name === 'utils') hasUtils = true;
|
|
108
|
-
}
|
|
109
|
-
} catch (err) {
|
|
110
|
-
_iterator3.e(err);
|
|
111
|
-
} finally {
|
|
112
|
-
_iterator3.f();
|
|
113
|
-
}
|
|
114
|
-
}
|
|
115
|
-
}
|
|
116
|
-
} catch (err) {
|
|
117
|
-
_iterator.e(err);
|
|
118
|
-
} finally {
|
|
119
|
-
_iterator.f();
|
|
89
|
+
_link(curDir);
|
|
90
|
+
} else {
|
|
91
|
+
runScript(curDir, 'npm install', dependencies, {
|
|
92
|
+
dirMessage: 'Unlinking local packages in ',
|
|
93
|
+
successMessage: 'Local packages have been successfully unlinked.'
|
|
94
|
+
});
|
|
120
95
|
}
|
|
121
96
|
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
var f = function f() {
|
|
126
|
-
var _iterator2 = _createForOfIteratorHelper(libs),
|
|
127
|
-
_step2;
|
|
97
|
+
return true;
|
|
98
|
+
}
|
|
128
99
|
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
var lib = _step2.value;
|
|
100
|
+
function readDependencies(packagePath) {
|
|
101
|
+
if (packagePath in packageDependencies) return packageDependencies[packagePath];
|
|
132
102
|
|
|
133
|
-
|
|
134
|
-
var libPath = _path["default"].join(paths[libScope], lib.name);
|
|
103
|
+
var fileContent = _fs["default"].readFileSync(_path["default"].join(packagePath, 'package.json'), 'utf-8');
|
|
135
104
|
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
(0, _child_process.exec)(isLinked ? 'npm update && npm run build' : 'npm install && npm run link-all && npm run build && npm link', {
|
|
139
|
-
cwd: libPath
|
|
140
|
-
}, function (err, stdout, stderr) {
|
|
141
|
-
if (err) throw err;else console.log(stderr, stdout);
|
|
142
|
-
});
|
|
143
|
-
}
|
|
144
|
-
}
|
|
145
|
-
} catch (err) {
|
|
146
|
-
_iterator2.e(err);
|
|
147
|
-
} finally {
|
|
148
|
-
_iterator2.f();
|
|
149
|
-
}
|
|
150
|
-
};
|
|
105
|
+
var json = JSON.parse(fileContent);
|
|
106
|
+
var libs = {};
|
|
151
107
|
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
}), 1)[0];
|
|
108
|
+
for (var dep in json.dependencies) {
|
|
109
|
+
if (dep === apiPackageName || dep.startsWith("".concat(libScope, "/"))) libs[dep] = json.dependencies[dep];
|
|
110
|
+
}
|
|
156
111
|
|
|
157
|
-
|
|
112
|
+
packageDependencies[packagePath] = libs;
|
|
113
|
+
return libs;
|
|
114
|
+
}
|
|
158
115
|
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
116
|
+
function getPackagePath(packageName) {
|
|
117
|
+
return packageName === apiPackageName ? paths[packageName] : _path["default"].join(paths[libScope], packageName.split('/')[1]);
|
|
118
|
+
}
|
|
119
|
+
/** Forms a hierarchy to understand in which order packages should be linked. */
|
|
120
|
+
|
|
121
|
+
|
|
122
|
+
function getHierarchy(packageDir) {
|
|
123
|
+
var hierarchy = [];
|
|
124
|
+
var dependencies = Object.keys(readDependencies(packageDir));
|
|
125
|
+
var cachedHierarchy = {};
|
|
126
|
+
|
|
127
|
+
for (var _i2 = 0, _dependencies = dependencies; _i2 < _dependencies.length; _i2++) {
|
|
128
|
+
var _cachedHierarchy$depP;
|
|
129
|
+
|
|
130
|
+
var dep = _dependencies[_i2];
|
|
131
|
+
var idx = hierarchy.indexOf(dep);
|
|
132
|
+
if (idx === -1) idx = hierarchy.push(dep) - 1;
|
|
133
|
+
var depPath = getPackagePath(dep);
|
|
134
|
+
var internalHierarchy = (_cachedHierarchy$depP = cachedHierarchy[depPath]) !== null && _cachedHierarchy$depP !== void 0 ? _cachedHierarchy$depP : getHierarchy(depPath);
|
|
135
|
+
if (!(depPath in cachedHierarchy)) cachedHierarchy[depPath] = internalHierarchy;
|
|
136
|
+
|
|
137
|
+
var _iterator = _createForOfIteratorHelper(internalHierarchy),
|
|
138
|
+
_step;
|
|
139
|
+
|
|
140
|
+
try {
|
|
141
|
+
for (_iterator.s(); !(_step = _iterator.n()).done;) {
|
|
142
|
+
var internalDep = _step.value;
|
|
143
|
+
var depIdx = hierarchy.indexOf(internalDep);
|
|
144
|
+
|
|
145
|
+
if (depIdx === -1) {
|
|
146
|
+
// Insert the internal dependency before the main package
|
|
147
|
+
hierarchy.splice(idx, 0, internalDep);
|
|
148
|
+
idx++;
|
|
149
|
+
} else if (depIdx > idx) {
|
|
150
|
+
// Remove the internal dependency from the list and place it before the main package
|
|
151
|
+
// (doesn't affect the order of same-level libraries, their order is arbitrary)
|
|
152
|
+
hierarchy.splice(depIdx, 1);
|
|
153
|
+
idx = hierarchy.indexOf(dep);
|
|
154
|
+
hierarchy.splice(idx, 0, internalDep);
|
|
155
|
+
idx++;
|
|
167
156
|
}
|
|
168
|
-
});
|
|
169
|
-
} else {
|
|
170
|
-
f();
|
|
171
|
-
}
|
|
172
|
-
}
|
|
173
|
-
|
|
174
|
-
if (apiModule != null) {
|
|
175
|
-
var isLinked = apiModule.isSymbolicLink();
|
|
176
|
-
console.log(isLinked ? "Package \"".concat(apiModule.name, "\" is linked. Updating dependencies and running the build script...") : "Linking \"".concat(apiModule.name, "\"..."));
|
|
177
|
-
(0, _child_process.exec)(isLinked ? "npm update && npm run build" : "npm install && npm run build && npm link", {
|
|
178
|
-
cwd: paths[apiPackageName]
|
|
179
|
-
}, function (err, stdout, stderr) {
|
|
180
|
-
if (err) throw err;else {
|
|
181
|
-
console.log(stderr, stdout);
|
|
182
|
-
installLibs(libs);
|
|
183
|
-
var packageNames = Object.keys(dependencies).join(' ');
|
|
184
|
-
(0, _child_process.exec)("npm link ".concat(packageNames));
|
|
185
157
|
}
|
|
186
|
-
})
|
|
158
|
+
} catch (err) {
|
|
159
|
+
_iterator.e(err);
|
|
160
|
+
} finally {
|
|
161
|
+
_iterator.f();
|
|
162
|
+
}
|
|
187
163
|
}
|
|
188
164
|
|
|
189
|
-
return
|
|
165
|
+
return hierarchy;
|
|
190
166
|
}
|
|
191
|
-
/**
|
|
167
|
+
/** Executes a script for a package and its dependencies with messages on the current progress. */
|
|
192
168
|
|
|
193
169
|
|
|
194
|
-
function
|
|
195
|
-
var
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
}
|
|
202
|
-
|
|
203
|
-
var dependencies = readDependencies(JSON.parse(_fs["default"].readFileSync(packageDir, 'utf-8')));
|
|
204
|
-
var packageNames = Object.keys(dependencies).join(' '); // npm unlink ${packageNames}
|
|
205
|
-
|
|
206
|
-
(0, _child_process.exec)("npm install", function (err, stdout, stderr) {
|
|
207
|
-
console.log("Unlinking local packages in ".concat(_path["default"].basename(curDir)));
|
|
170
|
+
function runScript(packageDir, script, dependencies) {
|
|
171
|
+
var options = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : {};
|
|
172
|
+
(0, _child_process.exec)(script, {
|
|
173
|
+
cwd: packageDir
|
|
174
|
+
}, function (err, stdout, stderr) {
|
|
175
|
+
if (options.dirMessage) console.log("".concat(options.dirMessage).concat(_path["default"].basename(packageDir)));
|
|
176
|
+
if (options.callback) options.callback(packageDir);
|
|
208
177
|
if (err) throw err;else {
|
|
209
178
|
console.log(stderr, stdout);
|
|
210
179
|
|
|
211
180
|
var _loop = function _loop(dep) {
|
|
212
|
-
var depPath =
|
|
213
|
-
(0, _child_process.exec)(
|
|
181
|
+
var depPath = getPackagePath(dep);
|
|
182
|
+
(0, _child_process.exec)(script, {
|
|
214
183
|
cwd: depPath
|
|
215
184
|
}, function (err, stdout, stderr) {
|
|
216
|
-
console.log("
|
|
185
|
+
if (options.dirMessage) console.log("".concat(options.dirMessage).concat(_path["default"].basename(depPath)));
|
|
186
|
+
if (options.callback) options.callback(depPath);
|
|
217
187
|
if (err) throw err;else console.log(stderr, stdout);
|
|
218
188
|
});
|
|
219
189
|
};
|
|
220
190
|
|
|
221
191
|
for (var dep in dependencies) {
|
|
222
192
|
_loop(dep);
|
|
223
|
-
}
|
|
193
|
+
} // if (options.successMessage)
|
|
194
|
+
// setTimeout(() => color.success(options.successMessage!), 5000);
|
|
195
|
+
|
|
224
196
|
}
|
|
225
197
|
});
|
|
226
|
-
return true;
|
|
227
198
|
}
|
|
199
|
+
/** Generates a package script to build all dependencies using the provided hierarchy. */
|
|
228
200
|
|
|
229
|
-
function readDependencies(json) {
|
|
230
|
-
var libs = {};
|
|
231
201
|
|
|
232
|
-
|
|
233
|
-
|
|
202
|
+
function generateBuildScript(packagePath, hierarchy) {
|
|
203
|
+
var dependencies = Object.keys(readDependencies(packagePath));
|
|
204
|
+
var packageNames = hierarchy.filter(function (p) {
|
|
205
|
+
return dependencies.includes(p);
|
|
206
|
+
});
|
|
207
|
+
var prefix = "./".concat(_path["default"].relative(packagePath, repositoryDir).split(_path["default"].sep).join('/'), "/");
|
|
208
|
+
var script = '';
|
|
209
|
+
|
|
210
|
+
var _iterator2 = _createForOfIteratorHelper(packageNames),
|
|
211
|
+
_step2;
|
|
212
|
+
|
|
213
|
+
try {
|
|
214
|
+
for (_iterator2.s(); !(_step2 = _iterator2.n()).done;) {
|
|
215
|
+
var packageName = _step2.value;
|
|
216
|
+
script += "npm --prefix ".concat(prefix).concat(packageName === apiPackageName ? 'js-api' : "libraries/".concat(packageName.split('/')[1]), " run build && ");
|
|
217
|
+
}
|
|
218
|
+
} catch (err) {
|
|
219
|
+
_iterator2.e(err);
|
|
220
|
+
} finally {
|
|
221
|
+
_iterator2.f();
|
|
234
222
|
}
|
|
235
223
|
|
|
236
|
-
return
|
|
224
|
+
return "".concat(script ? script : '', "npm run build");
|
|
225
|
+
}
|
|
226
|
+
/** Generates a package script to link all dependencies using the provided hierarchy. */
|
|
227
|
+
|
|
228
|
+
|
|
229
|
+
function generateLinkScript(packagePath, hierarchy) {
|
|
230
|
+
var dependencies = Object.keys(readDependencies(packagePath));
|
|
231
|
+
var packageNames = hierarchy.filter(function (p) {
|
|
232
|
+
return dependencies.includes(p);
|
|
233
|
+
});
|
|
234
|
+
|
|
235
|
+
for (var _i3 = 0, _dependencies2 = dependencies; _i3 < _dependencies2.length; _i3++) {
|
|
236
|
+
var dep = _dependencies2[_i3];
|
|
237
|
+
if (!packageNames.includes(dep)) color.error("Hierarchy does not include package ".concat(dep));
|
|
238
|
+
}
|
|
239
|
+
|
|
240
|
+
var script = "npm link".concat(packageNames.length ? ' ' + packageNames.join(' ') : '');
|
|
241
|
+
return script;
|
|
237
242
|
}
|
package/bin/grok.js
CHANGED
|
@@ -12,7 +12,6 @@ const commands = {
|
|
|
12
12
|
create: require('./commands/create').create,
|
|
13
13
|
init: require('./commands/init').init,
|
|
14
14
|
link: require('./commands/link').link,
|
|
15
|
-
unlink: require('./commands/link').unlink,
|
|
16
15
|
publish: require('./commands/publish').publish,
|
|
17
16
|
test: require('./commands/test').test,
|
|
18
17
|
};
|
package/package.json
CHANGED