lincd-cli 0.2.0 → 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 ADDED
@@ -0,0 +1,3 @@
1
+ always-auth = true
2
+ version-github-tag = false
3
+ //registry.npmjs.org/:_authToken=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
@@ -22,9 +22,9 @@
22
22
  "web3"
23
23
  ],
24
24
  "dependencies": {
25
- "lincd": "^0.4"
25
+ "lincd": "^0.5"
26
26
  },
27
27
  "devDependencies": {
28
- "lincd-cli": "^0.1"
28
+ "lincd-cli": "^0.2"
29
29
  }
30
30
  }
@@ -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,10 @@
1
+ import { CapacitorConfig } from '@capacitor/cli';
2
+
3
+ const config: CapacitorConfig = {
4
+ appId: 'com.mydomain.FILL_IN_YOUR_OWN',
5
+ appName: 'FILL_IN_YOUR_OWN',
6
+ webDir: 'frontend/web',
7
+ bundledWebRuntime: false
8
+ };
9
+
10
+ export default config;
@@ -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
+ );
@@ -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.4",
43
+ "lincd": "^0.5",
41
44
  "lincd-jsonld": "^0.1.5",
42
45
  "lincd-server": "^0.1",
43
46
  "react": "^18.2",
@@ -49,7 +52,7 @@
49
52
  "@types/react": "^18.0.17",
50
53
  "@types/react-dom": "^18.0.6",
51
54
  "env-cmd": "^10.1.0",
52
- "lincd-cli": "^0.1",
55
+ "lincd-cli": "^0.2",
53
56
  "nodemon": "^2.0.6"
54
57
  }
55
58
  }
@@ -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, sourceShape}) => {
7
+ export const ${camel_name} = linkedComponent<SHAPE>(SHAPE,({source}) => {
8
8
  return <div className={style.${camel_name}}></div>;
9
9
  });
10
10
 
@@ -29,10 +29,10 @@
29
29
  "web3"
30
30
  ],
31
31
  "dependencies": {
32
- "lincd": "^0.4",
32
+ "lincd": "^0.5",
33
33
  "lincd-jsonld": "^0.1"
34
34
  },
35
35
  "devDependencies": {
36
- "lincd-cli": "^0.1"
36
+ "lincd-cli": "^0.2"
37
37
  }
38
38
  }
@@ -1,20 +1,8 @@
1
1
  import React from "react";
2
2
  import {ExampleShapeClass} from "../shapes/ExampleShapeClass";
3
- import {linkedComponentClass,linkedComponent} from '../package';
4
- import {LinkedComponentClass} from 'lincd/lib/utils/LinkedComponentClass';
3
+ import {linkedComponent} from '../package';
5
4
 
6
- export const ExampleComponent = linkedComponent<ExampleShapeClass>(ExampleShapeClass, ({source, sourceShape}) => {
7
- //note that typescript knows that person has the type of the Shape you provided
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);
@@ -0,0 +1,3 @@
1
+ #!/usr/bin/env node
2
+ // console.log('forwarding to grunt: ', process.argv.slice(2).join(' '));
3
+ require('grunt-cli/bin/grunt');
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);
@@ -162,7 +169,7 @@ program.command('dev [target] [mode]').action(function (target, mode) {
162
169
  developPackage(target, mode);
163
170
  });
164
171
  program
165
- .command('module|m|package|p|pkg')
172
+ .command('package')
166
173
  .action(function (name, command, args) {
167
174
  var fullCommand = command
168
175
  ? command +
@@ -175,11 +182,17 @@ program
175
182
  : null;
176
183
  executeCommandForPackage(name, fullCommand);
177
184
  })
185
+ .alias('p')
186
+ .alias('pkg')
178
187
  .alias('m')
188
+ .alias('module')
179
189
  .description('Searches for a package in this workspace with a partially matching name and executes a command for that package (without needing to execute it from the folder of the package)')
180
190
  .argument('<name>', 'the name of the package. Can be a part of the name.')
181
191
  .argument('[command]', 'the lincd command you want to execute. Like dev or build')
182
192
  .argument('[args...]', 'the additional arguments of that command');
193
+ program.command('add-capacitor').action(function () {
194
+ addCapacitor();
195
+ });
183
196
  function logHelp() {
184
197
  execp('yarn lincd help');
185
198
  }
@@ -372,7 +385,7 @@ function runOnPackagesGroupedByDependencies(lincdPackages, onBuildStack, onStack
372
385
  //starts the process
373
386
  runStack(startStack);
374
387
  }
375
- function buildAll(target, target2) {
388
+ function buildAll(target, target2, target3) {
376
389
  var _this = this;
377
390
  console.log('Building all LINCD packages of this repository in order of dependencies');
378
391
  var lincdPackages = getLocalLincdPackageMap();
@@ -388,9 +401,17 @@ function buildAll(target, target2) {
388
401
  target = '';
389
402
  target2 = '';
390
403
  console.log(chalk.blue('Will skip builds until ' + startFrom));
391
- return function (pkg) { return __awaiter(_this, void 0, void 0, function () { return __generator(this, function (_a) {
392
- return [2 /*return*/];
393
- }); }); };
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) => {};
394
415
  }
395
416
  var done = new Set();
396
417
  var failedModules = [];
@@ -445,6 +466,7 @@ function buildAll(target, target2) {
445
466
  }
446
467
  })
447
468
  .then(function (res) {
469
+ log(chalk.green('Built ' + pkg.packageName));
448
470
  done.add(pkg);
449
471
  packagesLeft--;
450
472
  // log(chalk.magenta(packagesLeft + ' packages left'));
@@ -822,6 +844,33 @@ var createShape = function (name, basePath) {
822
844
  });
823
845
  });
824
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
+ };
825
874
  var createComponent = function (name, basePath) {
826
875
  if (basePath === void 0) { basePath = process.cwd(); }
827
876
  return __awaiter(void 0, void 0, void 0, function () {
@@ -949,7 +998,7 @@ var createApp = function (name, basePath) {
949
998
  fs.copySync(path.join(__dirname, '..', 'defaults', 'app-with-backend'), targetFolder);
950
999
  // fs.copySync(path.join(__dirname, '..', 'defaults', 'app'), targetFolder);
951
1000
  log("Creating new LINCD application '" + name + "'");
952
- //replace variables in some of the copied files
1001
+ //replace variables in some copied files
953
1002
  replaceVariablesInFilesWithRoot(targetFolder, 'package.json', 'frontend/src/App.tsx', 'frontend/src/App.scss.json', 'frontend/src/components/Spinner.scss.json');
954
1003
  return [4 /*yield*/, hasYarnInstalled()];
955
1004
  case 1:
@@ -1431,6 +1480,31 @@ var executeCommandForEachPackage = function (packages, command, filterMethod, fi
1431
1480
  });
1432
1481
  return p;
1433
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
+ };
1434
1508
  var executeCommandForPackage = function (packageName, command) {
1435
1509
  var packageDetails = getLincdPackages().find(function (modDetails) {
1436
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.0",
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.4",
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
+ }