lincd-cli 0.1.21 → 0.1.23
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/defaults/app-with-backend/frontend/src/components/Spinner.scss +4 -4
- package/defaults/app-with-backend/frontend/src/components/Spinner.tsx +3 -2
- package/defaults/app-with-backend/package.json +5 -1
- package/defaults/component.scss +3 -0
- package/defaults/component.tsx +12 -0
- package/defaults/module/src/package.ts +1 -1
- package/lib/cli.js +81 -36
- package/lib/config-webpack.js +20 -1
- package/lib/utils.js +8 -1
- package/package.json +3 -1
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
.spinner.active {
|
|
2
|
-
border: 4px solid
|
|
3
|
-
border-top: 4px solid
|
|
2
|
+
border: 4px solid transparent;
|
|
3
|
+
border-top: 4px solid #474545;
|
|
4
4
|
border-radius: 50%;
|
|
5
|
-
width:
|
|
6
|
-
height:
|
|
5
|
+
width: 16px;
|
|
6
|
+
height: 16px;
|
|
7
7
|
animation: spin 1s linear infinite;
|
|
8
8
|
}
|
|
9
9
|
@keyframes spin {
|
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
import './Spinner.scss';
|
|
2
|
+
import * as style from './Spinner.scss.json';
|
|
2
3
|
export default function Spinner({active = true}) {
|
|
3
4
|
return (
|
|
4
5
|
<div
|
|
5
|
-
className={[
|
|
6
|
+
className={[style.spinner, active && style.active].join(' ')}
|
|
6
7
|
role="progressbar"
|
|
7
8
|
aria-busy={active ? 'true' : 'false'}
|
|
8
9
|
/>
|
|
9
10
|
);
|
|
10
|
-
}
|
|
11
|
+
}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
import "./${hyphen_name}.scss";
|
|
3
|
+
import {default as style} from "./${hyphen_name}.scss.json";
|
|
4
|
+
import {registerPackageModule,linkedComponent} from '../package';
|
|
5
|
+
|
|
6
|
+
//TODO: replace SHAPE with an actual Shape class
|
|
7
|
+
export const ${camel_name} = linkedComponent<SHAPE>(SHAPE,({source, sourceShape}) => {
|
|
8
|
+
return <div className={style.${camel_name}}></div>;
|
|
9
|
+
});
|
|
10
|
+
|
|
11
|
+
//register all components in this file
|
|
12
|
+
registerPackageModule(module);
|
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
import {linkedPackage} from 'lincd/lib/utils/Module';
|
|
2
2
|
|
|
3
|
-
export const {linkedComponent, linkedComponentClass, linkedShape, linkedUtil, linkedOntology} =
|
|
3
|
+
export const {linkedComponent, linkedComponentClass, linkedShape, linkedUtil, linkedOntology, registerPackageModule, registerPackageExport, packageExports} =
|
|
4
4
|
linkedPackage('${module_name}');
|
package/lib/cli.js
CHANGED
|
@@ -94,6 +94,13 @@ program
|
|
|
94
94
|
})
|
|
95
95
|
.description('Creates a new ShapeClass file for your module. Execute this from your module folder.')
|
|
96
96
|
.argument('<name>', 'The name of the shape. Will be used for the file name and the class name');
|
|
97
|
+
program
|
|
98
|
+
.command('create-component')
|
|
99
|
+
.action(function (name, uriBase) {
|
|
100
|
+
return createComponent(name);
|
|
101
|
+
})
|
|
102
|
+
.description('Creates a new Component file for your package. Execute this from your package folder.')
|
|
103
|
+
.argument('<name>', 'The name of the component. Will be used for the file name and the export name');
|
|
97
104
|
program
|
|
98
105
|
.command('create-ontology')
|
|
99
106
|
.action(function (prefix, uriBase) {
|
|
@@ -142,12 +149,12 @@ program.command('build-updated-since [num-commits-back] [target] [target2]').act
|
|
|
142
149
|
program.command('build-all [target] [target2]').action(function (target, target2) {
|
|
143
150
|
buildAll(target, target2);
|
|
144
151
|
});
|
|
145
|
-
program.command('modules [action] [
|
|
146
|
-
executeCommandForEachModule(getLincdModules(), command,
|
|
147
|
-
});
|
|
148
|
-
program.command('modules-except [excludedSpaces] [action]').action(function (excludedSpaces, command) {
|
|
149
|
-
executeCommandForEachModule(getLincdModules(), command, null, excludedSpaces);
|
|
152
|
+
program.command('modules [action] [filter] [filter-value]').action(function (command, filter, filterValue) {
|
|
153
|
+
executeCommandForEachModule(getLincdModules(), command, filter, filterValue);
|
|
150
154
|
});
|
|
155
|
+
// program.command('modules-except [excludedSpaces] [action]').action((excludedSpaces, command) => {
|
|
156
|
+
// executeCommandForEachModule(getLincdModules(), command, null, excludedSpaces);
|
|
157
|
+
// });
|
|
151
158
|
program.command('dev [target] [mode]').action(function (target, mode) {
|
|
152
159
|
developModule(target, mode);
|
|
153
160
|
});
|
|
@@ -599,13 +606,13 @@ var replaceCurlyVariables = function (string) {
|
|
|
599
606
|
};
|
|
600
607
|
var capitalize = function (str) { return str.charAt(0).toUpperCase() + str.toLowerCase().slice(1); };
|
|
601
608
|
var camelCase = function (str) {
|
|
602
|
-
//this version does not replace any capitals already used by the user
|
|
603
609
|
var string = str
|
|
604
610
|
.replace(/[^A-Za-z0-9]/g, ' ')
|
|
605
|
-
.split(' ')
|
|
606
|
-
|
|
607
|
-
|
|
608
|
-
|
|
611
|
+
.split(' ');
|
|
612
|
+
if (string.length > 1) {
|
|
613
|
+
return string.reduce(function (result, word) { return result + capitalize(word); });
|
|
614
|
+
}
|
|
615
|
+
return str;
|
|
609
616
|
};
|
|
610
617
|
var createOntology = function (prefix, uriBase, basePath) {
|
|
611
618
|
if (basePath === void 0) { basePath = process.cwd(); }
|
|
@@ -764,6 +771,33 @@ var createShape = function (name, basePath) {
|
|
|
764
771
|
});
|
|
765
772
|
});
|
|
766
773
|
};
|
|
774
|
+
var createComponent = function (name, basePath) {
|
|
775
|
+
if (basePath === void 0) { basePath = process.cwd(); }
|
|
776
|
+
return __awaiter(void 0, void 0, void 0, function () {
|
|
777
|
+
var targetFolder, _a, hyphenName, camelCaseName, underscoreName, targetFile, targetFile2, indexPath;
|
|
778
|
+
return __generator(this, function (_b) {
|
|
779
|
+
switch (_b.label) {
|
|
780
|
+
case 0:
|
|
781
|
+
targetFolder = ensureFolderExists(basePath, 'src', 'components');
|
|
782
|
+
_a = setNameVariables(name), hyphenName = _a.hyphenName, camelCaseName = _a.camelCaseName, underscoreName = _a.underscoreName;
|
|
783
|
+
//copy default shape file
|
|
784
|
+
log("Creating files for component '" + name + "'");
|
|
785
|
+
targetFile = path.join(targetFolder, hyphenName + '.tsx');
|
|
786
|
+
fs.copySync(path.join(__dirname, '..', 'defaults', 'component.tsx'), targetFile);
|
|
787
|
+
targetFile2 = path.join(targetFolder, hyphenName + '.scss');
|
|
788
|
+
fs.copySync(path.join(__dirname, '..', 'defaults', 'component.scss'), targetFile2);
|
|
789
|
+
//replace variables in some of the copied files
|
|
790
|
+
return [4 /*yield*/, replaceVariablesInFiles(targetFile, targetFile2)];
|
|
791
|
+
case 1:
|
|
792
|
+
//replace variables in some of the copied files
|
|
793
|
+
_b.sent();
|
|
794
|
+
indexPath = addLineToIndex("import './components/".concat(hyphenName, "';"), 'components');
|
|
795
|
+
log("Created a new component template in ".concat(chalk.magenta(targetFile.replace(basePath, ''))), "Created component stylesheet template in ".concat(chalk.magenta(targetFile2.replace(basePath, ''))), "Added an import of this file from ".concat(chalk.magenta(indexPath)));
|
|
796
|
+
return [2 /*return*/];
|
|
797
|
+
}
|
|
798
|
+
});
|
|
799
|
+
});
|
|
800
|
+
};
|
|
767
801
|
var createModule = function (name, uriBase, basePath) {
|
|
768
802
|
if (basePath === void 0) { basePath = process.cwd(); }
|
|
769
803
|
return __awaiter(void 0, void 0, void 0, function () {
|
|
@@ -939,20 +973,21 @@ var register = function (registryURL) {
|
|
|
939
973
|
var pack = JSON.parse(fs.readFileSync(process.cwd() + '/package.json', 'utf8'));
|
|
940
974
|
var version = pack.version;
|
|
941
975
|
var moduleName = pack.name;
|
|
942
|
-
|
|
943
|
-
|
|
944
|
-
|
|
945
|
-
|
|
946
|
-
|
|
947
|
-
|
|
948
|
-
|
|
976
|
+
// let author = pack.author;
|
|
977
|
+
// let description = pack.description;
|
|
978
|
+
//
|
|
979
|
+
// let authorName = pack.author;
|
|
980
|
+
// if (pack.author.name) {
|
|
981
|
+
// authorName = pack.author.name;
|
|
982
|
+
// }
|
|
983
|
+
console.log(chalk.cyan('registering package ' + moduleName + ' ' + version + ' in the LINCD registry'));
|
|
949
984
|
return fetch(registryURL + '/register', {
|
|
950
985
|
method: 'POST',
|
|
951
986
|
headers: {
|
|
952
987
|
Accept: 'application/json, text/plain, */*',
|
|
953
988
|
'Content-Type': 'application/json'
|
|
954
989
|
},
|
|
955
|
-
body: JSON.stringify({ package: moduleName, version: version
|
|
990
|
+
body: JSON.stringify({ package: moduleName, version: version })
|
|
956
991
|
})
|
|
957
992
|
.then(function (res) { return res.json(); })
|
|
958
993
|
.then(function (json) {
|
|
@@ -960,7 +995,7 @@ var register = function (registryURL) {
|
|
|
960
995
|
console.log(chalk.red('Response: ' + json.error));
|
|
961
996
|
}
|
|
962
997
|
else if (json.result) {
|
|
963
|
-
console.log(chalk.
|
|
998
|
+
console.log(chalk.blueBright('Response: ') + json.result);
|
|
964
999
|
if (json.warning) {
|
|
965
1000
|
console.log(chalk.red('Warning: ') + json.warning);
|
|
966
1001
|
}
|
|
@@ -1218,31 +1253,41 @@ var buildUpdated = function (back, target, target2, test) {
|
|
|
1218
1253
|
// });
|
|
1219
1254
|
};
|
|
1220
1255
|
var printBuildResults = function (failed, done) {
|
|
1221
|
-
log('Build results: '
|
|
1222
|
-
|
|
1223
|
-
|
|
1224
|
-
|
|
1256
|
+
log('Build results: ' +
|
|
1257
|
+
chalk.green(__spreadArray([], __read(done), false).map(function (m) { return m.moduleName; }).join(', ')) +
|
|
1258
|
+
(failed.length > 0 ? ', ' + chalk.red(failed.join(', ')) : '') +
|
|
1259
|
+
'\n');
|
|
1225
1260
|
};
|
|
1226
|
-
var executeCommandForEachModule = function (modules, command,
|
|
1261
|
+
var executeCommandForEachModule = function (modules, command, filterMethod, filterValue) {
|
|
1227
1262
|
//if a specific set of modules is given
|
|
1228
|
-
if (
|
|
1263
|
+
if (filterMethod == 'exclude') {
|
|
1229
1264
|
//filter modules, so that we only execute on the modules as provided in the command
|
|
1230
|
-
|
|
1231
|
-
|
|
1232
|
-
|
|
1265
|
+
log('Excluding ' + filterValue);
|
|
1266
|
+
filterValue = filterValue.split(',');
|
|
1267
|
+
modules = modules.filter(function (module) { return filterValue.indexOf(module.moduleName) === -1; });
|
|
1233
1268
|
}
|
|
1234
|
-
|
|
1235
|
-
|
|
1236
|
-
|
|
1237
|
-
|
|
1238
|
-
|
|
1239
|
-
|
|
1269
|
+
var startFrom;
|
|
1270
|
+
//by default start executing, unless 'from' is given
|
|
1271
|
+
var executing = true;
|
|
1272
|
+
//option to start from a specific module in the stack
|
|
1273
|
+
if (filterMethod == 'from') {
|
|
1274
|
+
startFrom = filterValue;
|
|
1275
|
+
if (startFrom) {
|
|
1276
|
+
console.log(chalk.blue('Will skip ahead to ' + startFrom));
|
|
1277
|
+
}
|
|
1278
|
+
var seen_1 = false;
|
|
1279
|
+
modules = modules.filter(function (module) {
|
|
1280
|
+
if (!seen_1 && (module.moduleName == startFrom || module.packageName == startFrom)) {
|
|
1281
|
+
seen_1 = true;
|
|
1282
|
+
}
|
|
1283
|
+
return seen_1;
|
|
1284
|
+
});
|
|
1240
1285
|
}
|
|
1241
|
-
log("Executing '" + command + "' on modules " + modules.map(function (m) { return m.moduleName; }).join(', '));
|
|
1286
|
+
log("Executing '" + chalk.blueBright(command) + "' on modules " + chalk.magenta(modules.map(function (m) { return m.moduleName; }).join(', ')));
|
|
1242
1287
|
var p = Promise.resolve(true);
|
|
1243
1288
|
modules.forEach(function (module) {
|
|
1244
1289
|
p = p.then(function () {
|
|
1245
|
-
log('#
|
|
1290
|
+
log('# Package ' + chalk.magenta(module.moduleName));
|
|
1246
1291
|
return execp('cd ' + module.path + ' && ' + command);
|
|
1247
1292
|
});
|
|
1248
1293
|
});
|
package/lib/config-webpack.js
CHANGED
|
@@ -32,6 +32,7 @@ var path = require('path');
|
|
|
32
32
|
var BundleAnalyzerPlugin = require('webpack-bundle-analyzer').BundleAnalyzerPlugin;
|
|
33
33
|
var TerserPlugin = require('terser-webpack-plugin');
|
|
34
34
|
var exec = require('child_process').exec;
|
|
35
|
+
var CopyPlugin = require("copy-webpack-plugin");
|
|
35
36
|
var NODE_ENV = process.env.NODE_ENV;
|
|
36
37
|
var nodeProduction = NODE_ENV == 'production';
|
|
37
38
|
// const libraryName = 'lincd';
|
|
@@ -77,6 +78,24 @@ function generateWebpackConfig(buildName, moduleName, config) {
|
|
|
77
78
|
// return packageName.indexOf('lincd') !== -1;
|
|
78
79
|
// },
|
|
79
80
|
// }),
|
|
81
|
+
//NOTE: grunt comes with a copy task, which is ran during `yarn lincd build` but cannot run during `yarn lincd dev`
|
|
82
|
+
//so here we ALSO copy the same files to cover dev flow
|
|
83
|
+
new CopyPlugin({
|
|
84
|
+
patterns: [
|
|
85
|
+
{
|
|
86
|
+
from: "src/**/*.scss",
|
|
87
|
+
to: function (_a) {
|
|
88
|
+
var context = _a.context, absoluteFilename = _a.absoluteFilename;
|
|
89
|
+
// console.log(chalk.magenta(context),chalk.magenta(absoluteFilename),process.cwd());
|
|
90
|
+
//turn absolute path into the right lib path (lib is NOT in webpack output path, so need to use '../')
|
|
91
|
+
var outputPath = absoluteFilename.replace(process.cwd(), '').replace('/src/', '../lib/');
|
|
92
|
+
// console.log(chalk.blueBright(outputPath));
|
|
93
|
+
return Promise.resolve(outputPath);
|
|
94
|
+
},
|
|
95
|
+
noErrorOnMissing: true
|
|
96
|
+
},
|
|
97
|
+
]
|
|
98
|
+
}),
|
|
80
99
|
];
|
|
81
100
|
if (config.debug) {
|
|
82
101
|
plugins.push(new watch_run_1["default"]());
|
|
@@ -146,7 +165,7 @@ function generateWebpackConfig(buildName, moduleName, config) {
|
|
|
146
165
|
// "postcss-scss": {}, //<-- only add this back if the build gets stuck on //comments in scss files, but I dont think that will be the case anymore
|
|
147
166
|
'postcss-modules': {
|
|
148
167
|
// //by default postcss-modules will put out a json file right next to the original css / scss file, this method defines what classnames to use
|
|
149
|
-
generateScopedName: utils_1.generateScopedName,
|
|
168
|
+
generateScopedName: utils_1.generateScopedName.bind(null, moduleName),
|
|
150
169
|
globalModulePaths: [/tailwind/]
|
|
151
170
|
},
|
|
152
171
|
tailwindcss: {
|
package/lib/utils.js
CHANGED
|
@@ -55,6 +55,7 @@ exports.flatten = exports.warn = exports.debug = exports.log = exports.generateS
|
|
|
55
55
|
var fs = __importStar(require("fs"));
|
|
56
56
|
var path = __importStar(require("path"));
|
|
57
57
|
var chalk_1 = __importDefault(require("chalk"));
|
|
58
|
+
// const {findNearestPackageJson, findNearestPackageJsonSync} = require('find-nearest-package-json');
|
|
58
59
|
var getPackageJSON = function (root, error) {
|
|
59
60
|
if (root === void 0) { root = process.cwd(); }
|
|
60
61
|
if (error === void 0) { error = true; }
|
|
@@ -88,7 +89,13 @@ export function getShapes(packageExports): CoreSet<SHACL_Shape> {
|
|
|
88
89
|
}
|
|
89
90
|
return shapes;
|
|
90
91
|
}*/
|
|
91
|
-
function generateScopedName(name, filename, css) {
|
|
92
|
+
function generateScopedName(moduleName, name, filename, css) {
|
|
93
|
+
// console.log(moduleName,name,filename,css);
|
|
94
|
+
// var file = path.basename(filename, '.scss');
|
|
95
|
+
// let nearestPackageJson = findNearestPackageJsonSync(filename);
|
|
96
|
+
// let packageName = nearestPackageJson ? nearestPackageJson.data.name : packageJson.name;
|
|
97
|
+
// return packageName.replace(/[^a-zA-Z0-9_]+/g, '_') + '_' + file + '_' + name;
|
|
98
|
+
// process.exit();
|
|
92
99
|
var path = require('path');
|
|
93
100
|
var file = path.basename(filename, '.scss');
|
|
94
101
|
var module = filename.match(/[\\\/]modules[\\\/]([\w\-_]+)/);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "lincd-cli",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.23",
|
|
4
4
|
"description": "Command line tools for the lincd.js library",
|
|
5
5
|
"main": "lib/index.js",
|
|
6
6
|
"scripts": {
|
|
@@ -18,6 +18,7 @@
|
|
|
18
18
|
"repository": "https://github.com:Semantu/lincd.org",
|
|
19
19
|
"author": {
|
|
20
20
|
"name": "René Verheij",
|
|
21
|
+
"url": "https://github.com/flyon",
|
|
21
22
|
"email": "rpwverheij@gmail.com"
|
|
22
23
|
},
|
|
23
24
|
"license": "MPL-2.0",
|
|
@@ -40,6 +41,7 @@
|
|
|
40
41
|
"child-process-promise": "^2.2.1",
|
|
41
42
|
"colors": "^1.4.0",
|
|
42
43
|
"commander": "^9.4.0",
|
|
44
|
+
"copy-webpack-plugin": "^11.0.0",
|
|
43
45
|
"css-loader": "^6.7.1",
|
|
44
46
|
"fs-extra": "^10.1.0",
|
|
45
47
|
"glob": "^7.1.6",
|