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.
- package/defaults/app/Gruntfile.js +1 -1
- package/defaults/app/index.html +3 -3
- package/defaults/app/package.json +3 -3
- package/defaults/app/src/App.tsx +1 -1
- package/lib/cli.js +39 -22
- package/package.json +1 -1
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
var buildTools = require('lincd-cli');
|
|
2
|
-
module.exports = buildTools.generateGruntConfig('${
|
|
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
|
package/defaults/app/index.html
CHANGED
|
@@ -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/${
|
|
6
|
-
<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/${
|
|
10
|
+
<script src="./dist/${hyphen_name}.js"></script>
|
|
11
11
|
</body>
|
|
12
12
|
</html>
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
{
|
|
2
|
-
"name": "${
|
|
3
|
-
"displayName": "${
|
|
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/${
|
|
8
|
+
"types": "dist/${hyphen_name}.d.ts",
|
|
9
9
|
"author": "",
|
|
10
10
|
"license": "ISC",
|
|
11
11
|
"scripts": {
|
package/defaults/app/src/App.tsx
CHANGED
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,
|
|
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
|
|
807
|
-
targetFolder = path.join(basePath,
|
|
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
|
-
|
|
823
|
-
|
|
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
|
-
|
|
833
|
-
installCommand =
|
|
834
|
-
|
|
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 ' +
|
|
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
|
});
|