zcatalyst-cli 1.10.0 → 1.12.0

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.
Files changed (137) hide show
  1. package/docs/.DS_Store +0 -0
  2. package/docs/client-utils.toml +5 -0
  3. package/docs/command_needs/auth.toml +1 -1
  4. package/docs/optional-import.toml +10 -0
  5. package/docs/plugin-loader.toml +4 -0
  6. package/docs/serve/server/index.toml +4 -0
  7. package/docs/serve/server/lib/web_client/server.toml +4 -0
  8. package/lib/apig-utils.js +2 -1
  9. package/lib/archiver.js +3 -3
  10. package/lib/client-utils.js +8 -6
  11. package/lib/command_needs/auth.js +2 -2
  12. package/lib/commands/client/delete.js +1 -0
  13. package/lib/commands/event/generate/index.js +4 -13
  14. package/lib/commands/functions/shell.js +5 -2
  15. package/lib/commands/iac/import.js +29 -6
  16. package/lib/commands/init.js +1 -1
  17. package/lib/commands/pull.js +1 -1
  18. package/lib/commands/serve.js +2 -1
  19. package/lib/endpoints/lib/sdk.js +2 -2
  20. package/lib/error.js +16 -13
  21. package/lib/errorOut.js +2 -2
  22. package/lib/fn-utils/lib/common.js +6 -5
  23. package/lib/fn-utils/lib/java.js +1 -1
  24. package/lib/fn-utils/lib/node.js +2 -2
  25. package/lib/init/dependencies/npm-install.js +10 -10
  26. package/lib/init/features/client/index.js +47 -0
  27. package/lib/init/features/client/initializers/angular.js +104 -0
  28. package/lib/init/features/client/initializers/basic.js +50 -0
  29. package/lib/init/features/client/initializers/lyte.js +56 -0
  30. package/lib/init/features/client/initializers/react.js +78 -0
  31. package/lib/init/features/functions/languages/node.js +3 -1
  32. package/lib/init/features/index.js +10 -3
  33. package/lib/init/features/project.js +2 -1
  34. package/lib/init/util/client.js +89 -4
  35. package/lib/internal/command.js +4 -1
  36. package/lib/internal/config.js +2 -1
  37. package/lib/optional-import.js +27 -26
  38. package/lib/plugin-loader.js +27 -10
  39. package/lib/port-resolver.js +4 -2
  40. package/lib/serve/index.js +6 -1
  41. package/lib/serve/server/index.js +52 -8
  42. package/lib/serve/server/lib/master.js +24 -12
  43. package/lib/serve/server/lib/web_client/index.js +30 -0
  44. package/lib/serve/server/lib/web_client/server.js +171 -0
  45. package/lib/shell/index.js +10 -6
  46. package/lib/util_modules/char.js +1 -1
  47. package/lib/util_modules/config/lib/apig.js +2 -1
  48. package/lib/util_modules/config/lib/client.js +18 -21
  49. package/lib/util_modules/constants/index.js +3 -1
  50. package/lib/util_modules/constants/lib/placeholders.js +1 -0
  51. package/lib/util_modules/constants/lib/plugin.js +28 -0
  52. package/lib/util_modules/constants/lib/template.js +11 -1
  53. package/lib/util_modules/constants/lib/urls.js +29 -13
  54. package/lib/util_modules/{contextHelp.js → context-help.js} +0 -0
  55. package/lib/util_modules/env.js +13 -12
  56. package/lib/util_modules/fs/index.js +1 -9
  57. package/lib/util_modules/fs/lib/async.js +3 -3
  58. package/lib/util_modules/fs/utils.js +8 -0
  59. package/lib/util_modules/global-space.js +2 -0
  60. package/lib/util_modules/option.js +5 -1
  61. package/lib/util_modules/shell.js +10 -6
  62. package/lib/winston.js +1 -1
  63. package/package.json +7 -4
  64. package/templates/.DS_Store +0 -0
  65. package/templates/init/.DS_Store +0 -0
  66. package/templates/init/client/.DS_Store +0 -0
  67. package/templates/init/client/{client-package.json → basic/client-package.json} +0 -0
  68. package/templates/init/client/{index.html → basic/index.html} +0 -0
  69. package/templates/init/client/{main.css → basic/main.css} +0 -0
  70. package/templates/init/client/{main.js → basic/main.js} +0 -0
  71. package/templates/init/client/lyte/build/build.js +301 -0
  72. package/templates/init/client/lyte/build/scripts/cliDownloadScript.js +54 -0
  73. package/templates/init/client/lyte/client-package.json +5 -0
  74. package/templates/init/client/lyte/components/javascript/welcome-comp.js +13 -0
  75. package/templates/init/client/lyte/components/styles/welcome-comp.css +0 -0
  76. package/templates/init/client/lyte/components/templates/welcome-comp.html +8 -0
  77. package/templates/init/client/lyte/data-store/adapters/.gitkeep +0 -0
  78. package/templates/init/client/lyte/data-store/models/.gitkeep +0 -0
  79. package/templates/init/client/lyte/data-store/serializers/.gitkeep +0 -0
  80. package/templates/init/client/lyte/index.html +17 -0
  81. package/templates/init/client/lyte/package.json +12 -0
  82. package/templates/init/client/lyte/router.js +14 -0
  83. package/templates/init/client/lyte/routes/index.js +54 -0
  84. package/templates/init/client/react/.DS_Store +0 -0
  85. package/templates/init/client/react/react_js/package.json +11 -0
  86. package/templates/init/client/react/react_js/template/README.md +70 -0
  87. package/templates/init/client/react/react_js/template/client-package.json +5 -0
  88. package/templates/init/client/react/react_js/template/gitignore +23 -0
  89. package/templates/init/client/react/react_js/template/public/favicon.ico +0 -0
  90. package/templates/init/client/react/react_js/template/public/index.html +43 -0
  91. package/templates/init/client/react/react_js/template/public/logo192.png +0 -0
  92. package/templates/init/client/react/react_js/template/public/logo512.png +0 -0
  93. package/templates/init/client/react/react_js/template/public/manifest.json +25 -0
  94. package/templates/init/client/react/react_js/template/public/robots.txt +3 -0
  95. package/templates/init/client/react/react_js/template/src/App.css +38 -0
  96. package/templates/init/client/react/react_js/template/src/App.js +25 -0
  97. package/templates/init/client/react/react_js/template/src/App.test.js +8 -0
  98. package/templates/init/client/react/react_js/template/src/index.css +13 -0
  99. package/templates/init/client/react/react_js/template/src/index.js +17 -0
  100. package/templates/init/client/react/react_js/template/src/logo.svg +1 -0
  101. package/templates/init/client/react/react_js/template/src/reportWebVitals.js +13 -0
  102. package/templates/init/client/react/react_js/template/src/setupTests.js +5 -0
  103. package/templates/init/client/react/react_js/template.json +13 -0
  104. package/templates/init/client/react/react_ts/package.json +11 -0
  105. package/templates/init/client/react/react_ts/template/README.md +46 -0
  106. package/templates/init/client/react/react_ts/template/client-package.json +5 -0
  107. package/templates/init/client/react/react_ts/template/gitignore +23 -0
  108. package/templates/init/client/react/react_ts/template/public/favicon.ico +0 -0
  109. package/templates/init/client/react/react_ts/template/public/index.html +43 -0
  110. package/templates/init/client/react/react_ts/template/public/logo192.png +0 -0
  111. package/templates/init/client/react/react_ts/template/public/logo512.png +0 -0
  112. package/templates/init/client/react/react_ts/template/public/manifest.json +25 -0
  113. package/templates/init/client/react/react_ts/template/public/robots.txt +3 -0
  114. package/templates/init/client/react/react_ts/template/src/App.css +38 -0
  115. package/templates/init/client/react/react_ts/template/src/App.test.tsx +9 -0
  116. package/templates/init/client/react/react_ts/template/src/App.tsx +26 -0
  117. package/templates/init/client/react/react_ts/template/src/index.css +13 -0
  118. package/templates/init/client/react/react_ts/template/src/index.tsx +17 -0
  119. package/templates/init/client/react/react_ts/template/src/logo.svg +1 -0
  120. package/templates/init/client/react/react_ts/template/src/reportWebVitals.ts +15 -0
  121. package/templates/init/client/react/react_ts/template/src/setupTests.ts +5 -0
  122. package/templates/init/client/react/react_ts/template.json +18 -0
  123. package/templates/init/functions/java/integ/cliq/com/handlers/BotHandler.java +96 -111
  124. package/templates/init/functions/java/integ/cliq/com/handlers/CommandHandler.java +20 -27
  125. package/templates/init/functions/java/integ/cliq/com/handlers/FunctionHandler.java +143 -112
  126. package/templates/init/functions/java/integ/cliq/com/handlers/InstallationHandler.java +4 -7
  127. package/templates/init/functions/java/integ/cliq/com/handlers/InstallationValidator.java +4 -7
  128. package/templates/init/functions/java/integ/cliq/com/handlers/MessageActionHandler.java +10 -12
  129. package/templates/init/functions/java/integ/cliq/com/handlers/WidgetHandler.java +100 -66
  130. package/templates/init/functions/java/integ/cliq/sample.java +5 -7
  131. package/templates/init/functions/node/integ/cliq/handlers/bot-handler.js +2 -3
  132. package/templates/init/functions/node/integ/cliq/handlers/command-handler.js +0 -1
  133. package/templates/init/functions/node/integ/cliq/handlers/function-handler.js +46 -0
  134. package/templates/init/functions/node/integ/cliq/handlers/widget-handler.js +31 -0
  135. package/templates/web-socket.txt +21 -0
  136. package/lib/init/features/client.js +0 -50
  137. package/lib/serve/server/lib/client.js +0 -30
@@ -1,39 +1,55 @@
1
1
  'use strict';
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
2
5
  Object.defineProperty(exports, "__esModule", { value: true });
3
- const env_1 = require("../../env");
4
- const dc_1 = require("../../../dc");
6
+ const env_js_1 = require("../../env.js");
7
+ const dc_js_1 = require("../../../dc.js");
8
+ const dc_type_js_1 = __importDefault(require("./dc-type.js"));
5
9
  class URL {
6
10
  static get auth() {
7
- const dc = dc_1.getActiveDCType();
11
+ const dc = dc_js_1.getActiveDCType();
8
12
  if (dc === undefined) {
9
13
  return URL._auth;
10
14
  }
11
15
  return URL._auth.replace('.com', dc.ext);
12
16
  }
13
17
  static get admin() {
14
- const dc = dc_1.getActiveDCType();
18
+ const dc = dc_js_1.getActiveDCType();
15
19
  if (dc === undefined) {
16
20
  return URL._admin;
17
21
  }
18
22
  return URL._admin.replace('.com', dc.ext);
19
23
  }
20
24
  static get app() {
21
- const dc = dc_1.getActiveDCType();
25
+ const dc = dc_js_1.getActiveDCType();
22
26
  if (dc === undefined) {
23
27
  return URL._app;
24
28
  }
25
29
  return URL._app.replace('.com', dc.ext);
26
30
  }
27
- static get zoho() {
28
- const dc = dc_1.getActiveDCType();
31
+ static get catalystStatic() {
32
+ const dc = dc_js_1.getActiveDCType();
29
33
  if (dc === undefined) {
30
- return URL._zoho;
34
+ return URL._catalystStatic;
31
35
  }
32
- return URL._zoho.replace('.com', dc.ext);
36
+ if (dc.ext === dc_type_js_1.default.in.ext) {
37
+ return URL._zohoStatic.replace(dc_type_js_1.default.us.ext, dc_type_js_1.default.in.ext);
38
+ }
39
+ return URL._catalystStatic.replace('.com', dc.ext);
40
+ }
41
+ static get console() {
42
+ const dc = dc_js_1.getActiveDCType();
43
+ if (dc === undefined) {
44
+ return URL._console;
45
+ }
46
+ return URL._console.replace('.com', dc.ext);
33
47
  }
34
48
  }
35
49
  exports.default = URL;
36
- URL._auth = env_1.envOverride('CATALYST_AUTH_URL', 'https://accounts.zoho.com');
37
- URL._admin = env_1.envOverride('CATALYST_ADMIN_URL', 'https://api.catalyst.zoho.com');
38
- URL._app = env_1.envOverride('CATALYST_APP_URL', 'https://catalystserverless.com');
39
- URL._zoho = env_1.envOverride('ZOHO_URL', 'https://www.zoho.com');
50
+ URL._auth = env_js_1.envOverride('CATALYST_AUTH_URL', 'https://accounts.zoho.com');
51
+ URL._admin = env_js_1.envOverride('CATALYST_ADMIN_URL', 'https://api.catalyst.zoho.com');
52
+ URL._app = env_js_1.envOverride('CATALYST_APP_URL', 'https://catalystserverless.com');
53
+ URL._zohoStatic = env_js_1.envOverride('ZOHO_STATIC', 'https://www.zoho.com/catalyst');
54
+ URL._catalystStatic = env_js_1.envOverride('CATALYST_STATIC', 'https://catalyst.zoho.com');
55
+ URL._console = env_js_1.envOverride('CATALYST_CONSOLE_URL', 'https://console.catalyst.zoho.com');
@@ -1,21 +1,22 @@
1
1
  'use strict';
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.getEnvVariable = exports.envOverride = exports.isPrimaryShell = exports.isWindows = exports.isMac = void 0;
4
- function isMac() {
5
- return process && process.platform === 'darwin';
6
- }
7
- exports.isMac = isMac;
8
- function isWindows() {
9
- return (process &&
10
- (process.platform === 'win32' ||
11
- (process.env.OSTYPE !== undefined && /^(msys|cygwin)$/.test(process.env.OSTYPE))));
12
- }
13
- exports.isWindows = isWindows;
3
+ exports.getEnvVariable = exports.envOverride = exports.isPrimaryShell = exports.isWindows = exports.isMac = exports.isCI = void 0;
4
+ exports.isCI = process &&
5
+ !!(process.env.CI ||
6
+ process.env.CONTINUOUS_INTEGRATION ||
7
+ process.env.BUILD_NUMBER ||
8
+ process.env.RUN_ID ||
9
+ exports.name ||
10
+ false);
11
+ exports.isMac = process && process.platform === 'darwin';
12
+ exports.isWindows = process &&
13
+ (process.platform === 'win32' ||
14
+ (process.env.OSTYPE !== undefined && /^(msys|cygwin)$/.test(process.env.OSTYPE)));
14
15
  function isPrimaryShell() {
15
16
  if (!process || process.env.CATALYST_SUB_PROCESS) {
16
17
  return false;
17
18
  }
18
- if (!isWindows() && process.env.SHLVL) {
19
+ if (!exports.isWindows && process.env.SHLVL) {
19
20
  return parseInt(process.env.SHLVL) <= 1;
20
21
  }
21
22
  return false;
@@ -18,17 +18,9 @@ var __importStar = (this && this.__importStar) || function (mod) {
18
18
  __setModuleDefault(result, mod);
19
19
  return result;
20
20
  };
21
- var __importDefault = (this && this.__importDefault) || function (mod) {
22
- return (mod && mod.__esModule) ? mod : { "default": mod };
23
- };
24
21
  Object.defineProperty(exports, "__esModule", { value: true });
25
- exports.ASYNC = exports.SYNC = exports.untildify = void 0;
26
- const os_1 = __importDefault(require("os"));
22
+ exports.ASYNC = exports.SYNC = void 0;
27
23
  const ASYNC = __importStar(require("./lib/async"));
28
24
  exports.ASYNC = ASYNC;
29
25
  const SYNC = __importStar(require("./lib/sync"));
30
26
  exports.SYNC = SYNC;
31
- const tildRegex = /^~(?=$|\/|\\)/;
32
- const homeDirectory = os_1.default.homedir();
33
- const untildify = (pth) => homeDirectory ? pth.replace(tildRegex, homeDirectory) : pth;
34
- exports.untildify = untildify;
@@ -17,17 +17,17 @@ const fs_extra_1 = __importDefault(require("fs-extra"));
17
17
  const minimatch_1 = __importDefault(require("minimatch"));
18
18
  const os_1 = __importDefault(require("os"));
19
19
  const path_1 = __importDefault(require("path"));
20
- const __1 = require("..");
20
+ const utils_js_1 = require("../utils.js");
21
21
  function dirExists(pth) {
22
22
  return __awaiter(this, void 0, void 0, function* () {
23
- const stats = yield fs_extra_1.default.stat(__1.untildify(pth)).catch(() => false);
23
+ const stats = yield fs_extra_1.default.stat(utils_js_1.untildify(pth)).catch(() => false);
24
24
  return stats && stats.isDirectory();
25
25
  });
26
26
  }
27
27
  exports.dirExists = dirExists;
28
28
  function fileExists(pth) {
29
29
  return __awaiter(this, void 0, void 0, function* () {
30
- const stats = yield fs_extra_1.default.stat(__1.untildify(pth)).catch(() => false);
30
+ const stats = yield fs_extra_1.default.stat(utils_js_1.untildify(pth)).catch(() => false);
31
31
  return stats && stats.isFile();
32
32
  });
33
33
  }
@@ -0,0 +1,8 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.untildify = void 0;
4
+ const os_1 = require("os");
5
+ const tildRegex = /^~(?=$|\/|\\)/;
6
+ const homeDirectory = os_1.homedir();
7
+ const untildify = (pth) => homeDirectory ? pth.replace(tildRegex, homeDirectory) : pth;
8
+ exports.untildify = untildify;
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -3,7 +3,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
3
3
  return (mod && mod.__esModule) ? mod : { "default": mod };
4
4
  };
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
- exports.getGlobalOptionValue = exports.setGlobalOption = exports.getOptionValue = exports.getCurrentCommand = void 0;
6
+ exports.getUnknownOpts = exports.getGlobalOptionValue = exports.setGlobalOption = exports.getOptionValue = exports.getCurrentCommand = void 0;
7
7
  const runtime_store_1 = __importDefault(require("../runtime-store"));
8
8
  function getCurrentCommand(fallback) {
9
9
  return runtime_store_1.default.get('opts._name', fallback);
@@ -21,3 +21,7 @@ function getGlobalOptionValue(key, fallback) {
21
21
  return runtime_store_1.default.get('opts.globalOpts.' + key, fallback);
22
22
  }
23
23
  exports.getGlobalOptionValue = getGlobalOptionValue;
24
+ function getUnknownOpts(fallback) {
25
+ return runtime_store_1.default.get('opts.unknownOpts', fallback);
26
+ }
27
+ exports.getUnknownOpts = getUnknownOpts;
@@ -47,19 +47,23 @@ function spawn(command, opts, _a = {}) {
47
47
  ASYNC: () => {
48
48
  const childProcess = cross_spawn_1.default(command, opts, Object.assign({ cwd,
49
49
  stdio,
50
- shell }, otherOpts)).on('error', logger_1.debug);
50
+ shell }, otherOpts));
51
51
  return new Promise((res, rej) => {
52
+ var _a;
52
53
  let message = '';
54
+ let stdout = '';
55
+ (_a = childProcess.stdout) === null || _a === void 0 ? void 0 : _a.on('data', (msg) => {
56
+ stdout += msg.toString();
57
+ });
53
58
  childProcess.on('message', (msg) => {
54
59
  message += msg.toString();
55
- logger_1.debug(msg.toString());
56
60
  });
57
- childProcess.on('error', rej);
61
+ childProcess.on('error', (err) => rej(err));
58
62
  childProcess.on('exit', (code) => {
59
63
  if (code !== 0) {
60
64
  rej(code);
61
65
  }
62
- res(message);
66
+ res({ message, stdout });
63
67
  });
64
68
  });
65
69
  },
@@ -72,7 +76,7 @@ function spawn(command, opts, _a = {}) {
72
76
  exports.spawn = spawn;
73
77
  function which(commandName, { alwaysResolve = true }) {
74
78
  let cleanedCmd = commandName;
75
- if (env_1.isWindows()) {
79
+ if (env_1.isWindows) {
76
80
  const isPathName = /[\\]/.test(commandName);
77
81
  if (isPathName) {
78
82
  const dirname = '"' + path_1.default.dirname(commandName) + '"';
@@ -90,7 +94,7 @@ function which(commandName, { alwaysResolve = true }) {
90
94
  .replace(/\\'''/g, "\\'");
91
95
  }
92
96
  return new Promise((resolve, reject) => {
93
- if (env_1.isWindows()) {
97
+ if (env_1.isWindows) {
94
98
  if (/[\x00-\x1f<>:"|?*]/.test(commandName)) {
95
99
  alwaysResolve ? resolve(false) : reject('controll char test failed');
96
100
  }
package/lib/winston.js CHANGED
@@ -60,7 +60,7 @@ exports.logger = winston_1.createLogger({
60
60
  transports: [exports.transport.console],
61
61
  exitOnError: false
62
62
  });
63
- if (env_1.isPrimaryShell()) {
63
+ if (env_1.isWindows || env_1.isPrimaryShell()) {
64
64
  if (usage) {
65
65
  exports.logger.add(exports.transport.http_log);
66
66
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "zcatalyst-cli",
3
- "version": "1.10.0",
3
+ "version": "1.12.0",
4
4
  "description": "Command Line Tool for CATALYST",
5
5
  "main": "./lib/index.js",
6
6
  "bin": {
@@ -9,6 +9,7 @@
9
9
  "engines": {
10
10
  "node": ">=12.0.0"
11
11
  },
12
+ "preferGlobal": true,
12
13
  "keywords": [
13
14
  "cli",
14
15
  "cloud",
@@ -29,14 +30,13 @@
29
30
  "better-queue": "^3.8.10",
30
31
  "chokidar": "^3.5.2",
31
32
  "cli-cursor": "^3.1.0",
32
- "cli-table3": "^0.6.0",
33
+ "cli-table3": "0.6.0",
33
34
  "commander": "^8.2.0",
34
35
  "conf": "^10.0.2",
35
36
  "cross-spawn": "^7.0.3",
36
37
  "express": "^4.17.1",
37
38
  "fs-extra": "^10.0.0",
38
39
  "fuzzy": "^0.1.3",
39
- "global-dirs": "^3.0.0",
40
40
  "http-proxy": "^1.18.1",
41
41
  "inquirer": "^8.1.2",
42
42
  "inquirer-autocomplete-prompt": "^1.4.0",
@@ -53,8 +53,10 @@
53
53
  "toml": "^3.0.0",
54
54
  "update-notifier": "^5.1.0",
55
55
  "winston": "^3.3.3",
56
+ "ws": "^8.2.3",
56
57
  "xml2js": "^0.4.23",
57
- "yaml": "^1.10.2"
58
+ "yaml": "^1.10.2",
59
+ "zcatalyst-angular-schematics": "^0.1.0"
58
60
  },
59
61
  "devDependencies": {
60
62
  "@types/app-module-path": "^2.2.0",
@@ -72,6 +74,7 @@
72
74
  "@types/request": "^2.48.7",
73
75
  "@types/semver": "^7.3.8",
74
76
  "@types/update-notifier": "^5.1.0",
77
+ "@types/ws": "^8.2.0",
75
78
  "@types/xml2js": "^0.4.9",
76
79
  "@typescript-eslint/eslint-plugin": "^4.29.1",
77
80
  "@typescript-eslint/parser": "^4.29.1",
Binary file
Binary file
Binary file
File without changes
@@ -0,0 +1,301 @@
1
+ 'use strict';
2
+
3
+ var path,
4
+ includeStyle,
5
+ fs,
6
+ sane,
7
+ buildUtils,
8
+ buildOptions;
9
+
10
+ /**
11
+ buildUtils contains all necessary functions for copying and building files.
12
+ ---------------------------------------------------------------------------------------
13
+ * Available functions :
14
+ ---------------------------------------------------------------------------------------
15
+ * buildUtils.copy.file({options})
16
+ -----options-----
17
+ src : source file
18
+ dist : destination file
19
+ minify : [optional] If file needs to be minified in production mode.
20
+ In development mode file will be copied.(default : false)
21
+ ---------------------------------------------------------------------------------------
22
+ * buildUtils.copy.folder({options});
23
+ -----options-----
24
+ src : source folder
25
+ dist : destination folder
26
+ minify : [optional] If folder needs to be minified in production mode.
27
+ In development mode file will be copied.(default : false)
28
+ ---------------------------------------------------------------------------------------
29
+ * buildUtils.consolidate({options})
30
+ -----options-----
31
+ configPath : path from which, consolidation mapping json can be retrived.(json file)
32
+ (OR)
33
+ config : consolidation mapping(mapping)
34
+ module : consolidating module name(any string). To store consolidation mapping json
35
+ In order to store mapping and reusing it on build watch and build serve
36
+ file : [optional] When a particular file is changed and needs to be re-consolidated.
37
+ ---------------------------------------------------------------------------------------
38
+
39
+ **/
40
+ /**
41
+ For transpiling from es6 to es5 :
42
+ ---------------------------------------------------------------------------------------
43
+ * var transpile = require(path.join(options.cliRoot,'lib','utilities','transpile'));
44
+ transpile({options})
45
+ ----options---
46
+ file : single file path or path of the folder, that to convert from es6 to es5
47
+ (OR)
48
+ content : Content of the file to convert
49
+ dist : destination file or folder
50
+ strict : [[optional]] To enable strict mode (default : false)
51
+
52
+ ---------------------------------------------------------------------------------------
53
+ **/
54
+
55
+ /**
56
+ For compiling the themes :
57
+ ---------------------------------------------------------------------------------------
58
+ * buildUtils.compileThemes(buildOptions,{
59
+ src : Array of src File
60
+ dist : destination file
61
+ themeOptions : {
62
+ // list of less default options
63
+ }
64
+ })
65
+
66
+ ---------------------------------------------------------------------------------------
67
+ **/
68
+
69
+ module.exports = {
70
+ version : 1,
71
+ configureFolders : function(options) {
72
+ path = options.path;
73
+ options.outputFolder = "dist"; /* Folder at which the built files are to be needed. */
74
+ options.autoBundle = true ;/* autoBundle is to bundle all (routes,components,models,mixins,helpers and router.js file)*/
75
+ options.theming = false;
76
+ options.useStrict = false;
77
+ options.eslint = false;
78
+ buildUtils = require(path.join(options.cliRoot,'lib','utilities','buildUtils'));
79
+ var folders = { /* Available modules and its folder structures.*/
80
+ build : 'build',
81
+ routes : 'routes',
82
+ routers : 'router.js',
83
+ components : 'components',
84
+ adapters : path.join('data-store','adapters'),
85
+ models : path.join('data-store','models'),
86
+ serializers :path.join('data-store','serializers'),
87
+ mixins :'mixins',
88
+ javascript : path.join('components','javascript'),
89
+ templates : path.join('components','templates'),
90
+ helpers : path.join('components','helpers'),
91
+ styles : path.join('components','styles'),
92
+ images : path.join('components','images'),
93
+ themes : path.join('css'),
94
+ tests : 'tests'
95
+ };
96
+ options.folders = {};
97
+ options.folders.src = {};
98
+ options.folders.dist = {};
99
+ for(var key in folders) {
100
+ options.folders.src[key] = path.join(options.root,folders[key]) /* Source folder of modules. */
101
+ options.folders.dist[key] = path.join(options.root,options.outputFolder,folders[key]) /* Destination folder of modules,
102
+ can be changed if needed. */
103
+ }
104
+ },
105
+
106
+ /*-----------------------------------------------Build Process Starts-------------------------------------------*/
107
+ build : async function (options,dependencies) {
108
+ fs = dependencies.fs; /* fs-extra */
109
+ sane = dependencies.sane; /* watcher */
110
+ buildOptions = options;
111
+ /*configuration for transpile*/
112
+ options.transpile = false;
113
+ if(options.transpile) {
114
+ options.ignoreFoldersFromTranspile = [
115
+ "bower_components",
116
+ "node_modules"
117
+ ]
118
+ }
119
+ /* Building of modules starts. Custom modules can be added in build function. */
120
+ await buildUtils.init(options); /* Provides options to buildUtils. */
121
+ await buildUtils.build(['copyAppDir','routes','components','models','helpers','mixins','services']);
122
+ },
123
+ /*-----------------------------------------------Build Process ends---------------------------------------------*/
124
+
125
+ builder : {
126
+ /*----------------------------------Copy Task---------------------------------------------------------------*/
127
+ copyAppDir : async function(module) {
128
+ /* Comment folders to skip copying folders from source folder to destination folder. */
129
+ /*By default outputFolder,routes,mixins,data-store,compdonents,build will be ignored from copying */
130
+ /*Given folder should be relative to the root path*/
131
+ var ignoreFolders = [
132
+ 'node_modules'
133
+ ];
134
+ await buildUtils._super(module,ignoreFolders);
135
+ await buildUtils._completed(module);
136
+ },
137
+
138
+ /*-----------------------------------------------------------------------------------------------------------*/
139
+ routes : async function(module) {
140
+
141
+ await buildUtils._super(module);
142
+ /** _super of routes
143
+ ----------------------
144
+ * Copies route files from source folder to destination folder.
145
+ * Minifies route files if build is in production mode.
146
+ **/
147
+ await buildUtils._completed(module) /* Stops the timer and notifies that the module is completed. */
148
+ },
149
+
150
+ /*-----------------------------------------------------------------------------------------------------------*/
151
+ components : async function(module) {
152
+ includeStyle = true /* styles will be included to template by default. If not needed, toggle this property. */
153
+ await buildUtils._super(module,{includeStyle : includeStyle});
154
+ /** _super of components
155
+ -------------------------
156
+ * Compiles lyte files to html.
157
+ * Precompiles html files to get dynamic nodes.
158
+ * Appends style to template, if present. And then to component's javascript file.
159
+ * Copies component's files from source folder to destination folder.
160
+ * Minifies components files if build is in production mode.
161
+ **/
162
+ await buildUtils._completed(module) /* Stops the timer and notifies that the module is completed. */
163
+ },
164
+
165
+ /*-----------------------------------------------------------------------------------------------------------*/
166
+ helpers : async function(module) {
167
+ await buildUtils._super(module);
168
+ /** _super of helpers
169
+ ----------------------
170
+ * Copies file from source folder to destination folder(minifies if build
171
+ is in production mode).
172
+ **/
173
+ await buildUtils._completed(module) /* Stops the timer and notifies that the module is completed. */
174
+ },
175
+
176
+ /*-----------------------------------------------------------------------------------------------------------*/
177
+ models : async function(module) {
178
+ await buildUtils._super(module);
179
+ /** _super of models
180
+ ----------------------
181
+ * Concats model, adapter and serializer to a single file(minifies if build
182
+ is in production mode).
183
+ * Copies file from source folder to destination folder.
184
+ **/
185
+ await buildUtils._completed(module) /* Stops the timer and notifies that the module is completed. */
186
+ },
187
+
188
+ /*-----------------------------------------------------------------------------------------------------------*/
189
+ mixins : async function(module) {
190
+ await buildUtils._super(module);
191
+ /** _super of mixins
192
+ ----------------------
193
+ * Copies mixins files from source folder to destination folder.
194
+ * Minifies mixins files if build is in production mode.
195
+ **/
196
+ await buildUtils._completed(module) /* Stops the timer and notifies that the module is completed. */
197
+ },
198
+ services : async function(module) {
199
+
200
+ await buildUtils._super(module);
201
+ /** _super of services
202
+ ----------------------
203
+ * Copies services files from source folder to destination folder.
204
+ * Minifies services files if build is in production mode.
205
+ **/
206
+ await buildUtils._completed(module) /* Stops the timer and notifies that the module is completed. */
207
+ },
208
+ /*-----------------------------------------------------------------------------------------------------------*/
209
+ },
210
+
211
+ /*------------------------------------------Watch changes and build---------------------------------------------*/
212
+ watcher : {
213
+ copyAppDir : async function(module,file,modification) {
214
+ /* Comment folders to skip copying folders from source folder to destination folder. */
215
+ await buildUtils._super(module,{
216
+ file : file,
217
+ modification : modification
218
+ });
219
+ },
220
+ /*----------------------------------------------------------------------------------------------------------*/
221
+ routes : async function(module,file,modification) {
222
+ await buildUtils._super(module,{
223
+ file :file,
224
+ modification : modification
225
+ });
226
+ /** _super of routes on watcher
227
+ -------------------------------
228
+ * Copies specifed route files from source folder to destination folder.
229
+ * Minifies route files if build is in production mode.
230
+ **/
231
+ },
232
+
233
+ /*----------------------------------------------------------------------------------------------------------*/
234
+ components : async function(module,file,modification) {
235
+ await buildUtils._super(module,{
236
+ file : file,
237
+ modification :modification,
238
+ includeStyle : includeStyle
239
+ });
240
+ /** _super of components on watcher
241
+ -----------------------------------
242
+ * Compiles specified lyte files to html.
243
+ * Precompiles specified html files to get dynamic nodes.
244
+ * Appends style to template, if present. And then to component's javascript file.
245
+ * Copies specified component's files from source folder to destination folder.
246
+ * Minifies specified component files if build is in production mode.
247
+ **/
248
+ },
249
+
250
+ /*----------------------------------------------------------------------------------------------------------*/
251
+ helpers : async function(module,file,modification) {
252
+ await buildUtils._super(module,{
253
+ file : file,
254
+ modification : modification
255
+ });
256
+ /** _super of helpers on watcher
257
+ ---------------------------------
258
+ * Copies modified file from source folder to destination folder(minifies if build is in production mode).
259
+ **/
260
+ },
261
+
262
+ /*----------------------------------------------------------------------------------------------------------*/
263
+ models : async function(module,file,modification) {
264
+ await buildUtils._super(module,{
265
+ file :file,
266
+ modification :modification
267
+ });
268
+ /** _super of models on watcher
269
+ -------------------------------
270
+ * Concats model, adapter and serializer to a single file(minifies if build
271
+ is in production mode).
272
+ * Copies file from source folder to destination folder.
273
+ **/
274
+ },
275
+
276
+ /*----------------------------------------------------------------------------------------------------------*/
277
+ mixins : async function(module,file,modification) {
278
+ await buildUtils._super(module,{
279
+ file : file,
280
+ modification :modification
281
+ });
282
+ /** _super of mixins on watcher
283
+ ---------------------------------
284
+ * Copies modified file from source folder to destination folder(minifies if build is in production mode).
285
+ **/
286
+ },
287
+
288
+ services : async function(module,file,modification) {
289
+ await buildUtils._super(module,{
290
+ file : file,
291
+ modification :modification
292
+ });
293
+ /** _super of services on watcher
294
+ ---------------------------------
295
+ * Copies modified file from source folder to destination folder(minifies if build is in production mode).
296
+ **/
297
+ }
298
+
299
+
300
+ }
301
+ };
@@ -0,0 +1,54 @@
1
+ var production = process.env.production
2
+ if(!production) {
3
+ var execSync = require("child_process").execSync;
4
+ var registry = "http://integ-docker:4873";
5
+ var path = require("path");
6
+ var fs = require("fs");
7
+ var packageJSONPath = path.join(process.cwd(),"package.json");
8
+ var packageJSONContent = JSON.parse(fs.readFileSync(packageJSONPath,'utf-8'));
9
+ var version = packageJSONContent["lyte-cli"];
10
+ console.log("Installing the lyte-cli");
11
+ var installTheVersion = function(folderToCreate,version) {
12
+ var homeDir = process.env[(process.platform == 'win32') ? 'USERPROFILE' : 'HOME'];
13
+ var globalCliLocation = path.join(homeDir,'.lyte',"lyte-cli@"+folderToCreate);
14
+ var globalCliLocationNodeModules = path.join(globalCliLocation,"node_modules");
15
+ fs.mkdirSync(globalCliLocation,{recursive : true});
16
+ if(!fs.existsSync(globalCliLocationNodeModules)) {
17
+ try {
18
+ var str = execSync('cd '+globalCliLocation+' && npm install lyte-cli@'+version+' --registry='+registry+" --puppeteer_skip_chromium_download=true");
19
+ console.log(str.toString());
20
+ } catch(e) {
21
+ console.log(e.message);
22
+ process.exit(2);
23
+ }
24
+ }
25
+ var resolution = packageJSONContent.resolution || {};
26
+ resolution["lyte-cli"] = version;
27
+ packageJSONContent.resolution = resolution;
28
+ fs.writeFileSync(packageJSONPath,JSON.stringify(packageJSONContent,null,' '));
29
+ console.log("\x1b[32mLyte-cli found in the location "+globalCliLocation+'\x1b[0m');
30
+ }
31
+ if(version) {
32
+ let folderToCreate;
33
+ if(version.indexOf("http") != -1) {
34
+ folderToCreate = version.split(path.sep).pop();
35
+ installTheVersion(folderToCreate,version);
36
+ } else {
37
+ let lyteCliVersion;
38
+ var allVersions = execSync('npm view lyte-cli@'+version+' version --json --registry='+registry).toString().trim();
39
+ if(allVersions.length) {
40
+ array = JSON.parse(allVersions);
41
+ if(Array.isArray(array)) {
42
+ lyteCliVersion = array.pop().trim()
43
+ } else {
44
+ lyteCliVersion = array.trim();
45
+ }
46
+ lyteCliVersion = lyteCliVersion.replace(/V|v/g,'');
47
+ installTheVersion(lyteCliVersion,lyteCliVersion);
48
+ } else {
49
+ console.log("\x1b[31mNot an valid version for lyte-cli\x1b[0m");
50
+ process.exit(2);
51
+ }
52
+ }
53
+ }
54
+ }
@@ -0,0 +1,5 @@
1
+ {
2
+ "name": "{{_NAME_}}",
3
+ "version": "0.0.1",
4
+ "homepage": "index.html"
5
+ }