lincd-cli 0.1.10 → 0.1.11

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.
@@ -1,5 +1,5 @@
1
1
  var buildTools = require('lincd-cli');
2
- module.exports = buildTools.generateGruntConfig('${app_name}', {
2
+ module.exports = buildTools.generateGruntConfig('${hyphen_name}', {
3
3
  internals: '*', //for applications we tell the bundler to bundle everything
4
4
  //externals:{}, //list of non lincd modules that are already loaded and made globally available by one of the dependencies of this module
5
5
  //alias:{},//webpack alias -> maps on type of npm path to another
@@ -2,11 +2,11 @@
2
2
  <html>
3
3
  <head>
4
4
  <meta charset="utf-8" />
5
- <link rel="stylesheet" type="text/css" href="./dist/${app_name}.css">
6
- <title>${app_name}</title>
5
+ <link rel="stylesheet" type="text/css" href="./dist/${hyphen_name}.css">
6
+ <title>${name}</title>
7
7
  </head>
8
8
  <body>
9
9
  <div id="root"></div>
10
- <script src="./dist/${app_name}.js"></script>
10
+ <script src="./dist/${hyphen_name}.js"></script>
11
11
  </body>
12
12
  </html>
@@ -1,11 +1,11 @@
1
1
  {
2
- "name": "${app_name}",
3
- "displayName": "${app_name}",
2
+ "name": "${hyphen_name}",
3
+ "displayName": "${name}",
4
4
  "version": "0.1.0",
5
5
  "description": "",
6
6
  "lincd": true,
7
7
  "main": "lib/index.js",
8
- "types": "dist/${app_name}.d.ts",
8
+ "types": "dist/${hyphen_name}.d.ts",
9
9
  "author": "",
10
10
  "license": "ISC",
11
11
  "scripts": {
@@ -1,5 +1,5 @@
1
1
  import React from 'react';
2
2
  export function App()
3
3
  {
4
- return <div>${app_name} - LINCD App</div>;
4
+ return <div>${name} - LINCD App</div>;
5
5
  }
package/lib/cli.js CHANGED
@@ -649,6 +649,29 @@ var replaceVariablesInFiles = function () {
649
649
  return replaceVariablesInFile(file);
650
650
  }));
651
651
  };
652
+ var replaceVariablesInFilesWithRoot = function (root) {
653
+ var files = [];
654
+ for (var _i = 1; _i < arguments.length; _i++) {
655
+ files[_i - 1] = arguments[_i];
656
+ }
657
+ return replaceVariablesInFiles.apply(void 0, files.map(function (f) { return path.join(root, f); }));
658
+ };
659
+ var hasYarnInstalled = function () {
660
+ return __awaiter(this, void 0, void 0, function () {
661
+ var version;
662
+ return __generator(this, function (_a) {
663
+ switch (_a.label) {
664
+ case 0: return [4 /*yield*/, execPromise('yarn --version')["catch"](function (err) {
665
+ console.log('yarn probably not working');
666
+ return '';
667
+ })];
668
+ case 1:
669
+ version = (_a.sent());
670
+ return [2 /*return*/, version.toString().match(/[0-9]+/)];
671
+ }
672
+ });
673
+ });
674
+ };
652
675
  var ensureFolderExists = function () {
653
676
  var folders = [];
654
677
  for (var _i = 0; _i < arguments.length; _i++) {
@@ -796,48 +819,42 @@ var createModule = function (name, uriBase, basePath) {
796
819
  var createApp = function (name, basePath) {
797
820
  if (basePath === void 0) { basePath = process.cwd(); }
798
821
  return __awaiter(void 0, void 0, void 0, function () {
799
- var _a, packageName, scope, cleanPackageName, targetFolder, codeName, cameCaseName, underscoreName, version, installCommand;
822
+ var _a, hyphenName, camelCaseName, underscoreName, targetFolder, hasYarn, installCommand, lincdCommand;
800
823
  return __generator(this, function (_b) {
801
824
  switch (_b.label) {
802
825
  case 0:
803
826
  if (!name) {
804
827
  console.warn('Please provide a name as the first argument');
805
828
  }
806
- _a = name.match(/(@[\w\-]+\/)?([\w\-]+)/), packageName = _a[0], scope = _a[1], cleanPackageName = _a[2];
807
- targetFolder = path.join(basePath, name);
829
+ _a = setNameVariables(name), hyphenName = _a.hyphenName, camelCaseName = _a.camelCaseName, underscoreName = _a.underscoreName;
830
+ targetFolder = path.join(basePath, hyphenName);
808
831
  if (!fs.existsSync(targetFolder)) {
809
832
  fs.mkdirSync(targetFolder);
810
833
  }
811
834
  fs.copySync(path.join(__dirname, '..', 'defaults', 'app'), targetFolder);
812
- codeName = cleanPackageName.replace(/\-/g, '_');
813
- cameCaseName = camelCase(name);
814
- underscoreName = name.replace(/[-\s]+/g, '_');
835
+ // let codeName = cleanPackageName.replace(/\-/g, '_');
836
+ // let cameCaseName = camelCase(name); //some-module --> someModule
837
+ // let underscoreName = name.replace(/[-\s]+/g, '_');
815
838
  // setVariable('uri_base', uriBase);
816
839
  //longer similar variables names should come before the shorter ones
817
- setVariable('camelcase_name', cameCaseName);
818
- setVariable('underscore_name', underscoreName);
819
- setVariable('app_name', name);
840
+ // setVariable('camelcase_name', cameCaseName);
841
+ // setVariable('underscore_name', underscoreName);
842
+ // setVariable('app_name', name);
820
843
  log("Creating new LINCD application '" + name + "'");
821
844
  //replace variables in some of the copied files
822
- ['package.json', 'index.html', 'Gruntfile.js', 'src/index.tsx', 'src/App.tsx']
823
- .map(function (f) { return path.join(targetFolder, f); })
824
- .forEach(function (file) {
825
- replaceVariablesInFile(file);
826
- });
827
- return [4 /*yield*/, execPromise('yarn --version')["catch"](function (err) {
828
- console.log('yarn probably not working');
829
- return '';
830
- })];
845
+ replaceVariablesInFilesWithRoot(targetFolder, 'package.json', 'index.html', 'Gruntfile.js', 'src/index.tsx', 'src/App.tsx');
846
+ return [4 /*yield*/, hasYarnInstalled()];
831
847
  case 1:
832
- version = (_b.sent());
833
- installCommand = version.toString().match(/[0-9]+/) ? 'yarn install' : 'npm install';
834
- return [4 /*yield*/, execp("cd ".concat(name, " && ").concat(installCommand, " && npm exec lincd build"), true)["catch"](function (err) {
848
+ hasYarn = _b.sent();
849
+ installCommand = hasYarn ? 'yarn install' : 'npm install';
850
+ lincdCommand = hasYarn ? 'yarn lincd' : 'npm exec lincd';
851
+ return [4 /*yield*/, execp("cd ".concat(hyphenName, " && ").concat(installCommand, " && ").concat(hasYarn ? 'yarn' : 'npm exec', " lincd build"), true)["catch"](function (err) {
835
852
  console.warn('Could not install dependencies');
836
853
  })];
837
854
  case 2:
838
855
  _b.sent();
839
856
  open(path.join(targetFolder, 'index.html'));
840
- log("Your LINCD App starting setup is ready.", "Run ".concat(chalk.blueBright('cd ' + name), " and then run \n the ").concat(chalk.blueBright('build'), " script to build once or \n the ").concat(chalk.blueBright('dev'), " script to continuously rebuild on file changes"));
857
+ log("Your LINCD App starting setup is ready.", "Run ".concat(chalk.blueBright('cd ' + hyphenName), " and then \n - ").concat(chalk.blueBright(lincdCommand + ' build'), " to build once or \n - ").concat(chalk.blueBright(lincdCommand + ' dev'), " to continuously rebuild on file changes"));
841
858
  return [2 /*return*/];
842
859
  }
843
860
  });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "lincd-cli",
3
- "version": "0.1.10",
3
+ "version": "0.1.11",
4
4
  "description": "Command line tools for the lincd.js library",
5
5
  "main": "lib/index.js",
6
6
  "scripts": {