lincd-cli 0.2.1 → 0.2.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.
- package/.npmrc +3 -0
- package/defaults/app/package.json +1 -1
- package/defaults/app-static/.env-cmdrc.json +10 -0
- package/defaults/app-static/capacitor.config.ts +10 -0
- package/defaults/app-static/frontend/src/index-static.tsx +16 -0
- package/defaults/app-static/frontend/web/apple-touch-icon-144x144.png +0 -0
- package/defaults/app-static/frontend/web/apple-touch-icon-57x57.png +0 -0
- package/defaults/app-static/frontend/web/apple-touch-icon-72x72.png +0 -0
- package/defaults/app-static/frontend/web/index.html +21 -0
- package/defaults/app-with-backend/package.json +4 -1
- package/defaults/component.tsx +1 -1
- package/defaults/package/package.json +1 -1
- package/defaults/package/src/components/ExampleComponent.tsx +3 -15
- package/defaults/set-component.tsx +16 -0
- package/expose-grunt.js +3 -0
- package/lib/cli.js +78 -7
- package/package.json +5 -3
- package/yarn-error.log +12933 -0
- package/defaults/app-with-backend/.gitignore +0 -4
- package/defaults/package/.npmignore +0 -6
- package/defaults/package/Gruntfile.js +0 -16
- package/defaults/package/tsconfig-es5.json +0 -18
- package/defaults/package/tsconfig.json +0 -22
package/.npmrc
ADDED
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
{
|
|
2
|
+
"static-dev": {
|
|
3
|
+
"NODE_ENV": "production",
|
|
4
|
+
"SITE_ROOT": "http://localhost:4000",
|
|
5
|
+
"DATA_ROOT": "https://coolbock.lincd.org/data",
|
|
6
|
+
"OUTPUT_PATH" : "./frontend/web/assets",
|
|
7
|
+
"ASSET_PATH" : "./assets/",
|
|
8
|
+
"ENTRY_PATH" : "./frontend/src/index-static.tsx"
|
|
9
|
+
}
|
|
10
|
+
}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import ReactDOM from 'react-dom/client';
|
|
3
|
+
import {BrowserRouter} from 'react-router-dom';
|
|
4
|
+
import App from './App';
|
|
5
|
+
|
|
6
|
+
const root = ReactDOM.createRoot(
|
|
7
|
+
document.getElementById('root') as HTMLElement
|
|
8
|
+
);
|
|
9
|
+
|
|
10
|
+
root.render(
|
|
11
|
+
<React.StrictMode>
|
|
12
|
+
<BrowserRouter>
|
|
13
|
+
<App assets={window['assetManifest']} />
|
|
14
|
+
</BrowserRouter>
|
|
15
|
+
</React.StrictMode>,
|
|
16
|
+
);
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
<!DOCTYPE html>
|
|
2
|
+
<html lang="en">
|
|
3
|
+
<head>
|
|
4
|
+
<meta charSet="utf-8"/>
|
|
5
|
+
<meta name="viewport" content="width=device-width, initial-scale=1"/>
|
|
6
|
+
<link rel="stylesheet" href="./assets/main.css"/>
|
|
7
|
+
<title>Cool Block | Cool City Challenge | Community Based Empowerment</title>
|
|
8
|
+
<link rel="shortcut icon" href="./favicon.ico"/>
|
|
9
|
+
<link rel="apple-touch-icon" href="./apple-touch-icon-144x144.png" sizes="144x144"/>
|
|
10
|
+
<link rel="apple-touch-icon" href="./apple-touch-icon-72x72.png" sizes="72x72"/>
|
|
11
|
+
<link rel="apple-touch-icon" href="./apple-touch-icon-57x57.png" sizes="57x57"/>
|
|
12
|
+
<meta name="description"
|
|
13
|
+
content="The Cool Block is a how-to guide for local communities to make a significant impact on climate change. The Cool Block program helps citizens get engage in a grassroots initiative to be planet friendly, disaster resilient and community rich."/>
|
|
14
|
+
<script src="./assets/main.bundle.js" async=""></script>
|
|
15
|
+
</head>
|
|
16
|
+
<body>
|
|
17
|
+
<noscript><b>Enable JavaScript to run this app.</b></noscript><!--$-->
|
|
18
|
+
<div id="root"></div>
|
|
19
|
+
<script>assetManifest = {"main.js": "./assets/main.bundle.js", "main.css": "./assets/main.css"};</script>
|
|
20
|
+
</body>
|
|
21
|
+
</html>
|
|
@@ -20,6 +20,9 @@
|
|
|
20
20
|
"server:dev": "env-cmd -e dev nodemon --watch ../../modules/lincd-server/lib --watch ../../modules/lincd-server/site.webpack.config.js ./backend/server.js",
|
|
21
21
|
"server:prod": "env-cmd -e prod nodemon -e js,json s ./backend/server.js"
|
|
22
22
|
},
|
|
23
|
+
"workspaces" : [
|
|
24
|
+
"modules/*"
|
|
25
|
+
],
|
|
23
26
|
"keywords": [
|
|
24
27
|
"lincd",
|
|
25
28
|
"linked code",
|
|
@@ -37,7 +40,7 @@
|
|
|
37
40
|
"@babel/preset-react": "^7.18.6",
|
|
38
41
|
"@babel/preset-typescript": "^7.18.6",
|
|
39
42
|
"@babel/register": "^7.18.9",
|
|
40
|
-
"lincd": "^0.
|
|
43
|
+
"lincd": "^0.5",
|
|
41
44
|
"lincd-jsonld": "^0.1.5",
|
|
42
45
|
"lincd-server": "^0.1",
|
|
43
46
|
"react": "^18.2",
|
package/defaults/component.tsx
CHANGED
|
@@ -4,7 +4,7 @@ import {default as style} from "./${hyphen_name}.scss.json";
|
|
|
4
4
|
import {registerPackageModule,linkedComponent} from '../package';
|
|
5
5
|
|
|
6
6
|
//TODO: replace SHAPE with an actual Shape class
|
|
7
|
-
export const ${camel_name} = linkedComponent<SHAPE>(SHAPE,({source
|
|
7
|
+
export const ${camel_name} = linkedComponent<SHAPE>(SHAPE,({source}) => {
|
|
8
8
|
return <div className={style.${camel_name}}></div>;
|
|
9
9
|
});
|
|
10
10
|
|
|
@@ -1,20 +1,8 @@
|
|
|
1
1
|
import React from "react";
|
|
2
2
|
import {ExampleShapeClass} from "../shapes/ExampleShapeClass";
|
|
3
|
-
import {
|
|
4
|
-
import {LinkedComponentClass} from 'lincd/lib/utils/LinkedComponentClass';
|
|
3
|
+
import {linkedComponent} from '../package';
|
|
5
4
|
|
|
6
|
-
export const ExampleComponent = linkedComponent<ExampleShapeClass>(ExampleShapeClass, ({source
|
|
7
|
-
//note that typescript knows that
|
|
5
|
+
export const ExampleComponent = linkedComponent<ExampleShapeClass>(ExampleShapeClass, ({source}) => {
|
|
6
|
+
//note that typescript knows that 'source' is an instance of the Shape you linked this component to
|
|
8
7
|
return <div></div>;
|
|
9
8
|
});
|
|
10
|
-
|
|
11
|
-
//alternatively, use a Class component if you prefer:
|
|
12
|
-
/*@linkedComponentClass(ExampleShapeClass)
|
|
13
|
-
export class ExampleComponent extends LinkedComponentClass<ExampleShapeClass> {
|
|
14
|
-
render() {
|
|
15
|
-
let exampleInstance = this.sourceShape;
|
|
16
|
-
|
|
17
|
-
//get the name of this item from the graph
|
|
18
|
-
return <h1>Hello {exampleInstance.name}!</h1>;
|
|
19
|
-
}
|
|
20
|
-
}*/
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
import "./${hyphen_name}.scss";
|
|
3
|
+
import {default as style} from "./${hyphen_name}.scss.json";
|
|
4
|
+
import {registerPackageModule,linkedSetComponent} from '../package';
|
|
5
|
+
|
|
6
|
+
//TODO: replace SHAPE with an actual Shape class
|
|
7
|
+
export const ${camel_name} = linkedSetComponent<SHAPE>(SHAPE,({sources}) => {
|
|
8
|
+
return <div className={style.${camel_name}}>
|
|
9
|
+
{sources.map(source => {
|
|
10
|
+
return <div key={source.toString()}></div>;
|
|
11
|
+
})}
|
|
12
|
+
</div>;
|
|
13
|
+
});
|
|
14
|
+
|
|
15
|
+
//register all components in this file
|
|
16
|
+
registerPackageModule(module);
|
package/expose-grunt.js
ADDED
package/lib/cli.js
CHANGED
|
@@ -102,6 +102,13 @@ program
|
|
|
102
102
|
})
|
|
103
103
|
.description('Creates a new Component file for your package. Execute this from your package folder.')
|
|
104
104
|
.argument('<name>', 'The name of the component. Will be used for the file name and the export name');
|
|
105
|
+
program
|
|
106
|
+
.command('create-set-component')
|
|
107
|
+
.action(function (name, uriBase) {
|
|
108
|
+
return createSetComponent(name);
|
|
109
|
+
})
|
|
110
|
+
.description('Creates a new SetComponent file for your package. Execute this from your package folder.')
|
|
111
|
+
.argument('<name>', 'The name of the component. Will be used for the file name and the export name');
|
|
105
112
|
program
|
|
106
113
|
.command('create-ontology')
|
|
107
114
|
.action(function (prefix, uriBase) {
|
|
@@ -149,8 +156,8 @@ program.command('build-updated [target] [target2]').action(function (target, tar
|
|
|
149
156
|
program.command('build-updated-since [num-commits-back] [target] [target2]').action(function (back, target, target2) {
|
|
150
157
|
return buildUpdated(back, target, target2);
|
|
151
158
|
});
|
|
152
|
-
program.command('build-all [target] [target2]').action(function (target, target2) {
|
|
153
|
-
buildAll(target, target2);
|
|
159
|
+
program.command('build-all [target] [target2] [target3]').action(function (target, target2, target3) {
|
|
160
|
+
buildAll(target, target2, target3);
|
|
154
161
|
});
|
|
155
162
|
program.command('all [action] [filter] [filter-value]').action(function (command, filter, filterValue) {
|
|
156
163
|
executeCommandForEachPackage(getLincdPackages(), command, filter, filterValue);
|
|
@@ -183,6 +190,9 @@ program
|
|
|
183
190
|
.argument('<name>', 'the name of the package. Can be a part of the name.')
|
|
184
191
|
.argument('[command]', 'the lincd command you want to execute. Like dev or build')
|
|
185
192
|
.argument('[args...]', 'the additional arguments of that command');
|
|
193
|
+
program.command('add-capacitor').action(function () {
|
|
194
|
+
addCapacitor();
|
|
195
|
+
});
|
|
186
196
|
function logHelp() {
|
|
187
197
|
execp('yarn lincd help');
|
|
188
198
|
}
|
|
@@ -375,7 +385,7 @@ function runOnPackagesGroupedByDependencies(lincdPackages, onBuildStack, onStack
|
|
|
375
385
|
//starts the process
|
|
376
386
|
runStack(startStack);
|
|
377
387
|
}
|
|
378
|
-
function buildAll(target, target2) {
|
|
388
|
+
function buildAll(target, target2, target3) {
|
|
379
389
|
var _this = this;
|
|
380
390
|
console.log('Building all LINCD packages of this repository in order of dependencies');
|
|
381
391
|
var lincdPackages = getLocalLincdPackageMap();
|
|
@@ -391,9 +401,17 @@ function buildAll(target, target2) {
|
|
|
391
401
|
target = '';
|
|
392
402
|
target2 = '';
|
|
393
403
|
console.log(chalk.blue('Will skip builds until ' + startFrom));
|
|
394
|
-
return
|
|
395
|
-
|
|
396
|
-
|
|
404
|
+
// return async (pkg) => {};
|
|
405
|
+
}
|
|
406
|
+
if (target2 == 'from') {
|
|
407
|
+
startFrom = target3;
|
|
408
|
+
//if we have a startFrom, then we havnt started the build process yet
|
|
409
|
+
building = startFrom ? false : true;
|
|
410
|
+
//clear targets
|
|
411
|
+
target2 = '';
|
|
412
|
+
target3 = '';
|
|
413
|
+
console.log(chalk.blue('Will skip builds until ' + startFrom));
|
|
414
|
+
// return async (pkg) => {};
|
|
397
415
|
}
|
|
398
416
|
var done = new Set();
|
|
399
417
|
var failedModules = [];
|
|
@@ -448,6 +466,7 @@ function buildAll(target, target2) {
|
|
|
448
466
|
}
|
|
449
467
|
})
|
|
450
468
|
.then(function (res) {
|
|
469
|
+
log(chalk.green('Built ' + pkg.packageName));
|
|
451
470
|
done.add(pkg);
|
|
452
471
|
packagesLeft--;
|
|
453
472
|
// log(chalk.magenta(packagesLeft + ' packages left'));
|
|
@@ -825,6 +844,33 @@ var createShape = function (name, basePath) {
|
|
|
825
844
|
});
|
|
826
845
|
});
|
|
827
846
|
};
|
|
847
|
+
var createSetComponent = function (name, basePath) {
|
|
848
|
+
if (basePath === void 0) { basePath = process.cwd(); }
|
|
849
|
+
return __awaiter(void 0, void 0, void 0, function () {
|
|
850
|
+
var targetFolder, _a, hyphenName, camelCaseName, underscoreName, targetFile, targetFile2, indexPath;
|
|
851
|
+
return __generator(this, function (_b) {
|
|
852
|
+
switch (_b.label) {
|
|
853
|
+
case 0:
|
|
854
|
+
targetFolder = ensureFolderExists(basePath, 'src', 'components');
|
|
855
|
+
_a = setNameVariables(name), hyphenName = _a.hyphenName, camelCaseName = _a.camelCaseName, underscoreName = _a.underscoreName;
|
|
856
|
+
//copy default shape file
|
|
857
|
+
log("Creating files for set component '" + name + "'");
|
|
858
|
+
targetFile = path.join(targetFolder, hyphenName + '.tsx');
|
|
859
|
+
fs.copySync(path.join(__dirname, '..', 'defaults', 'set-component.tsx'), targetFile);
|
|
860
|
+
targetFile2 = path.join(targetFolder, hyphenName + '.scss');
|
|
861
|
+
fs.copySync(path.join(__dirname, '..', 'defaults', 'component.scss'), targetFile2);
|
|
862
|
+
//replace variables in some of the copied files
|
|
863
|
+
return [4 /*yield*/, replaceVariablesInFiles(targetFile, targetFile2)];
|
|
864
|
+
case 1:
|
|
865
|
+
//replace variables in some of the copied files
|
|
866
|
+
_b.sent();
|
|
867
|
+
indexPath = addLineToIndex("import './components/".concat(hyphenName, "';"), 'components');
|
|
868
|
+
log("Created a new set component in ".concat(chalk.magenta(targetFile.replace(basePath, ''))), "Created a new stylesheet in ".concat(chalk.magenta(targetFile2.replace(basePath, ''))), "Added an import of this file from ".concat(chalk.magenta(indexPath)));
|
|
869
|
+
return [2 /*return*/];
|
|
870
|
+
}
|
|
871
|
+
});
|
|
872
|
+
});
|
|
873
|
+
};
|
|
828
874
|
var createComponent = function (name, basePath) {
|
|
829
875
|
if (basePath === void 0) { basePath = process.cwd(); }
|
|
830
876
|
return __awaiter(void 0, void 0, void 0, function () {
|
|
@@ -952,7 +998,7 @@ var createApp = function (name, basePath) {
|
|
|
952
998
|
fs.copySync(path.join(__dirname, '..', 'defaults', 'app-with-backend'), targetFolder);
|
|
953
999
|
// fs.copySync(path.join(__dirname, '..', 'defaults', 'app'), targetFolder);
|
|
954
1000
|
log("Creating new LINCD application '" + name + "'");
|
|
955
|
-
//replace variables in some
|
|
1001
|
+
//replace variables in some copied files
|
|
956
1002
|
replaceVariablesInFilesWithRoot(targetFolder, 'package.json', 'frontend/src/App.tsx', 'frontend/src/App.scss.json', 'frontend/src/components/Spinner.scss.json');
|
|
957
1003
|
return [4 /*yield*/, hasYarnInstalled()];
|
|
958
1004
|
case 1:
|
|
@@ -1434,6 +1480,31 @@ var executeCommandForEachPackage = function (packages, command, filterMethod, fi
|
|
|
1434
1480
|
});
|
|
1435
1481
|
return p;
|
|
1436
1482
|
};
|
|
1483
|
+
var addCapacitor = function (basePath) {
|
|
1484
|
+
if (basePath === void 0) { basePath = process.cwd(); }
|
|
1485
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
1486
|
+
var targetFolder, pack;
|
|
1487
|
+
return __generator(this, function (_a) {
|
|
1488
|
+
switch (_a.label) {
|
|
1489
|
+
case 0:
|
|
1490
|
+
targetFolder = ensureFolderExists(basePath);
|
|
1491
|
+
log('Adding capacitor');
|
|
1492
|
+
fs.copySync(path.join(__dirname, '..', 'defaults', 'app-static'), targetFolder);
|
|
1493
|
+
pack = (0, utils_1.getPackageJSON)(basePath);
|
|
1494
|
+
pack.scripts['build-static'] = 'env-cmd -e static-dev node frontend/scripts/build.js';
|
|
1495
|
+
fs.writeFile(path.resolve(basePath, 'package.json'), JSON.stringify(pack));
|
|
1496
|
+
return [4 /*yield*/, execPromise("yarn add -W -D @capacitor/cli", false, false, null, true)];
|
|
1497
|
+
case 1:
|
|
1498
|
+
_a.sent();
|
|
1499
|
+
return [4 /*yield*/, execPromise("yarn add -W @capacitor/android @capacitor/core @capacitor/geolocation @capacitor/ios @capacitor/push-notifications", false, false, null, true)];
|
|
1500
|
+
case 2:
|
|
1501
|
+
_a.sent();
|
|
1502
|
+
log('Done! Run `yarn build-static` to generate static bundles. Then `yarn cap add android` or `yarn cap add ios`');
|
|
1503
|
+
return [2 /*return*/];
|
|
1504
|
+
}
|
|
1505
|
+
});
|
|
1506
|
+
});
|
|
1507
|
+
};
|
|
1437
1508
|
var executeCommandForPackage = function (packageName, command) {
|
|
1438
1509
|
var packageDetails = getLincdPackages().find(function (modDetails) {
|
|
1439
1510
|
return modDetails.packageName.indexOf(packageName) !== -1 || modDetails.packageName.indexOf(packageName) !== -1;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "lincd-cli",
|
|
3
|
-
"version": "0.2.
|
|
3
|
+
"version": "0.2.2",
|
|
4
4
|
"description": "Command line tools for the lincd.js library",
|
|
5
5
|
"main": "lib/index.js",
|
|
6
6
|
"scripts": {
|
|
@@ -23,6 +23,7 @@
|
|
|
23
23
|
},
|
|
24
24
|
"license": "MPL-2.0",
|
|
25
25
|
"bin": {
|
|
26
|
+
"grunt": "expose-grunt.js",
|
|
26
27
|
"lincd": "lib/cli.js"
|
|
27
28
|
},
|
|
28
29
|
"dependencies": {
|
|
@@ -47,6 +48,7 @@
|
|
|
47
48
|
"fs-extra": "^10.1.0",
|
|
48
49
|
"glob": "^7.1.6",
|
|
49
50
|
"grunt": "^1.3.0",
|
|
51
|
+
"grunt-cli": "^1.4.3",
|
|
50
52
|
"grunt-concurrent": "^3.0.0",
|
|
51
53
|
"grunt-contrib-clean": "^2.0.0",
|
|
52
54
|
"grunt-contrib-copy": "^1.0.0",
|
|
@@ -54,7 +56,7 @@
|
|
|
54
56
|
"grunt-ts": "^6.0.0-beta.22",
|
|
55
57
|
"grunt-webpack": "^5.0.0",
|
|
56
58
|
"license-info-webpack-plugin": "^3.0.0",
|
|
57
|
-
"lincd": "^0.
|
|
59
|
+
"lincd": "^0.5",
|
|
58
60
|
"lincd-jsonld": "^0.1.8",
|
|
59
61
|
"load-grunt-tasks": "^5.1.0",
|
|
60
62
|
"mini-css-extract-plugin": "^2.6.1",
|
|
@@ -84,4 +86,4 @@
|
|
|
84
86
|
"optimize-css-assets-webpack-plugin": "^6.0.1"
|
|
85
87
|
},
|
|
86
88
|
"peerDepencencies": {}
|
|
87
|
-
}
|
|
89
|
+
}
|