1 | #!/usr/bin/env node
|
2 | (function webpackUniversalModuleDefinition(root, factory) {
|
3 | if(typeof exports === 'object' && typeof module === 'object')
|
4 | module.exports = factory();
|
5 | else if(typeof define === 'function' && define.amd)
|
6 | define([], factory);
|
7 | else {
|
8 | var a = factory();
|
9 | for(var i in a) (typeof exports === 'object' ? exports : root)[i] = a[i];
|
10 | }
|
11 | })(global, function() {
|
12 | return (function(modules) {
|
13 |
|
14 | var installedModules = {};
|
15 |
|
16 |
|
17 | function __webpack_require__(moduleId) {
|
18 |
|
19 |
|
20 | if(installedModules[moduleId]) {
|
21 | return installedModules[moduleId].exports;
|
22 | }
|
23 |
|
24 | var module = installedModules[moduleId] = {
|
25 | i: moduleId,
|
26 | l: false,
|
27 | exports: {}
|
28 | };
|
29 |
|
30 |
|
31 | modules[moduleId].call(module.exports, module, module.exports, __webpack_require__);
|
32 |
|
33 |
|
34 | module.l = true;
|
35 |
|
36 |
|
37 | return module.exports;
|
38 | }
|
39 |
|
40 |
|
41 |
|
42 | __webpack_require__.m = modules;
|
43 |
|
44 |
|
45 | __webpack_require__.c = installedModules;
|
46 |
|
47 |
|
48 | __webpack_require__.d = function(exports, name, getter) {
|
49 | if(!__webpack_require__.o(exports, name)) {
|
50 | Object.defineProperty(exports, name, { enumerable: true, get: getter });
|
51 | }
|
52 | };
|
53 |
|
54 |
|
55 | __webpack_require__.r = function(exports) {
|
56 | if(typeof Symbol !== 'undefined' && Symbol.toStringTag) {
|
57 | Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
58 | }
|
59 | Object.defineProperty(exports, '__esModule', { value: true });
|
60 | };
|
61 |
|
62 |
|
63 |
|
64 |
|
65 |
|
66 |
|
67 | __webpack_require__.t = function(value, mode) {
|
68 | if(mode & 1) value = __webpack_require__(value);
|
69 | if(mode & 8) return value;
|
70 | if((mode & 4) && typeof value === 'object' && value && value.__esModule) return value;
|
71 | var ns = Object.create(null);
|
72 | __webpack_require__.r(ns);
|
73 | Object.defineProperty(ns, 'default', { enumerable: true, value: value });
|
74 | if(mode & 2 && typeof value != 'string') for(var key in value) __webpack_require__.d(ns, key, function(key) { return value[key]; }.bind(null, key));
|
75 | return ns;
|
76 | };
|
77 |
|
78 |
|
79 | __webpack_require__.n = function(module) {
|
80 | var getter = module && module.__esModule ?
|
81 | function getDefault() { return module['default']; } :
|
82 | function getModuleExports() { return module; };
|
83 | __webpack_require__.d(getter, 'a', getter);
|
84 | return getter;
|
85 | };
|
86 |
|
87 |
|
88 | __webpack_require__.o = function(object, property) { return Object.prototype.hasOwnProperty.call(object, property); };
|
89 |
|
90 |
|
91 | __webpack_require__.p = "";
|
92 |
|
93 |
|
94 |
|
95 | return __webpack_require__(__webpack_require__.s = 18);
|
96 | })
|
97 |
|
98 | ([
|
99 |
|
100 | (function(module, exports) {
|
101 |
|
102 | module.exports = require("fs-extra");
|
103 |
|
104 | }),
|
105 |
|
106 | (function(module, exports) {
|
107 |
|
108 | module.exports = require("path");
|
109 |
|
110 | }),
|
111 |
|
112 | (function(module, exports) {
|
113 |
|
114 | module.exports = require("@simplism/core");
|
115 |
|
116 | }),
|
117 |
|
118 | (function(module, exports) {
|
119 |
|
120 | module.exports = require("child_process");
|
121 |
|
122 | }),
|
123 |
|
124 | (function(module, exports) {
|
125 |
|
126 | module.exports = require("ts-node/register");
|
127 |
|
128 | }),
|
129 |
|
130 | (function(module, exports) {
|
131 |
|
132 | module.exports = require("webpack");
|
133 |
|
134 | }),
|
135 |
|
136 | (function(module, exports) {
|
137 |
|
138 | module.exports = require("webpack-merge");
|
139 |
|
140 | }),
|
141 |
|
142 | (function(module, exports, __webpack_require__) {
|
143 |
|
144 | "use strict";
|
145 | (function(__dirname) {
|
146 | Object.defineProperty(exports, "__esModule", { value: true });
|
147 | var fs = __webpack_require__(0);
|
148 | var path = __webpack_require__(1);
|
149 | var child_process = __webpack_require__(3);
|
150 | var TsCheckAndDeclarationPlugin = (function () {
|
151 | function TsCheckAndDeclarationPlugin(_options) {
|
152 | this._options = _options;
|
153 | }
|
154 | TsCheckAndDeclarationPlugin.prototype.apply = function (compiler) {
|
155 | var _this = this;
|
156 | var worker;
|
157 | compiler.hooks.watchRun.tap("TsCheckAndDeclarationPlugin", function () {
|
158 | if (!worker) {
|
159 | worker = child_process.fork(_this._loadersPath("ts-check-and-declaration-worker.js"), [
|
160 | _this._options.packageName,
|
161 | "watch",
|
162 | _this._options.tsConfigPath
|
163 | ].filterExists(), {
|
164 | stdio: [undefined, undefined, undefined, "ipc"]
|
165 | });
|
166 | worker.on("message", function (message) {
|
167 | _this._options.logger.error("\uD0C0\uC785 \uC5D0\uB7EC:", message);
|
168 | });
|
169 | }
|
170 | });
|
171 | compiler.hooks.run.tap("TsCheckAndDeclarationPlugin", function () {
|
172 | worker = child_process.fork(_this._loadersPath("ts-check-and-declaration-worker.js"), [
|
173 | _this._options.packageName,
|
174 | "build",
|
175 | _this._options.tsConfigPath
|
176 | ].filterExists(), {
|
177 | stdio: [undefined, undefined, undefined, "ipc"]
|
178 | });
|
179 | worker.on("message", function (message) {
|
180 | _this._options.logger.error("\uD0C0\uC785 \uC5D0\uB7EC:", message);
|
181 | });
|
182 | });
|
183 | };
|
184 | TsCheckAndDeclarationPlugin.prototype._loadersPath = function () {
|
185 | var args = [];
|
186 | for (var _i = 0; _i < arguments.length; _i++) {
|
187 | args[_i] = arguments[_i];
|
188 | }
|
189 | return fs.existsSync(path.resolve(this._options.projectPath || process.cwd(), "node_modules/@simplism/cli/loaders"))
|
190 | ? path.resolve.apply(path, [this._options.projectPath || process.cwd(), "node_modules/@simplism/cli/loaders"].concat(args)) : path.resolve.apply(path, [__dirname, "../../loaders"].concat(args));
|
191 | };
|
192 | return TsCheckAndDeclarationPlugin;
|
193 | }());
|
194 | exports.TsCheckAndDeclarationPlugin = TsCheckAndDeclarationPlugin;
|
195 |
|
196 | }.call(this, "packages\\cli\\src\\plugins"))
|
197 |
|
198 | }),
|
199 |
|
200 | (function(module, exports, __webpack_require__) {
|
201 |
|
202 | "use strict";
|
203 |
|
204 | Object.defineProperty(exports, "__esModule", { value: true });
|
205 | var FriendlyLoggerPlugin = (function () {
|
206 | function FriendlyLoggerPlugin(_options) {
|
207 | this._options = _options;
|
208 | }
|
209 | FriendlyLoggerPlugin.prototype.apply = function (compiler) {
|
210 | var _this = this;
|
211 | compiler.hooks.run.tap("FriendlyLoggerPlugin", function () {
|
212 | _this._options.logger.log("\uBE4C\uB4DC...");
|
213 | });
|
214 | compiler.hooks.watchRun.tap("FriendlyLoggerPlugin", function () {
|
215 | _this._options.logger.log("\uBE4C\uB4DC...");
|
216 | });
|
217 | compiler.hooks.done.tap("FriendlyLoggerPlugin", function (stats) {
|
218 | var info = stats.toJson();
|
219 | if (stats.hasWarnings()) {
|
220 | for (var _i = 0, _a = info.warnings; _i < _a.length; _i++) {
|
221 | var warning = _a[_i];
|
222 | _this._options.logger.warn(warning);
|
223 | }
|
224 | }
|
225 | if (stats.hasErrors()) {
|
226 | for (var _b = 0, _c = info.errors; _b < _c.length; _b++) {
|
227 | var error = _c[_b];
|
228 | _this._options.logger.error(error);
|
229 | }
|
230 | }
|
231 | _this._options.logger.info("\uBE4C\uB4DC \uC644\uB8CC");
|
232 | });
|
233 | };
|
234 | return FriendlyLoggerPlugin;
|
235 | }());
|
236 | exports.FriendlyLoggerPlugin = FriendlyLoggerPlugin;
|
237 |
|
238 |
|
239 | }),
|
240 |
|
241 | (function(module, exports) {
|
242 |
|
243 | module.exports = require("glob");
|
244 |
|
245 | }),
|
246 |
|
247 | (function(module, exports, __webpack_require__) {
|
248 |
|
249 | "use strict";
|
250 |
|
251 | var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
252 | return new (P || (P = Promise))(function (resolve, reject) {
|
253 | function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
254 | function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
255 | function step(result) { result.done ? resolve(result.value) : new P(function (resolve) { resolve(result.value); }).then(fulfilled, rejected); }
|
256 | step((generator = generator.apply(thisArg, _arguments || [])).next());
|
257 | });
|
258 | };
|
259 | var __generator = (this && this.__generator) || function (thisArg, body) {
|
260 | var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
|
261 | return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
262 | function verb(n) { return function (v) { return step([n, v]); }; }
|
263 | function step(op) {
|
264 | if (f) throw new TypeError("Generator is already executing.");
|
265 | while (_) try {
|
266 | if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
|
267 | if (y = 0, t) op = [op[0] & 2, t.value];
|
268 | switch (op[0]) {
|
269 | case 0: case 1: t = op; break;
|
270 | case 4: _.label++; return { value: op[1], done: false };
|
271 | case 5: _.label++; y = op[1]; op = [0]; continue;
|
272 | case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
273 | default:
|
274 | if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
275 | if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
276 | if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
277 | if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
278 | if (t[2]) _.ops.pop();
|
279 | _.trys.pop(); continue;
|
280 | }
|
281 | op = body.call(thisArg, _);
|
282 | } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
283 | if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
284 | }
|
285 | };
|
286 | Object.defineProperty(exports, "__esModule", { value: true });
|
287 | var fs = __webpack_require__(0);
|
288 | var path = __webpack_require__(1);
|
289 | var core_1 = __webpack_require__(2);
|
290 | var FileWatcher_1 = __webpack_require__(11);
|
291 | var LocalUpdater = (function () {
|
292 | function LocalUpdater(_packageName, _packagePath) {
|
293 | this._packageName = _packageName;
|
294 | this._packagePath = _packagePath;
|
295 | this._logger = new core_1.Logger("@simplism/cli", this._packageName + ":");
|
296 | }
|
297 | LocalUpdater.prototype.runAsync = function (watch) {
|
298 | return __awaiter(this, void 0, Promise, function () {
|
299 | var _i, _a, file;
|
300 | var _this = this;
|
301 | return __generator(this, function (_b) {
|
302 | switch (_b.label) {
|
303 | case 0:
|
304 | if (!watch) return [3, 2];
|
305 | this._logger.log("\uB85C\uCEEC \uC5C5\uB370\uC774\uD2B8 \uAC10\uC9C0 \uC2DC\uC791...");
|
306 | return [4, FileWatcher_1.FileWatcher.watch(this._sourcePath("**/*"), ["add", "change", "unlink"], function (files) {
|
307 | try {
|
308 | for (var _i = 0, files_1 = files; _i < files_1.length; _i++) {
|
309 | var file = files_1[_i];
|
310 | if (file.filePath.endsWith("package.json"))
|
311 | continue;
|
312 | _this._logger.log("\uBCC0\uACBD\uB428: " + file.type + " => " + file.filePath);
|
313 | var relativeSourcePath = path.relative(_this._sourcePath(), file.filePath);
|
314 | var targetPath = _this._targetPath(relativeSourcePath);
|
315 | if (file.type === "unlink") {
|
316 | fs.removeSync(targetPath);
|
317 | }
|
318 | else {
|
319 | fs.copyFileSync(file.filePath, targetPath);
|
320 | }
|
321 | }
|
322 | }
|
323 | catch (err) {
|
324 | _this._logger.error(err);
|
325 | }
|
326 | })];
|
327 | case 1:
|
328 | _b.sent();
|
329 | return [3, 3];
|
330 | case 2:
|
331 | for (_i = 0, _a = fs.readdirSync(this._sourcePath()); _i < _a.length; _i++) {
|
332 | file = _a[_i];
|
333 | if (file === "package.json")
|
334 | continue;
|
335 | fs.copySync(this._sourcePath(file), this._targetPath(file));
|
336 | }
|
337 | this._logger.log("\uB85C\uCEEC \uC5C5\uB370\uC774\uD2B8 \uC644\uB8CC");
|
338 | _b.label = 3;
|
339 | case 3: return [2];
|
340 | }
|
341 | });
|
342 | });
|
343 | };
|
344 | LocalUpdater.prototype._sourcePath = function () {
|
345 | var args = [];
|
346 | for (var _i = 0; _i < arguments.length; _i++) {
|
347 | args[_i] = arguments[_i];
|
348 | }
|
349 | return path.resolve.apply(path, [this._packagePath].concat(args));
|
350 | };
|
351 | LocalUpdater.prototype._targetPath = function () {
|
352 | var args = [];
|
353 | for (var _i = 0; _i < arguments.length; _i++) {
|
354 | args[_i] = arguments[_i];
|
355 | }
|
356 | return path.resolve.apply(path, [process.cwd(), "node_modules/" + this._packageName].concat(args));
|
357 | };
|
358 | return LocalUpdater;
|
359 | }());
|
360 | exports.LocalUpdater = LocalUpdater;
|
361 |
|
362 |
|
363 | }),
|
364 |
|
365 | (function(module, exports, __webpack_require__) {
|
366 |
|
367 | "use strict";
|
368 |
|
369 | var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
370 | return new (P || (P = Promise))(function (resolve, reject) {
|
371 | function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
372 | function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
373 | function step(result) { result.done ? resolve(result.value) : new P(function (resolve) { resolve(result.value); }).then(fulfilled, rejected); }
|
374 | step((generator = generator.apply(thisArg, _arguments || [])).next());
|
375 | });
|
376 | };
|
377 | var __generator = (this && this.__generator) || function (thisArg, body) {
|
378 | var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
|
379 | return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
380 | function verb(n) { return function (v) { return step([n, v]); }; }
|
381 | function step(op) {
|
382 | if (f) throw new TypeError("Generator is already executing.");
|
383 | while (_) try {
|
384 | if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
|
385 | if (y = 0, t) op = [op[0] & 2, t.value];
|
386 | switch (op[0]) {
|
387 | case 0: case 1: t = op; break;
|
388 | case 4: _.label++; return { value: op[1], done: false };
|
389 | case 5: _.label++; y = op[1]; op = [0]; continue;
|
390 | case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
391 | default:
|
392 | if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
393 | if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
394 | if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
395 | if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
396 | if (t[2]) _.ops.pop();
|
397 | _.trys.pop(); continue;
|
398 | }
|
399 | op = body.call(thisArg, _);
|
400 | } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
401 | if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
402 | }
|
403 | };
|
404 | Object.defineProperty(exports, "__esModule", { value: true });
|
405 | var chokidar = __webpack_require__(21);
|
406 | var FileWatcher = (function () {
|
407 | function FileWatcher() {
|
408 | }
|
409 | FileWatcher.watch = function (paths, sits, callback) {
|
410 | return __awaiter(this, void 0, Promise, function () {
|
411 | return __generator(this, function (_a) {
|
412 | switch (_a.label) {
|
413 | case 0: return [4, new Promise(function (resolve) {
|
414 | var watcher = chokidar.watch((typeof paths === "string" ? [paths] : paths).map(function (item) { return item.replace(/\\/g, "/"); }))
|
415 | .on("ready", function () {
|
416 | var preservedFileChanges = [];
|
417 | var timeout;
|
418 | var onWatched = function (type, filePath) {
|
419 | preservedFileChanges.push({ type: type, filePath: filePath });
|
420 | clearTimeout(timeout);
|
421 | timeout = setTimeout(function () {
|
422 | var fileChanges = Object.clone(preservedFileChanges);
|
423 | preservedFileChanges = [];
|
424 | callback(fileChanges);
|
425 | }, 300);
|
426 | };
|
427 | var _loop_1 = function (sit) {
|
428 | watcher.on(sit, function (filePath) {
|
429 | onWatched(sit, filePath);
|
430 | });
|
431 | };
|
432 | for (var _i = 0, sits_1 = sits; _i < sits_1.length; _i++) {
|
433 | var sit = sits_1[_i];
|
434 | _loop_1(sit);
|
435 | }
|
436 | resolve();
|
437 | });
|
438 | })];
|
439 | case 1:
|
440 | _a.sent();
|
441 | return [2];
|
442 | }
|
443 | });
|
444 | });
|
445 | };
|
446 | return FileWatcher;
|
447 | }());
|
448 | exports.FileWatcher = FileWatcher;
|
449 |
|
450 |
|
451 | }),
|
452 |
|
453 | (function(module, exports, __webpack_require__) {
|
454 |
|
455 | "use strict";
|
456 | (function(__dirname) {
|
457 | var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
458 | return new (P || (P = Promise))(function (resolve, reject) {
|
459 | function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
460 | function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
461 | function step(result) { result.done ? resolve(result.value) : new P(function (resolve) { resolve(result.value); }).then(fulfilled, rejected); }
|
462 | step((generator = generator.apply(thisArg, _arguments || [])).next());
|
463 | });
|
464 | };
|
465 | var __generator = (this && this.__generator) || function (thisArg, body) {
|
466 | var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
|
467 | return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
468 | function verb(n) { return function (v) { return step([n, v]); }; }
|
469 | function step(op) {
|
470 | if (f) throw new TypeError("Generator is already executing.");
|
471 | while (_) try {
|
472 | if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
|
473 | if (y = 0, t) op = [op[0] & 2, t.value];
|
474 | switch (op[0]) {
|
475 | case 0: case 1: t = op; break;
|
476 | case 4: _.label++; return { value: op[1], done: false };
|
477 | case 5: _.label++; y = op[1]; op = [0]; continue;
|
478 | case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
479 | default:
|
480 | if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
481 | if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
482 | if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
483 | if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
484 | if (t[2]) _.ops.pop();
|
485 | _.trys.pop(); continue;
|
486 | }
|
487 | op = body.call(thisArg, _);
|
488 | } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
489 | if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
490 | }
|
491 | };
|
492 | Object.defineProperty(exports, "__esModule", { value: true });
|
493 | var fs = __webpack_require__(0);
|
494 | var path = __webpack_require__(1);
|
495 | var core_1 = __webpack_require__(2);
|
496 | var child_process = __webpack_require__(3);
|
497 | var webpack = __webpack_require__(5);
|
498 | var webpackMerge = __webpack_require__(6);
|
499 | var TsCheckAndDeclarationPlugin_1 = __webpack_require__(7);
|
500 | var FriendlyLoggerPlugin_1 = __webpack_require__(8);
|
501 | var nodeExternals = __webpack_require__(22);
|
502 | var LibraryPackageBuilder = (function () {
|
503 | function LibraryPackageBuilder(_config) {
|
504 | this._config = _config;
|
505 | this._logger = new core_1.Logger("@simplism/cli", this._config.name + ":");
|
506 | }
|
507 | Object.defineProperty(LibraryPackageBuilder.prototype, "_packageName", {
|
508 | get: function () {
|
509 | return this._config.name.includes(":") ? this._config.name.slice(0, this._config.name.indexOf(":")) : this._config.name;
|
510 | },
|
511 | enumerable: true,
|
512 | configurable: true
|
513 | });
|
514 | LibraryPackageBuilder.prototype.buildAsync = function () {
|
515 | return __awaiter(this, void 0, Promise, function () {
|
516 | var tsconfig;
|
517 | var _this = this;
|
518 | return __generator(this, function (_a) {
|
519 | switch (_a.label) {
|
520 | case 0:
|
521 | tsconfig = fs.readJsonSync(this._packagePath("tsconfig.json"));
|
522 | fs.removeSync(this._packagePath(tsconfig.compilerOptions.outDir || "dist"));
|
523 | return [4, new Promise(function (resolve, reject) {
|
524 | var webpackConfig = webpackMerge(_this._getCommonConfig(), {
|
525 | mode: "production",
|
526 | devtool: "source-map",
|
527 | optimization: {
|
528 | noEmitOnErrors: true,
|
529 | minimize: false,
|
530 | nodeEnv: false
|
531 | }
|
532 | });
|
533 | webpack(webpackConfig, function (err) {
|
534 | if (err) {
|
535 | reject(err);
|
536 | return;
|
537 | }
|
538 | resolve();
|
539 | });
|
540 | })];
|
541 | case 1:
|
542 | _a.sent();
|
543 | return [2];
|
544 | }
|
545 | });
|
546 | });
|
547 | };
|
548 | LibraryPackageBuilder.prototype.watchAsync = function () {
|
549 | return __awaiter(this, void 0, Promise, function () {
|
550 | var tsconfig;
|
551 | var _this = this;
|
552 | return __generator(this, function (_a) {
|
553 | switch (_a.label) {
|
554 | case 0:
|
555 | tsconfig = fs.readJsonSync(this._packagePath("tsconfig.json"));
|
556 | fs.removeSync(this._packagePath(tsconfig.compilerOptions.outDir || "dist"));
|
557 | return [4, new Promise(function (resolve, reject) {
|
558 | var webpackConfig = webpackMerge(_this._getCommonConfig(), {
|
559 | mode: "development",
|
560 | devtool: "source-map",
|
561 | optimization: {
|
562 | nodeEnv: false
|
563 | }
|
564 | });
|
565 | var compiler = webpack(webpackConfig);
|
566 | compiler.watch({}, function (err) {
|
567 | if (err) {
|
568 | reject(err);
|
569 | return;
|
570 | }
|
571 | resolve();
|
572 | });
|
573 | })];
|
574 | case 1:
|
575 | _a.sent();
|
576 | return [2];
|
577 | }
|
578 | });
|
579 | });
|
580 | };
|
581 | LibraryPackageBuilder.prototype.publishAsync = function () {
|
582 | return __awaiter(this, void 0, Promise, function () {
|
583 | var _this = this;
|
584 | return __generator(this, function (_a) {
|
585 | switch (_a.label) {
|
586 | case 0: return [4, new Promise(function (resolve, reject) {
|
587 | _this._logger.log("\uBC30\uD3EC...");
|
588 | var packageJson = fs.readJsonSync(_this._packagePath("package.json"));
|
589 | var shell = child_process.spawn("yarn", ["publish", "--new-version", packageJson.version, "--access", "public", "--no-git-tag-version"], {
|
590 | shell: true,
|
591 | stdio: "pipe",
|
592 | cwd: _this._packagePath()
|
593 | });
|
594 | var errorMessage = "";
|
595 | shell.stderr.on("data", function (chunk) {
|
596 | errorMessage += chunk.toString();
|
597 | });
|
598 | shell.on("exit", function (code) {
|
599 | if (code !== 0) {
|
600 | if (errorMessage.includes("You cannot publish over the previously published versions")) {
|
601 | _this._logger.warn("\uACBD\uACE0 \uBC1C\uC0DD", errorMessage.replace(/[\u001b\u009b][[()#;?]*(?:[0-9]{1,4}(?:;[0-9]{0,4})*)?[0-9A-ORZcf-nqry=><]/g, "").trim());
|
602 | resolve();
|
603 | return;
|
604 | }
|
605 | else {
|
606 | _this._logger.error("\uC5D0\uB7EC \uBC1C\uC0DD", errorMessage.replace(/[\u001b\u009b][[()#;?]*(?:[0-9]{1,4}(?:;[0-9]{0,4})*)?[0-9A-ORZcf-nqry=><]/g, "").trim());
|
607 | reject();
|
608 | return;
|
609 | }
|
610 | }
|
611 | _this._logger.info("\uBC30\uD3EC \uC644\uB8CC: v" + packageJson.version);
|
612 | resolve();
|
613 | });
|
614 | })];
|
615 | case 1:
|
616 | _a.sent();
|
617 | return [2];
|
618 | }
|
619 | });
|
620 | });
|
621 | };
|
622 | LibraryPackageBuilder.prototype._getCommonConfig = function () {
|
623 | var _this = this;
|
624 | var tsconfig = fs.readJsonSync(this._packagePath("tsconfig.json"));
|
625 | var alias = {};
|
626 | if (tsconfig.compilerOptions.paths) {
|
627 | for (var _i = 0, _a = Object.keys(tsconfig.compilerOptions.paths); _i < _a.length; _i++) {
|
628 | var key = _a[_i];
|
629 | alias[key] = this._packagePath(tsconfig.compilerOptions.paths[key][0].replace(/[\\/]src[\\/]([^\\/.]*)\.ts$/, ""));
|
630 | }
|
631 | }
|
632 | var packageJson = fs.readJsonSync(this._packagePath("package.json"));
|
633 | var entry = {};
|
634 | for (var _b = 0, _c = tsconfig.files; _b < _c.length; _b++) {
|
635 | var fileName = _c[_b];
|
636 | var basename = path.basename(fileName, path.extname(fileName));
|
637 | entry[basename] = this._packagePath(fileName);
|
638 | }
|
639 | return {
|
640 | target: "node",
|
641 | node: {
|
642 | __dirname: true
|
643 | },
|
644 | resolve: {
|
645 | extensions: [".ts", ".js", ".json"],
|
646 | alias: alias
|
647 | },
|
648 | entry: entry,
|
649 | output: {
|
650 | path: this._packagePath(tsconfig.compilerOptions.outDir || "dist"),
|
651 | filename: "[name].js",
|
652 | libraryTarget: "umd"
|
653 | },
|
654 | module: {
|
655 | rules: [
|
656 | {
|
657 | enforce: "pre",
|
658 | test: /\.js$/,
|
659 | use: ["source-map-loader"],
|
660 | include: /node_modules[\\/]@simplism/
|
661 | },
|
662 | {
|
663 | test: /\.ts$/,
|
664 | exclude: /node_modules/,
|
665 | loaders: [
|
666 | {
|
667 | loader: this._loadersPath("ts-transpile-loader.js"),
|
668 | options: {
|
669 | logger: this._logger
|
670 | }
|
671 | },
|
672 | this._loadersPath("shebang-loader.js")
|
673 | ]
|
674 | }
|
675 | ]
|
676 | },
|
677 | plugins: [
|
678 | new TsCheckAndDeclarationPlugin_1.TsCheckAndDeclarationPlugin({
|
679 | packageName: this._packageName,
|
680 | logger: this._logger
|
681 | }),
|
682 | new FriendlyLoggerPlugin_1.FriendlyLoggerPlugin({
|
683 | packageName: this._packageName,
|
684 | logger: this._logger
|
685 | })
|
686 | ].concat((packageJson.bin)
|
687 | ? [
|
688 | new webpack.BannerPlugin({
|
689 | banner: "#!/usr/bin/env node",
|
690 | raw: true,
|
691 | entryOnly: true,
|
692 | include: Object.keys(packageJson.bin).map(function (key) { return path.relative(_this._packagePath(tsconfig.compilerOptions.outDir || "dist"), _this._packagePath(packageJson.bin[key])); })
|
693 | })
|
694 | ]
|
695 | : []),
|
696 | externals: [
|
697 | function (context, request, callback) {
|
698 | if (alias[request]) {
|
699 | callback(undefined, "commonjs " + request);
|
700 | return;
|
701 | }
|
702 | callback(undefined, undefined);
|
703 | },
|
704 | nodeExternals()
|
705 | ]
|
706 | };
|
707 | };
|
708 | LibraryPackageBuilder.prototype._loadersPath = function () {
|
709 | var args = [];
|
710 | for (var _i = 0; _i < arguments.length; _i++) {
|
711 | args[_i] = arguments[_i];
|
712 | }
|
713 | return fs.existsSync(path.resolve(process.cwd(), "node_modules/@simplism/cli/loaders"))
|
714 | ? path.resolve.apply(path, [process.cwd(), "node_modules/@simplism/cli/loaders"].concat(args)) : path.resolve.apply(path, [__dirname, "../../loaders"].concat(args));
|
715 | };
|
716 | LibraryPackageBuilder.prototype._packagePath = function () {
|
717 | var args = [];
|
718 | for (var _i = 0; _i < arguments.length; _i++) {
|
719 | args[_i] = arguments[_i];
|
720 | }
|
721 | return path.resolve.apply(path, [process.cwd(), "packages/" + this._packageName].concat(args));
|
722 | };
|
723 | return LibraryPackageBuilder;
|
724 | }());
|
725 | exports.LibraryPackageBuilder = LibraryPackageBuilder;
|
726 |
|
727 | }.call(this, "packages\\cli\\src\\builders"))
|
728 |
|
729 | }),
|
730 |
|
731 | (function(module, exports, __webpack_require__) {
|
732 |
|
733 | "use strict";
|
734 | (function(__dirname) {
|
735 | var __assign = (this && this.__assign) || function () {
|
736 | __assign = Object.assign || function(t) {
|
737 | for (var s, i = 1, n = arguments.length; i < n; i++) {
|
738 | s = arguments[i];
|
739 | for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
|
740 | t[p] = s[p];
|
741 | }
|
742 | return t;
|
743 | };
|
744 | return __assign.apply(this, arguments);
|
745 | };
|
746 | var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
747 | return new (P || (P = Promise))(function (resolve, reject) {
|
748 | function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
749 | function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
750 | function step(result) { result.done ? resolve(result.value) : new P(function (resolve) { resolve(result.value); }).then(fulfilled, rejected); }
|
751 | step((generator = generator.apply(thisArg, _arguments || [])).next());
|
752 | });
|
753 | };
|
754 | var __generator = (this && this.__generator) || function (thisArg, body) {
|
755 | var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
|
756 | return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
757 | function verb(n) { return function (v) { return step([n, v]); }; }
|
758 | function step(op) {
|
759 | if (f) throw new TypeError("Generator is already executing.");
|
760 | while (_) try {
|
761 | if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
|
762 | if (y = 0, t) op = [op[0] & 2, t.value];
|
763 | switch (op[0]) {
|
764 | case 0: case 1: t = op; break;
|
765 | case 4: _.label++; return { value: op[1], done: false };
|
766 | case 5: _.label++; y = op[1]; op = [0]; continue;
|
767 | case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
768 | default:
|
769 | if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
770 | if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
771 | if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
772 | if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
773 | if (t[2]) _.ops.pop();
|
774 | _.trys.pop(); continue;
|
775 | }
|
776 | op = body.call(thisArg, _);
|
777 | } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
778 | if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
779 | }
|
780 | };
|
781 | Object.defineProperty(exports, "__esModule", { value: true });
|
782 | var fs = __webpack_require__(0);
|
783 | var path = __webpack_require__(1);
|
784 | var child_process = __webpack_require__(3);
|
785 | var glob = __webpack_require__(9);
|
786 | var core_1 = __webpack_require__(2);
|
787 | var storage_1 = __webpack_require__(14);
|
788 | var FriendlyLoggerPlugin_1 = __webpack_require__(8);
|
789 | var webpack = __webpack_require__(5);
|
790 | var webpackMerge = __webpack_require__(6);
|
791 | var TsCheckAndDeclarationPlugin_1 = __webpack_require__(7);
|
792 | var CopyWebpackPlugin = __webpack_require__(15);
|
793 | var ServerPackageBuilder = (function () {
|
794 | function ServerPackageBuilder(_config) {
|
795 | this._config = _config;
|
796 | this._logger = new core_1.Logger("@simplism/cli", this._config.name + ":");
|
797 | }
|
798 | Object.defineProperty(ServerPackageBuilder.prototype, "_packageName", {
|
799 | get: function () {
|
800 | return this._config.name.includes(":") ? this._config.name.slice(0, this._config.name.indexOf(":")) : this._config.name;
|
801 | },
|
802 | enumerable: true,
|
803 | configurable: true
|
804 | });
|
805 | ServerPackageBuilder.prototype.buildAsync = function () {
|
806 | return __awaiter(this, void 0, Promise, function () {
|
807 | var tsconfig;
|
808 | var _this = this;
|
809 | return __generator(this, function (_a) {
|
810 | switch (_a.label) {
|
811 | case 0:
|
812 | tsconfig = fs.readJsonSync(this._packagePath("tsconfig.json"));
|
813 | fs.removeSync(this._packagePath(tsconfig.compilerOptions.outDir || "dist"));
|
814 | return [4, new Promise(function (resolve, reject) {
|
815 | var webpackConfig = webpackMerge(_this._getCommonConfig(), {
|
816 | mode: "production",
|
817 | devtool: "source-map",
|
818 | optimization: {
|
819 | noEmitOnErrors: true,
|
820 | minimize: false
|
821 | },
|
822 | plugins: [
|
823 | new webpack.DefinePlugin({
|
824 | "process.env": _this._envStringify(__assign({ VERSION: fs.readJsonSync(_this._packagePath("package.json")).version, PACKAGE_NAME: _this._packageName }, _this._config.env, _this._config["env.production"]))
|
825 | })
|
826 | ]
|
827 | });
|
828 | webpack(webpackConfig, function (err) {
|
829 | if (err) {
|
830 | reject(err);
|
831 | return;
|
832 | }
|
833 | resolve();
|
834 | });
|
835 | })];
|
836 | case 1:
|
837 | _a.sent();
|
838 | return [2];
|
839 | }
|
840 | });
|
841 | });
|
842 | };
|
843 | ServerPackageBuilder.prototype.watchAsync = function () {
|
844 | return __awaiter(this, void 0, Promise, function () {
|
845 | var tsconfig;
|
846 | var _this = this;
|
847 | return __generator(this, function (_a) {
|
848 | switch (_a.label) {
|
849 | case 0:
|
850 | tsconfig = fs.readJsonSync(this._packagePath("tsconfig.json"));
|
851 | fs.removeSync(this._packagePath(tsconfig.compilerOptions.outDir || "dist"));
|
852 | return [4, new Promise(function (resolve, reject) {
|
853 | var webpackConfig = webpackMerge(_this._getCommonConfig(), {
|
854 | mode: "development",
|
855 | devtool: "inline-source-map",
|
856 | plugins: [
|
857 | new webpack.DefinePlugin({
|
858 | "process.env": _this._envStringify(__assign({ VERSION: fs.readJsonSync(_this._packagePath("package.json")).version, PACKAGE_NAME: _this._packageName }, _this._config.env, _this._config["env.development"]))
|
859 | })
|
860 | ]
|
861 | });
|
862 | var compiler = webpack(webpackConfig);
|
863 | var worker;
|
864 | compiler.watch({}, function (err) {
|
865 | if (err) {
|
866 | reject(err);
|
867 | return;
|
868 | }
|
869 | if (worker) {
|
870 | worker.kill();
|
871 | }
|
872 | worker = child_process.fork(_this._packagePath(tsconfig.compilerOptions.outDir || "dist", "app.js"), [], {
|
873 | cwd: _this._packagePath(tsconfig.compilerOptions.outDir || "dist"),
|
874 | execArgv: ["--require", "source-map-support/register"]
|
875 | });
|
876 | resolve();
|
877 | });
|
878 | })];
|
879 | case 1:
|
880 | _a.sent();
|
881 | return [2];
|
882 | }
|
883 | });
|
884 | });
|
885 | };
|
886 | ServerPackageBuilder.prototype.publishAsync = function () {
|
887 | return __awaiter(this, void 0, Promise, function () {
|
888 | var tsconfig, distPath, storage, filePaths, _i, filePaths_1, filePath, ftpFilePath, packageJson;
|
889 | return __generator(this, function (_a) {
|
890 | switch (_a.label) {
|
891 | case 0:
|
892 | this._logger.log("\uBC30\uD3EC...");
|
893 | if (!this._config.publish) {
|
894 | throw new Error("설정파일에 'publish'옵션이 설정되어야 합니다.");
|
895 | }
|
896 | tsconfig = fs.readJsonSync(this._packagePath("tsconfig.json"));
|
897 | distPath = this._packagePath(tsconfig.compilerOptions.outDir || "dist");
|
898 | storage = new storage_1.FtpStorage();
|
899 | return [4, storage.connectAsync({
|
900 | host: this._config.publish.host,
|
901 | port: this._config.publish.port,
|
902 | user: this._config.publish.username,
|
903 | password: this._config.publish.password
|
904 | })];
|
905 | case 1:
|
906 | _a.sent();
|
907 | return [4, storage.mkdirAsync(this._config.publish.path)];
|
908 | case 2:
|
909 | _a.sent();
|
910 | filePaths = glob.sync(path.resolve(distPath, "**/*"));
|
911 | _i = 0, filePaths_1 = filePaths;
|
912 | _a.label = 3;
|
913 | case 3:
|
914 | if (!(_i < filePaths_1.length)) return [3, 8];
|
915 | filePath = filePaths_1[_i];
|
916 | ftpFilePath = this._config.publish.path + "/" + path.relative(distPath, filePath).replace(/\\/g, "/");
|
917 | if (!fs.lstatSync(filePath).isDirectory()) return [3, 5];
|
918 | return [4, storage.mkdirAsync(ftpFilePath)];
|
919 | case 4:
|
920 | _a.sent();
|
921 | return [3, 7];
|
922 | case 5: return [4, storage.putAsync(filePath, ftpFilePath)];
|
923 | case 6:
|
924 | _a.sent();
|
925 | _a.label = 7;
|
926 | case 7:
|
927 | _i++;
|
928 | return [3, 3];
|
929 | case 8: return [4, storage.putAsync(this._packagePath("package.json"), this._config.publish.path + "/package.json")];
|
930 | case 9:
|
931 | _a.sent();
|
932 | return [4, storage.putAsync(Buffer.from(JSON.stringify({
|
933 | apps: [{
|
934 | name: this._config.publish.path.replace(/[\\/]/g, "."),
|
935 | script: "./app.js",
|
936 | watch: [
|
937 | "app.js",
|
938 | "pm2.json"
|
939 | ],
|
940 | env: __assign({ NODE_ENV: "production", VERSION: fs.readJsonSync(this._packagePath("package.json")).version, PACKAGE_NAME: this._packageName }, this._config.env, this._config["env.production"])
|
941 | }]
|
942 | }, undefined, 2)), "/" + this._config.publish.path + "/pm2.json")];
|
943 | case 10:
|
944 | _a.sent();
|
945 | return [4, storage.closeAsync()];
|
946 | case 11:
|
947 | _a.sent();
|
948 | packageJson = fs.readJsonSync(this._packagePath("package.json"));
|
949 | this._logger.info("\uBC30\uD3EC \uC644\uB8CC: v" + packageJson.version);
|
950 | return [2];
|
951 | }
|
952 | });
|
953 | });
|
954 | };
|
955 | ServerPackageBuilder.prototype._getCommonConfig = function () {
|
956 | var tsconfig = fs.readJsonSync(this._packagePath("tsconfig.json"));
|
957 | var alias = {};
|
958 | if (tsconfig.compilerOptions.paths) {
|
959 | for (var _i = 0, _a = Object.keys(tsconfig.compilerOptions.paths); _i < _a.length; _i++) {
|
960 | var key = _a[_i];
|
961 | alias[key] = this._packagePath(tsconfig.compilerOptions.paths[key][0].replace(/[\\/]src[\\/]([^\\/.]*)\.ts$/, ""));
|
962 | }
|
963 | }
|
964 | var webpackConfig = {
|
965 | target: "node",
|
966 | node: {
|
967 | __dirname: true
|
968 | },
|
969 | resolve: {
|
970 | extensions: [".ts", ".js", ".json"],
|
971 | alias: __assign({ "node-gyp-build": this._loadersPath("node-gyp-build.js") }, alias)
|
972 | },
|
973 | entry: this._packagePath("src/app.ts"),
|
974 | output: {
|
975 | path: this._packagePath(tsconfig.compilerOptions.outDir || "dist"),
|
976 | filename: "app.js"
|
977 | },
|
978 | module: {
|
979 | rules: [
|
980 | {
|
981 | enforce: "pre",
|
982 | test: /\.js$/,
|
983 | use: ["source-map-loader"],
|
984 | include: /node_modules[\\/]@simplism/
|
985 | },
|
986 | {
|
987 | test: /\.ts$/,
|
988 | exclude: /node_modules/,
|
989 | loader: this._loadersPath("ts-transpile-loader.js"),
|
990 | options: {
|
991 | logger: this._logger
|
992 | }
|
993 | },
|
994 | {
|
995 | test: /\.node$/,
|
996 | loader: this._loadersPath("node-loader.js")
|
997 | },
|
998 | {
|
999 | test: /\.(png|jpe?g|gif|svg|woff|woff2|ttf|eot|ico|otf)$/,
|
1000 | loader: "file-loader",
|
1001 | options: {
|
1002 | name: "assets/[name].[ext]?[hash]"
|
1003 | }
|
1004 | }
|
1005 | ]
|
1006 | },
|
1007 | plugins: [
|
1008 | new TsCheckAndDeclarationPlugin_1.TsCheckAndDeclarationPlugin({
|
1009 | packageName: this._packageName,
|
1010 | logger: this._logger
|
1011 | }),
|
1012 | new FriendlyLoggerPlugin_1.FriendlyLoggerPlugin({
|
1013 | packageName: this._packageName,
|
1014 | logger: this._logger
|
1015 | })
|
1016 | ]
|
1017 | };
|
1018 | var packageJson = fs.readJsonSync(this._packagePath("package.json"));
|
1019 | var depTypeNames = ["dependencies", "peerDependencies", "optionalDependencies"];
|
1020 | for (var _b = 0, depTypeNames_1 = depTypeNames; _b < depTypeNames_1.length; _b++) {
|
1021 | var depTypeName = depTypeNames_1[_b];
|
1022 | for (var _c = 0, _d = Object.keys(packageJson[depTypeName] || {}); _c < _d.length; _c++) {
|
1023 | var depName = _d[_c];
|
1024 | if (depName.startsWith("@simplism")) {
|
1025 | if (fs.existsSync(this._projectPath("node_modules/" + depName + "/assets"))) {
|
1026 | webpackConfig.plugins.push(new CopyWebpackPlugin([
|
1027 | {
|
1028 | from: this._projectPath("node_modules/" + depName + "/assets"),
|
1029 | to: "node_modules/" + depName + "/assets"
|
1030 | }
|
1031 | ]));
|
1032 | }
|
1033 | }
|
1034 | }
|
1035 | }
|
1036 | return webpackConfig;
|
1037 | };
|
1038 | ServerPackageBuilder.prototype._envStringify = function (param) {
|
1039 | var result = {};
|
1040 | for (var _i = 0, _a = Object.keys(param); _i < _a.length; _i++) {
|
1041 | var key = _a[_i];
|
1042 | result[key] = param[key] === undefined ? "undefined" : JSON.stringify(param[key]);
|
1043 | }
|
1044 | return result;
|
1045 | };
|
1046 | ServerPackageBuilder.prototype._loadersPath = function () {
|
1047 | var args = [];
|
1048 | for (var _i = 0; _i < arguments.length; _i++) {
|
1049 | args[_i] = arguments[_i];
|
1050 | }
|
1051 | return fs.existsSync(path.resolve(process.cwd(), "node_modules/@simplism/cli/loaders"))
|
1052 | ? path.resolve.apply(path, [process.cwd(), "node_modules/@simplism/cli/loaders"].concat(args)) : path.resolve.apply(path, [__dirname, "../../loaders"].concat(args));
|
1053 | };
|
1054 | ServerPackageBuilder.prototype._projectPath = function () {
|
1055 | var args = [];
|
1056 | for (var _i = 0; _i < arguments.length; _i++) {
|
1057 | args[_i] = arguments[_i];
|
1058 | }
|
1059 | return path.resolve.apply(path, [process.cwd()].concat(args));
|
1060 | };
|
1061 | ServerPackageBuilder.prototype._packagePath = function () {
|
1062 | var args = [];
|
1063 | for (var _i = 0; _i < arguments.length; _i++) {
|
1064 | args[_i] = arguments[_i];
|
1065 | }
|
1066 | return path.resolve.apply(path, [process.cwd(), "packages/" + this._packageName].concat(args));
|
1067 | };
|
1068 | return ServerPackageBuilder;
|
1069 | }());
|
1070 | exports.ServerPackageBuilder = ServerPackageBuilder;
|
1071 |
|
1072 | }.call(this, "packages\\cli\\src\\builders"))
|
1073 |
|
1074 | }),
|
1075 |
|
1076 | (function(module, exports) {
|
1077 |
|
1078 | module.exports = require("@simplism/storage");
|
1079 |
|
1080 | }),
|
1081 |
|
1082 | (function(module, exports) {
|
1083 |
|
1084 | module.exports = require("copy-webpack-plugin");
|
1085 |
|
1086 | }),
|
1087 |
|
1088 | (function(module, exports, __webpack_require__) {
|
1089 |
|
1090 | "use strict";
|
1091 | (function(__dirname) {
|
1092 | var __assign = (this && this.__assign) || function () {
|
1093 | __assign = Object.assign || function(t) {
|
1094 | for (var s, i = 1, n = arguments.length; i < n; i++) {
|
1095 | s = arguments[i];
|
1096 | for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
|
1097 | t[p] = s[p];
|
1098 | }
|
1099 | return t;
|
1100 | };
|
1101 | return __assign.apply(this, arguments);
|
1102 | };
|
1103 | var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
1104 | return new (P || (P = Promise))(function (resolve, reject) {
|
1105 | function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
1106 | function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
1107 | function step(result) { result.done ? resolve(result.value) : new P(function (resolve) { resolve(result.value); }).then(fulfilled, rejected); }
|
1108 | step((generator = generator.apply(thisArg, _arguments || [])).next());
|
1109 | });
|
1110 | };
|
1111 | var __generator = (this && this.__generator) || function (thisArg, body) {
|
1112 | var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
|
1113 | return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
1114 | function verb(n) { return function (v) { return step([n, v]); }; }
|
1115 | function step(op) {
|
1116 | if (f) throw new TypeError("Generator is already executing.");
|
1117 | while (_) try {
|
1118 | if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
|
1119 | if (y = 0, t) op = [op[0] & 2, t.value];
|
1120 | switch (op[0]) {
|
1121 | case 0: case 1: t = op; break;
|
1122 | case 4: _.label++; return { value: op[1], done: false };
|
1123 | case 5: _.label++; y = op[1]; op = [0]; continue;
|
1124 | case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
1125 | default:
|
1126 | if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
1127 | if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
1128 | if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
1129 | if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
1130 | if (t[2]) _.ops.pop();
|
1131 | _.trys.pop(); continue;
|
1132 | }
|
1133 | op = body.call(thisArg, _);
|
1134 | } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
1135 | if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
1136 | }
|
1137 | };
|
1138 | Object.defineProperty(exports, "__esModule", { value: true });
|
1139 | var path = __webpack_require__(1);
|
1140 | var webpack = __webpack_require__(5);
|
1141 | var glob = __webpack_require__(9);
|
1142 | var fs = __webpack_require__(0);
|
1143 | var HtmlWebpackPlugin = __webpack_require__(23);
|
1144 | var CopyWebpackPlugin = __webpack_require__(15);
|
1145 | var core_1 = __webpack_require__(2);
|
1146 | var FriendlyLoggerPlugin_1 = __webpack_require__(8);
|
1147 | var storage_1 = __webpack_require__(14);
|
1148 | var webpackMerge = __webpack_require__(6);
|
1149 | var WebpackDevServer = __webpack_require__(24);
|
1150 | var TsCheckAndDeclarationPlugin_1 = __webpack_require__(7);
|
1151 | var childProcess = __webpack_require__(3);
|
1152 | var ClientPackageBuilder = (function () {
|
1153 | function ClientPackageBuilder(_config) {
|
1154 | this._config = _config;
|
1155 | this._logger = new core_1.Logger("@simplism/cli", this._config.name + ":");
|
1156 | }
|
1157 | Object.defineProperty(ClientPackageBuilder.prototype, "_packageName", {
|
1158 | get: function () {
|
1159 | return this._config.name.includes(":") ? this._config.name.slice(0, this._config.name.indexOf(":")) : this._config.name;
|
1160 | },
|
1161 | enumerable: true,
|
1162 | configurable: true
|
1163 | });
|
1164 | ClientPackageBuilder.prototype.buildAsync = function () {
|
1165 | return __awaiter(this, void 0, Promise, function () {
|
1166 | var tsconfig, distPath;
|
1167 | var _this = this;
|
1168 | return __generator(this, function (_a) {
|
1169 | switch (_a.label) {
|
1170 | case 0:
|
1171 | tsconfig = fs.readJsonSync(this._packagePath("tsconfig.json"));
|
1172 | distPath = this._packagePath((tsconfig.compilerOptions && tsconfig.compilerOptions.outDir) || "dist");
|
1173 | fs.removeSync(distPath);
|
1174 | return [4, Promise.all((this._config.platforms || ["web"]).map(function (platform) { return __awaiter(_this, void 0, void 0, function () {
|
1175 | var clientDistPath, cordovaProjectPath, version, configFileContent, cordovaBinPath, packageVersion, apkFileName, distApkFileName;
|
1176 | var _this = this;
|
1177 | return __generator(this, function (_a) {
|
1178 | switch (_a.label) {
|
1179 | case 0:
|
1180 | if (this._config.cordova) {
|
1181 | this._initializeCordova(platform);
|
1182 | }
|
1183 | clientDistPath = this._config.cordova
|
1184 | ? this._packagePath(".cordova", "www")
|
1185 | : distPath;
|
1186 | fs.removeSync(clientDistPath);
|
1187 | return [4, new Promise(function (resolve, reject) {
|
1188 | var webpackConfig = webpackMerge(_this._getCommonConfig(platform), {
|
1189 | mode: "production",
|
1190 | devtool: "source-map",
|
1191 | entry: _this._loadersPath("client-main.js"),
|
1192 | output: {
|
1193 | path: clientDistPath,
|
1194 | publicPath: _this._config.cordova ? "/android_asset/www/" : "/" + _this._packageName + "/",
|
1195 | filename: "app.js",
|
1196 | chunkFilename: "[name].chunk.js"
|
1197 | },
|
1198 | optimization: {
|
1199 | noEmitOnErrors: true,
|
1200 | minimize: false
|
1201 | },
|
1202 | plugins: [
|
1203 | new HtmlWebpackPlugin({
|
1204 | template: _this._loadersPath("index.ejs"),
|
1205 | BASE_HREF: platform === "android" ? "/android_asset/www/" : "/" + _this._packageName + "/",
|
1206 | PLATFORM: platform,
|
1207 | HAS_FAVICON: !!_this._config.favicon || fs.existsSync(_this._packagePath("src/favicon.ico"))
|
1208 | }),
|
1209 | new webpack.DefinePlugin({
|
1210 | "process.env": _this._envStringify(__assign({ VERSION: fs.readJsonSync(_this._packagePath("package.json")).version, PLATFORM: platform, PACKAGE_NAME: _this._packageName }, _this._config.env, _this._config["env.production"]))
|
1211 | })
|
1212 | ]
|
1213 | });
|
1214 | webpack(webpackConfig, function (err) {
|
1215 | if (err) {
|
1216 | reject(err);
|
1217 | return;
|
1218 | }
|
1219 | resolve();
|
1220 | });
|
1221 | })];
|
1222 | case 1:
|
1223 | _a.sent();
|
1224 | if (this._config.cordova) {
|
1225 | this._logger.log("CORDOVA \uBE4C\uB4DC");
|
1226 | cordovaProjectPath = this._packagePath(".cordova");
|
1227 | if (platform === "android" && this._config.cordova.sign) {
|
1228 | fs.copySync(path.resolve(process.cwd(), ".sign", this._config.cordova.sign, "release-signing.jks"), path.resolve(cordovaProjectPath, "platforms", "android", "release-signing.jks"));
|
1229 | fs.copySync(path.resolve(process.cwd(), ".sign", this._config.cordova.sign, "release-signing.properties"), path.resolve(cordovaProjectPath, "platforms", "android", "release-signing.properties"));
|
1230 | }
|
1231 | if (this._config.cordova.icon) {
|
1232 | fs.copySync(this._config.cordova.icon, path.resolve(cordovaProjectPath, "res", "icon", "icon.png"));
|
1233 | }
|
1234 | version = fs.readJsonSync(this._packagePath("package.json")).version;
|
1235 | configFileContent = fs.readFileSync(path.resolve(this._packagePath(), ".cordova", "config.xml"), "utf-8");
|
1236 | configFileContent = configFileContent.replace(/<allow-navigation href="[^"]"\s?\/>/g, "");
|
1237 | configFileContent = configFileContent.replace(/version="[^"]*"/g, "version=\"" + version + "\"");
|
1238 | if (this._config.cordova.icon && !configFileContent.includes("<icon")) {
|
1239 | configFileContent = configFileContent.replace("</widget>", " <icon src=\"res/icon/icon.png\" />\r\n</widget>");
|
1240 | }
|
1241 | fs.writeFileSync(path.resolve(cordovaProjectPath, "config.xml"), configFileContent, "utf-8");
|
1242 | cordovaBinPath = this._projectPath("node_modules", ".bin", "cordova.cmd");
|
1243 | childProcess.spawnSync(cordovaBinPath, [
|
1244 | "build",
|
1245 | platform,
|
1246 | "--release"
|
1247 | ], {
|
1248 | shell: true,
|
1249 | stdio: "inherit",
|
1250 | cwd: cordovaProjectPath
|
1251 | });
|
1252 | if (platform === "android") {
|
1253 | packageVersion = fs.readJsonSync(this._packagePath("package.json")).version;
|
1254 | apkFileName = this._config.cordova.sign ? "app-release.apk" : "app-release-unsigned.apk";
|
1255 | distApkFileName = "" + this._config.name.replace(/ /g, "_") + (this._config.cordova.sign ? "" : "-unsigned") + "-v" + packageVersion + ".apk";
|
1256 | fs.mkdirsSync(distPath);
|
1257 | fs.copyFileSync(path.resolve(cordovaProjectPath, "platforms", "android", "app", "build", "outputs", "apk", "release", apkFileName), path.resolve(distPath, distApkFileName));
|
1258 | }
|
1259 | }
|
1260 | return [2];
|
1261 | }
|
1262 | });
|
1263 | }); }))];
|
1264 | case 1:
|
1265 | _a.sent();
|
1266 | return [2];
|
1267 | }
|
1268 | });
|
1269 | });
|
1270 | };
|
1271 | ClientPackageBuilder.prototype.watchAsync = function () {
|
1272 | return __awaiter(this, void 0, Promise, function () {
|
1273 | var tsconfig;
|
1274 | var _this = this;
|
1275 | return __generator(this, function (_a) {
|
1276 | switch (_a.label) {
|
1277 | case 0:
|
1278 | if (!this._config.devServer) {
|
1279 | throw new Error("'--watch'옵션을 사용하려면 설정파일에 'devServer'가 설정되어야 합니다.");
|
1280 | }
|
1281 | tsconfig = fs.readJsonSync(this._packagePath("tsconfig.json"));
|
1282 | fs.removeSync(this._packagePath((tsconfig.compilerOptions && (tsconfig.compilerOptions && tsconfig.compilerOptions.outDir)) || "dist"));
|
1283 | return [4, Promise.all((this._config.platforms || ["web"]).map(function (platform) { return __awaiter(_this, void 0, void 0, function () {
|
1284 | var _this = this;
|
1285 | return __generator(this, function (_a) {
|
1286 | switch (_a.label) {
|
1287 | case 0:
|
1288 | if (this._config.cordova) {
|
1289 | this._initializeCordova(platform);
|
1290 | }
|
1291 | return [4, new Promise(function (resolve, reject) {
|
1292 | var webpackConfig = webpackMerge(_this._getCommonConfig(platform), {
|
1293 | mode: "development",
|
1294 | devtool: "cheap-module-source-map",
|
1295 | entry: [
|
1296 | "webpack-dev-server/client?http://0.0.0.0:" + _this._config.devServer.port + "/",
|
1297 | "webpack/hot/dev-server",
|
1298 | _this._loadersPath("client-main.js")
|
1299 | ],
|
1300 | output: {
|
1301 | path: _this._packagePath((tsconfig.compilerOptions && tsconfig.compilerOptions.outDir) || "dist"),
|
1302 | publicPath: "/",
|
1303 | filename: "app.js",
|
1304 | chunkFilename: "[name].chunk.js"
|
1305 | },
|
1306 | plugins: [
|
1307 | new webpack.HotModuleReplacementPlugin(),
|
1308 | new HtmlWebpackPlugin({
|
1309 | template: _this._loadersPath("index.ejs"),
|
1310 | BASE_HREF: "/",
|
1311 | PLATFORM: platform,
|
1312 | HAS_FAVICON: !!_this._config.favicon || fs.existsSync(_this._packagePath("src/favicon.ico"))
|
1313 | }),
|
1314 | new webpack.DefinePlugin({
|
1315 | "process.env": _this._envStringify(__assign({ VERSION: fs.readJsonSync(_this._packagePath("package.json")).version, PLATFORM: platform, PACKAGE_NAME: _this._packageName }, _this._config.env, _this._config["env.development"]))
|
1316 | })
|
1317 | ]
|
1318 | });
|
1319 | if (_this._config.cordova) {
|
1320 | webpackConfig.plugins.push(new CopyWebpackPlugin([{
|
1321 | context: path.resolve(_this._packagePath(), ".cordova/platforms/" + platform + "/platform_www"),
|
1322 | from: "**/*"
|
1323 | }]));
|
1324 | }
|
1325 | var compiler = webpack(webpackConfig);
|
1326 | var server = new WebpackDevServer(compiler, {
|
1327 | historyApiFallback: true,
|
1328 | quiet: true,
|
1329 | hot: true,
|
1330 | disableHostCheck: true
|
1331 | });
|
1332 | server.listen(_this._config.devServer.port, function (err) {
|
1333 | if (err) {
|
1334 | reject(err);
|
1335 | return;
|
1336 | }
|
1337 | _this._logger.log("\uAC1C\uBC1C \uC11C\uBC84 \uC2DC\uC791\uB428 [\uD3EC\uD2B8: " + _this._config.devServer.port + "]");
|
1338 | resolve();
|
1339 | });
|
1340 | })];
|
1341 | case 1:
|
1342 | _a.sent();
|
1343 | return [2];
|
1344 | }
|
1345 | });
|
1346 | }); }))];
|
1347 | case 1:
|
1348 | _a.sent();
|
1349 | return [2];
|
1350 | }
|
1351 | });
|
1352 | });
|
1353 | };
|
1354 | ClientPackageBuilder.prototype.publishAsync = function () {
|
1355 | return __awaiter(this, void 0, Promise, function () {
|
1356 | var tsconfig, distPath, storage, filePaths, _i, filePaths_1, filePath, ftpFilePath, cumDir, _a, _b, ftpDir, ftpDirPath, packageJson;
|
1357 | return __generator(this, function (_c) {
|
1358 | switch (_c.label) {
|
1359 | case 0:
|
1360 | this._logger.log("\uBC30\uD3EC...");
|
1361 | if (!this._config.publish) {
|
1362 | throw new Error("설정파일에 'publish'옵션이 설정되어야 합니다.");
|
1363 | }
|
1364 | tsconfig = fs.readJsonSync(this._packagePath("tsconfig.json"));
|
1365 | distPath = this._packagePath((tsconfig.compilerOptions && tsconfig.compilerOptions.outDir) || "dist");
|
1366 | storage = new storage_1.FtpStorage();
|
1367 | return [4, storage.connectAsync({
|
1368 | host: this._config.publish.host,
|
1369 | port: this._config.publish.port,
|
1370 | user: this._config.publish.username,
|
1371 | password: this._config.publish.password
|
1372 | })];
|
1373 | case 1:
|
1374 | _c.sent();
|
1375 | return [4, storage.mkdirAsync(this._config.publish.path)];
|
1376 | case 2:
|
1377 | _c.sent();
|
1378 | filePaths = glob.sync(path.resolve(distPath, "**/*"));
|
1379 | _i = 0, filePaths_1 = filePaths;
|
1380 | _c.label = 3;
|
1381 | case 3:
|
1382 | if (!(_i < filePaths_1.length)) return [3, 13];
|
1383 | filePath = filePaths_1[_i];
|
1384 | ftpFilePath = this._config.publish.path + "/" + path.relative(distPath, filePath).replace(/\\/g, "/");
|
1385 | if (!fs.lstatSync(filePath).isDirectory()) return [3, 5];
|
1386 | return [4, storage.mkdirAsync(ftpFilePath)];
|
1387 | case 4:
|
1388 | _c.sent();
|
1389 | return [3, 12];
|
1390 | case 5:
|
1391 | if (!/[\\/]/.test(ftpFilePath)) return [3, 9];
|
1392 | cumDir = "";
|
1393 | _a = 0, _b = ftpFilePath.split(/[\\/]/).slice(0, -1);
|
1394 | _c.label = 6;
|
1395 | case 6:
|
1396 | if (!(_a < _b.length)) return [3, 9];
|
1397 | ftpDir = _b[_a];
|
1398 | cumDir += ftpDir + "/";
|
1399 | return [4, storage.mkdirAsync(cumDir)];
|
1400 | case 7:
|
1401 | _c.sent();
|
1402 | _c.label = 8;
|
1403 | case 8:
|
1404 | _a++;
|
1405 | return [3, 6];
|
1406 | case 9: return [4, storage.putAsync(filePath, ftpFilePath)];
|
1407 | case 10:
|
1408 | _c.sent();
|
1409 | if (!(this._config.platforms &&
|
1410 | this._config.platforms.includes("android") &&
|
1411 | this._config.cordova &&
|
1412 | this._config.cordova.sign &&
|
1413 | path.extname(filePath) === ".apk")) return [3, 12];
|
1414 | ftpDirPath = ftpFilePath.split(/[\\/]/).slice(0, -1).join("/");
|
1415 | return [4, storage.putAsync(filePath, ftpDirPath + "/lastest.apk")];
|
1416 | case 11:
|
1417 | _c.sent();
|
1418 | _c.label = 12;
|
1419 | case 12:
|
1420 | _i++;
|
1421 | return [3, 3];
|
1422 | case 13: return [4, storage.closeAsync()];
|
1423 | case 14:
|
1424 | _c.sent();
|
1425 | packageJson = fs.readJsonSync(this._packagePath("package.json"));
|
1426 | this._logger.info("\uBC30\uD3EC \uC644\uB8CC: v" + packageJson.version);
|
1427 | return [2];
|
1428 | }
|
1429 | });
|
1430 | });
|
1431 | };
|
1432 | ClientPackageBuilder.prototype._getCommonConfig = function (platform) {
|
1433 | var tsconfig = fs.readJsonSync(this._packagePath("tsconfig.json"));
|
1434 | var alias = {};
|
1435 | if (tsconfig.compilerOptions.paths) {
|
1436 | for (var _i = 0, _a = Object.keys(tsconfig.compilerOptions.paths); _i < _a.length; _i++) {
|
1437 | var key = _a[_i];
|
1438 | alias[key] = this._packagePath(tsconfig.compilerOptions.paths[key][0].replace(/[\\/]src[\\/]([^\\/.]*)\.ts$/, ""));
|
1439 | }
|
1440 | }
|
1441 | alias["SIMPLISM_CLIENT_APP_MODULE"] = this._packagePath("src/AppModule");
|
1442 | return {
|
1443 | resolve: {
|
1444 | extensions: [".ts", ".js", ".json"],
|
1445 | alias: __assign({ "soap": this._loadersPath("soap.js") }, alias)
|
1446 | },
|
1447 | module: {
|
1448 | rules: [
|
1449 | {
|
1450 | enforce: "pre",
|
1451 | test: /\.js$/,
|
1452 | use: ["source-map-loader"],
|
1453 | exclude: /node_modules[\\/](?!@simplism)/
|
1454 | },
|
1455 | {
|
1456 | test: /\.js$/,
|
1457 | parser: { system: true }
|
1458 | },
|
1459 | {
|
1460 | test: /\.ts$/,
|
1461 | exclude: /node_modules/,
|
1462 | loaders: [
|
1463 | {
|
1464 | loader: this._loadersPath("ts-transpile-loader.js"),
|
1465 | options: {
|
1466 | logger: this._logger
|
1467 | }
|
1468 | },
|
1469 | "angular-router-loader"
|
1470 | ]
|
1471 | },
|
1472 | {
|
1473 | test: /\.html$/,
|
1474 | loader: "html-loader"
|
1475 | },
|
1476 | {
|
1477 | test: /\.scss$/,
|
1478 | loaders: [
|
1479 | "style-loader",
|
1480 | "css-loader",
|
1481 | "sass-loader"
|
1482 | ]
|
1483 | },
|
1484 | {
|
1485 | test: /\.css$/,
|
1486 | loaders: [
|
1487 | "style-loader",
|
1488 | "css-loader"
|
1489 | ]
|
1490 | },
|
1491 | {
|
1492 | test: /\.(png|jpe?g|gif|svg|woff|woff2|ttf|eot|ico|otf|xlsx)$/,
|
1493 | loader: "file-loader",
|
1494 | options: {
|
1495 | name: "assets/[name].[ext]?[hash]"
|
1496 | }
|
1497 | }
|
1498 | ]
|
1499 | },
|
1500 | plugins: [
|
1501 | new TsCheckAndDeclarationPlugin_1.TsCheckAndDeclarationPlugin({
|
1502 | tsConfigPath: this._packagePath("tsconfig.json"),
|
1503 | packageName: this._packageName,
|
1504 | logger: this._logger
|
1505 | }),
|
1506 | new webpack.ContextReplacementPlugin(/angular[\\/]core[\\/]fesm5/, this._packagePath("src"), {}),
|
1507 | new FriendlyLoggerPlugin_1.FriendlyLoggerPlugin({
|
1508 | packageName: this._packageName,
|
1509 | logger: this._logger
|
1510 | }),
|
1511 | !!this._config.favicon || fs.existsSync(this._packagePath("src/favicon.ico"))
|
1512 | ? new CopyWebpackPlugin([
|
1513 | {
|
1514 | from: this._config.favicon ? this._projectPath(this._config.favicon) : this._packagePath("src/favicon.ico"),
|
1515 | to: "favicon.ico"
|
1516 | }
|
1517 | ])
|
1518 | : undefined
|
1519 | ].filterExists(),
|
1520 | optimization: {
|
1521 | splitChunks: {
|
1522 | cacheGroups: {
|
1523 | vendor: {
|
1524 | test: /[\\/]node_modules[\\/](?!@simplism)/,
|
1525 | name: "vendor",
|
1526 | chunks: "initial",
|
1527 | enforce: true
|
1528 | },
|
1529 | simplism: {
|
1530 | test: /[\\/]node_modules[\\/]@simplism/,
|
1531 | name: "simplism",
|
1532 | chunks: "initial",
|
1533 | enforce: true
|
1534 | }
|
1535 | }
|
1536 | }
|
1537 | },
|
1538 | externals: [
|
1539 | function (context, request, callback) {
|
1540 | if (request === "net" || request === "fs" || request === "tls") {
|
1541 | callback(undefined, "\"\"");
|
1542 | return;
|
1543 | }
|
1544 | callback(undefined, undefined);
|
1545 | }
|
1546 | ]
|
1547 | };
|
1548 | };
|
1549 | ClientPackageBuilder.prototype._initializeCordova = function (platform) {
|
1550 | if (!this._config.cordova)
|
1551 | return;
|
1552 | var cordovaProjectPath = this._packagePath(".cordova");
|
1553 | var cordovaBinPath = this._projectPath("node_modules", ".bin", "cordova.cmd");
|
1554 | if (!fs.existsSync(cordovaProjectPath)) {
|
1555 | this._logger.log("CORDOVA \uD504\uB85C\uC81D\uD2B8 \uC0DD\uC131");
|
1556 | childProcess.spawnSync(cordovaBinPath, [
|
1557 | "create",
|
1558 | ".cordova",
|
1559 | this._config.cordova.appId,
|
1560 | "\"" + (this._config.cordova.name || this._config.name) + "\""
|
1561 | ], {
|
1562 | shell: true,
|
1563 | stdio: "inherit",
|
1564 | cwd: this._packagePath()
|
1565 | });
|
1566 | }
|
1567 | fs.mkdirsSync(path.resolve(cordovaProjectPath, "www"));
|
1568 | if (!fs.existsSync(path.resolve(cordovaProjectPath, "platforms", platform))) {
|
1569 | this._logger.log("CORDOVA \uD50C\uB7AB\uD3FC \uC0DD\uC131: " + platform);
|
1570 | childProcess.spawnSync(cordovaBinPath, [
|
1571 | "platform",
|
1572 | "add",
|
1573 | platform
|
1574 | ], {
|
1575 | shell: true,
|
1576 | stdio: "inherit",
|
1577 | cwd: cordovaProjectPath
|
1578 | });
|
1579 | }
|
1580 | var prevPlugins = Object.values(fs.readJsonSync(path.resolve(cordovaProjectPath, "plugins", "fetch.json"))).map(function (item) { return item["source"].id ? item["source"].id.replace(/@.*$/, "") : item["source"].url; });
|
1581 | if (!prevPlugins.includes("cordova-android-support-gradle-release")) {
|
1582 | this._logger.log("CORDOVA \uD50C\uB7EC\uADF8\uC778 \uC124\uCE58: cordova-android-support-gradle-release");
|
1583 | childProcess.spawnSync(cordovaBinPath, [
|
1584 | "plugin",
|
1585 | "add",
|
1586 | "cordova-android-support-gradle-release"
|
1587 | ], {
|
1588 | shell: true,
|
1589 | stdio: "inherit",
|
1590 | cwd: cordovaProjectPath
|
1591 | });
|
1592 | }
|
1593 | if (this._config.cordova.plugins) {
|
1594 | for (var _i = 0, _a = this._config.cordova.plugins; _i < _a.length; _i++) {
|
1595 | var plugin = _a[_i];
|
1596 | if (!prevPlugins.includes(plugin)) {
|
1597 | this._logger.log("CORDOVA \uD50C\uB7EC\uADF8\uC778 \uC124\uCE58 : " + plugin);
|
1598 | childProcess.spawnSync(cordovaBinPath, [
|
1599 | "plugin",
|
1600 | "add",
|
1601 | plugin
|
1602 | ], {
|
1603 | shell: true,
|
1604 | stdio: "inherit",
|
1605 | cwd: cordovaProjectPath
|
1606 | });
|
1607 | }
|
1608 | }
|
1609 | }
|
1610 | };
|
1611 | ClientPackageBuilder.prototype._envStringify = function (param) {
|
1612 | var result = {};
|
1613 | for (var _i = 0, _a = Object.keys(param); _i < _a.length; _i++) {
|
1614 | var key = _a[_i];
|
1615 | result[key] = param[key] === undefined ? "undefined" : JSON.stringify(param[key]);
|
1616 | }
|
1617 | return result;
|
1618 | };
|
1619 | ClientPackageBuilder.prototype._loadersPath = function () {
|
1620 | var args = [];
|
1621 | for (var _i = 0; _i < arguments.length; _i++) {
|
1622 | args[_i] = arguments[_i];
|
1623 | }
|
1624 | return fs.existsSync(this._projectPath("node_modules/@simplism/cli/loaders"))
|
1625 | ? this._projectPath.apply(this, ["node_modules/@simplism/cli/loaders"].concat(args)) : path.resolve.apply(path, [__dirname, "../../loaders"].concat(args));
|
1626 | };
|
1627 | ClientPackageBuilder.prototype._projectPath = function () {
|
1628 | var args = [];
|
1629 | for (var _i = 0; _i < arguments.length; _i++) {
|
1630 | args[_i] = arguments[_i];
|
1631 | }
|
1632 | var split = process.cwd().split(/[\\/]/);
|
1633 | if (split[split.length - 1] === this._packageName) {
|
1634 | return path.resolve.apply(path, [process.cwd(), "../.."].concat(args));
|
1635 | }
|
1636 | return path.resolve.apply(path, [process.cwd()].concat(args));
|
1637 | };
|
1638 | ClientPackageBuilder.prototype._packagePath = function () {
|
1639 | var args = [];
|
1640 | for (var _i = 0; _i < arguments.length; _i++) {
|
1641 | args[_i] = arguments[_i];
|
1642 | }
|
1643 | return this._projectPath.apply(this, ["packages/" + this._packageName].concat(args));
|
1644 | };
|
1645 | return ClientPackageBuilder;
|
1646 | }());
|
1647 | exports.ClientPackageBuilder = ClientPackageBuilder;
|
1648 |
|
1649 | }.call(this, "packages\\cli\\src\\builders"))
|
1650 |
|
1651 | }),
|
1652 |
|
1653 | (function(module, exports) {
|
1654 |
|
1655 | module.exports = require("os");
|
1656 |
|
1657 | }),
|
1658 |
|
1659 | (function(module, exports, __webpack_require__) {
|
1660 |
|
1661 | "use strict";
|
1662 |
|
1663 | var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
1664 | return new (P || (P = Promise))(function (resolve, reject) {
|
1665 | function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
1666 | function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
1667 | function step(result) { result.done ? resolve(result.value) : new P(function (resolve) { resolve(result.value); }).then(fulfilled, rejected); }
|
1668 | step((generator = generator.apply(thisArg, _arguments || [])).next());
|
1669 | });
|
1670 | };
|
1671 | var __generator = (this && this.__generator) || function (thisArg, body) {
|
1672 | var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
|
1673 | return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
1674 | function verb(n) { return function (v) { return step([n, v]); }; }
|
1675 | function step(op) {
|
1676 | if (f) throw new TypeError("Generator is already executing.");
|
1677 | while (_) try {
|
1678 | if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
|
1679 | if (y = 0, t) op = [op[0] & 2, t.value];
|
1680 | switch (op[0]) {
|
1681 | case 0: case 1: t = op; break;
|
1682 | case 4: _.label++; return { value: op[1], done: false };
|
1683 | case 5: _.label++; y = op[1]; op = [0]; continue;
|
1684 | case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
1685 | default:
|
1686 | if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
1687 | if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
1688 | if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
1689 | if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
1690 | if (t[2]) _.ops.pop();
|
1691 | _.trys.pop(); continue;
|
1692 | }
|
1693 | op = body.call(thisArg, _);
|
1694 | } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
1695 | if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
1696 | }
|
1697 | };
|
1698 | var _this = this;
|
1699 | Object.defineProperty(exports, "__esModule", { value: true });
|
1700 | var yargs = __webpack_require__(19);
|
1701 | var buildAsync_1 = __webpack_require__(20);
|
1702 | var publishAsync_1 = __webpack_require__(26);
|
1703 | var localUpdateAsync_1 = __webpack_require__(27);
|
1704 | var events_1 = __webpack_require__(28);
|
1705 | var keygenAsync_1 = __webpack_require__(29);
|
1706 | var runDeviceAsync_1 = __webpack_require__(31);
|
1707 | var core_1 = __webpack_require__(2);
|
1708 | __webpack_require__(33).install();
|
1709 | events_1.EventEmitter.defaultMaxListeners = 20;
|
1710 | var logger = new core_1.Logger("@simplism/cli", "$");
|
1711 | logger.info("시작");
|
1712 | yargs
|
1713 | .version(false)
|
1714 | .help("help", "도움말")
|
1715 | .alias("help", "h")
|
1716 | .command("build", "프로젝트를 빌드합니다.", function (cmd) { return cmd.version(false)
|
1717 | .options({
|
1718 | config: {
|
1719 | type: "string",
|
1720 | describe: "설정파일"
|
1721 | },
|
1722 | watch: {
|
1723 | type: "boolean",
|
1724 | describe: "변경을 감지하여 자동으로 다시 빌드합니다.",
|
1725 | default: false
|
1726 | },
|
1727 | package: {
|
1728 | type: "string",
|
1729 | describe: "빌드할 패키지를 설정합니다."
|
1730 | },
|
1731 | env: {
|
1732 | describe: "환경변수를 설정합니다"
|
1733 | }
|
1734 | }); }, function (argv) { return __awaiter(_this, void 0, void 0, function () {
|
1735 | return __generator(this, function (_a) {
|
1736 | switch (_a.label) {
|
1737 | case 0: return [4, buildAsync_1.buildAsync(argv)
|
1738 | .catch(function (err) {
|
1739 | logger.error(err);
|
1740 | process.exit(1);
|
1741 | })];
|
1742 | case 1:
|
1743 | _a.sent();
|
1744 | return [2];
|
1745 | }
|
1746 | });
|
1747 | }); })
|
1748 | .command("publish", "배포합니다.", function (cmd) { return cmd.version(false)
|
1749 | .options({
|
1750 | config: {
|
1751 | type: "string",
|
1752 | describe: "설정파일"
|
1753 | },
|
1754 | package: {
|
1755 | type: "string",
|
1756 | describe: "배포할 패키지를 설정합니다."
|
1757 | },
|
1758 | env: {
|
1759 | describe: "환경변수를 설정합니다"
|
1760 | }
|
1761 | }); }, function (argv) { return __awaiter(_this, void 0, void 0, function () {
|
1762 | return __generator(this, function (_a) {
|
1763 | switch (_a.label) {
|
1764 | case 0: return [4, publishAsync_1.publishAsync(argv)
|
1765 | .catch(function (err) {
|
1766 | logger.error(err);
|
1767 | process.exit(1);
|
1768 | })];
|
1769 | case 1:
|
1770 | _a.sent();
|
1771 | return [2];
|
1772 | }
|
1773 | });
|
1774 | }); })
|
1775 | .command("local-update", "로컬에 있는 simplism 패키지로 의존성 모듈을 덮어씁니다. (고급)", function (cmd) { return cmd.version(false)
|
1776 | .options({
|
1777 | watch: {
|
1778 | type: "boolean",
|
1779 | describe: "변경을 감지하여 자동으로 업데이트합니다.",
|
1780 | default: false
|
1781 | },
|
1782 | config: {
|
1783 | type: "string",
|
1784 | describe: "설정파일"
|
1785 | }
|
1786 | }); }, function (argv) { return __awaiter(_this, void 0, void 0, function () {
|
1787 | return __generator(this, function (_a) {
|
1788 | switch (_a.label) {
|
1789 | case 0: return [4, localUpdateAsync_1.localUpdateAsync(argv)
|
1790 | .catch(function (err) {
|
1791 | logger.error(err);
|
1792 | process.exit(1);
|
1793 | })];
|
1794 | case 1:
|
1795 | _a.sent();
|
1796 | return [2];
|
1797 | }
|
1798 | });
|
1799 | }); })
|
1800 | .command("keygen", "안드로이드 사인키를 생성합니다.", function (cmd) { return cmd
|
1801 | .version(false)
|
1802 | .options({
|
1803 | alias: {
|
1804 | type: "string",
|
1805 | describe: "구분명칭",
|
1806 | required: true
|
1807 | },
|
1808 | password: {
|
1809 | type: "string",
|
1810 | describe: "비밀번호",
|
1811 | required: true
|
1812 | }
|
1813 | }); }, function (argv) { return __awaiter(_this, void 0, void 0, function () {
|
1814 | return __generator(this, function (_a) {
|
1815 | switch (_a.label) {
|
1816 | case 0: return [4, keygenAsync_1.keygenAsync(argv)
|
1817 | .catch(function (err) {
|
1818 | logger.error(err);
|
1819 | process.exit(1);
|
1820 | })];
|
1821 | case 1:
|
1822 | _a.sent();
|
1823 | return [2];
|
1824 | }
|
1825 | });
|
1826 | }); })
|
1827 | .command("run-device", "장치에서 실행합니다.", function (cmd) { return cmd
|
1828 | .version(false)
|
1829 | .options({
|
1830 | config: {
|
1831 | type: "string",
|
1832 | describe: "설정파일"
|
1833 | },
|
1834 | package: {
|
1835 | type: "string",
|
1836 | describe: "실행할 패키지를 설정합니다.",
|
1837 | required: true
|
1838 | },
|
1839 | release: {
|
1840 | type: "boolean",
|
1841 | describe: "릴리즈버전을 실행합니다. (감지중이 아니고, 빌드되어 있어야 합니다.)",
|
1842 | default: false
|
1843 | },
|
1844 | debug: {
|
1845 | type: "boolean",
|
1846 | describe: "디버그버전을 실행합니다. (감지중이 아니고, 빌드되어 있어야 합니다.)",
|
1847 | default: false
|
1848 | }
|
1849 | }); }, function (argv) { return __awaiter(_this, void 0, void 0, function () {
|
1850 | return __generator(this, function (_a) {
|
1851 | switch (_a.label) {
|
1852 | case 0: return [4, runDeviceAsync_1.runDeviceAsync(argv)
|
1853 | .catch(function (err) {
|
1854 | logger.error(err);
|
1855 | process.exit(1);
|
1856 | })];
|
1857 | case 1:
|
1858 | _a.sent();
|
1859 | return [2];
|
1860 | }
|
1861 | });
|
1862 | }); })
|
1863 | .argv;
|
1864 | process.on("exit", function () {
|
1865 | logger.info("완료");
|
1866 | });
|
1867 |
|
1868 |
|
1869 | }),
|
1870 |
|
1871 | (function(module, exports) {
|
1872 |
|
1873 | module.exports = require("yargs");
|
1874 |
|
1875 | }),
|
1876 |
|
1877 | (function(module, exports, __webpack_require__) {
|
1878 |
|
1879 | "use strict";
|
1880 | (function(__dirname) {
|
1881 | var __assign = (this && this.__assign) || function () {
|
1882 | __assign = Object.assign || function(t) {
|
1883 | for (var s, i = 1, n = arguments.length; i < n; i++) {
|
1884 | s = arguments[i];
|
1885 | for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
|
1886 | t[p] = s[p];
|
1887 | }
|
1888 | return t;
|
1889 | };
|
1890 | return __assign.apply(this, arguments);
|
1891 | };
|
1892 | var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
1893 | return new (P || (P = Promise))(function (resolve, reject) {
|
1894 | function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
1895 | function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
1896 | function step(result) { result.done ? resolve(result.value) : new P(function (resolve) { resolve(result.value); }).then(fulfilled, rejected); }
|
1897 | step((generator = generator.apply(thisArg, _arguments || [])).next());
|
1898 | });
|
1899 | };
|
1900 | var __generator = (this && this.__generator) || function (thisArg, body) {
|
1901 | var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
|
1902 | return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
1903 | function verb(n) { return function (v) { return step([n, v]); }; }
|
1904 | function step(op) {
|
1905 | if (f) throw new TypeError("Generator is already executing.");
|
1906 | while (_) try {
|
1907 | if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
|
1908 | if (y = 0, t) op = [op[0] & 2, t.value];
|
1909 | switch (op[0]) {
|
1910 | case 0: case 1: t = op; break;
|
1911 | case 4: _.label++; return { value: op[1], done: false };
|
1912 | case 5: _.label++; y = op[1]; op = [0]; continue;
|
1913 | case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
1914 | default:
|
1915 | if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
1916 | if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
1917 | if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
1918 | if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
1919 | if (t[2]) _.ops.pop();
|
1920 | _.trys.pop(); continue;
|
1921 | }
|
1922 | op = body.call(thisArg, _);
|
1923 | } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
1924 | if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
1925 | }
|
1926 | };
|
1927 | Object.defineProperty(exports, "__esModule", { value: true });
|
1928 | var fs = __webpack_require__(0);
|
1929 | var path = __webpack_require__(1);
|
1930 | var LocalUpdater_1 = __webpack_require__(10);
|
1931 | var LibraryPackageBuilder_1 = __webpack_require__(12);
|
1932 | var core_1 = __webpack_require__(2);
|
1933 | var ServerPackageBuilder_1 = __webpack_require__(13);
|
1934 | var ClientPackageBuilder_1 = __webpack_require__(16);
|
1935 | var semver = __webpack_require__(25);
|
1936 | var os = __webpack_require__(17);
|
1937 | var child_process = __webpack_require__(3);
|
1938 | var FileWatcher_1 = __webpack_require__(11);
|
1939 | function buildAsync(argv) {
|
1940 | return __awaiter(this, void 0, Promise, function () {
|
1941 | var configFilePath, projectConfig, promiseList, _i, _a, packageName, packagePath, runAsync, _loadersPath, lintAsync, rootPackageJsonPath, rootPackageJson, _b, _c, pack, packageJsonPath, packageJson, depTypeNames, _d, depTypeNames_1, depTypeName, _e, _f, depName, _g, _h, pack, _j, _k, packName, packageConfigs_1, completedPackNames_1, _loop_1, _l, _m, pack, _loop_2, _o, _p, packName;
|
1942 | var _this = this;
|
1943 | return __generator(this, function (_q) {
|
1944 | switch (_q.label) {
|
1945 | case 0:
|
1946 | process.env.NODE_ENV = argv.watch ? "development" : "production";
|
1947 | configFilePath = argv.config;
|
1948 | configFilePath = configFilePath ? path.resolve(process.cwd(), configFilePath)
|
1949 | : fs.existsSync(path.resolve(process.cwd(), "simplism.ts")) ? path.resolve(process.cwd(), "simplism.ts")
|
1950 | : fs.existsSync(path.resolve(process.cwd(), "simplism.js")) ? path.resolve(process.cwd(), "simplism.js")
|
1951 | : path.resolve(process.cwd(), "simplism.json");
|
1952 | if (path.extname(configFilePath) === ".ts") {
|
1953 | __webpack_require__(4);
|
1954 | Object.assign(process.env, argv.env);
|
1955 | }
|
1956 | projectConfig = eval("require(configFilePath)");
|
1957 | promiseList = [];
|
1958 | if (argv.watch && projectConfig.localDependencies) {
|
1959 | for (_i = 0, _a = Object.keys(projectConfig.localDependencies); _i < _a.length; _i++) {
|
1960 | packageName = _a[_i];
|
1961 | packagePath = projectConfig.localDependencies[packageName];
|
1962 | if (fs.existsSync(packagePath)) {
|
1963 | promiseList.push(new LocalUpdater_1.LocalUpdater(packageName, packagePath).runAsync(true));
|
1964 | }
|
1965 | }
|
1966 | }
|
1967 | return [4, Promise.all(promiseList)];
|
1968 | case 1:
|
1969 | _q.sent();
|
1970 | promiseList = [];
|
1971 | runAsync = function (config) { return __awaiter(_this, void 0, void 0, function () {
|
1972 | return __generator(this, function (_a) {
|
1973 | switch (_a.label) {
|
1974 | case 0:
|
1975 | if (!!argv.watch) return [3, 7];
|
1976 | if (!(config.type === "client")) return [3, 2];
|
1977 | return [4, new ClientPackageBuilder_1.ClientPackageBuilder(__assign({}, config, { "env": __assign({}, projectConfig.env, config.env, argv.env), "env.production": __assign({}, projectConfig["env.production"], config["env.production"]) })).buildAsync()];
|
1978 | case 1:
|
1979 | _a.sent();
|
1980 | return [3, 6];
|
1981 | case 2:
|
1982 | if (!(config.type === "server")) return [3, 4];
|
1983 | return [4, new ServerPackageBuilder_1.ServerPackageBuilder(__assign({}, config, { "env": __assign({}, projectConfig.env, config.env, argv.env), "env.production": __assign({}, projectConfig["env.production"], config["env.production"]) })).buildAsync()];
|
1984 | case 3:
|
1985 | _a.sent();
|
1986 | return [3, 6];
|
1987 | case 4: return [4, new LibraryPackageBuilder_1.LibraryPackageBuilder(config).buildAsync()];
|
1988 | case 5:
|
1989 | _a.sent();
|
1990 | _a.label = 6;
|
1991 | case 6: return [3, 13];
|
1992 | case 7:
|
1993 | if (!(config.type === "client")) return [3, 9];
|
1994 | return [4, new ClientPackageBuilder_1.ClientPackageBuilder(__assign({}, config, { "env": __assign({}, projectConfig.env, config.env, argv.env), "env.development": __assign({}, projectConfig["env.development"], config["env.development"]) })).watchAsync()];
|
1995 | case 8:
|
1996 | _a.sent();
|
1997 | return [3, 13];
|
1998 | case 9:
|
1999 | if (!(config.type === "server")) return [3, 11];
|
2000 | return [4, new ServerPackageBuilder_1.ServerPackageBuilder(__assign({}, config, { "env": __assign({}, projectConfig.env, config.env, argv.env), "env.development": __assign({}, projectConfig["env.development"], config["env.development"]) })).watchAsync()];
|
2001 | case 10:
|
2002 | _a.sent();
|
2003 | return [3, 13];
|
2004 | case 11: return [4, new LibraryPackageBuilder_1.LibraryPackageBuilder(config).watchAsync()];
|
2005 | case 12:
|
2006 | _a.sent();
|
2007 | _a.label = 13;
|
2008 | case 13: return [2];
|
2009 | }
|
2010 | });
|
2011 | }); };
|
2012 | _loadersPath = function () {
|
2013 | var args = [];
|
2014 | for (var _i = 0; _i < arguments.length; _i++) {
|
2015 | args[_i] = arguments[_i];
|
2016 | }
|
2017 | return fs.existsSync(path.resolve(process.cwd(), "node_modules/@simplism/cli/loaders"))
|
2018 | ? path.resolve.apply(path, [process.cwd(), "node_modules/@simplism/cli/loaders"].concat(args)) : path.resolve.apply(path, [__dirname, "../../loaders"].concat(args));
|
2019 | };
|
2020 | lintAsync = function (packName) { return __awaiter(_this, void 0, void 0, function () {
|
2021 | var logger, worker;
|
2022 | return __generator(this, function (_a) {
|
2023 | switch (_a.label) {
|
2024 | case 0:
|
2025 | logger = new core_1.Logger("@simplism/cli", packName + "(LINT):");
|
2026 | logger.log("코드검사...");
|
2027 | return [4, new Promise(function (resolve, reject) {
|
2028 | worker = child_process.fork(_loadersPath("ts-lint-worker.js"), [
|
2029 | packName,
|
2030 | argv.watch ? "watch" : "build",
|
2031 | path.resolve(process.cwd(), "packages", packName, "tsconfig.json")
|
2032 | ].filterExists(), {
|
2033 | stdio: [undefined, undefined, undefined, "ipc"]
|
2034 | });
|
2035 | worker.on("message", function (message) {
|
2036 | if (message === "finish") {
|
2037 | logger.info("코드검사 완료");
|
2038 | resolve();
|
2039 | }
|
2040 | else {
|
2041 | logger.warn("코드검사 경고 발생", message);
|
2042 | }
|
2043 | });
|
2044 | worker.send([], function (err) {
|
2045 | if (err) {
|
2046 | reject(err);
|
2047 | }
|
2048 | });
|
2049 | })];
|
2050 | case 1:
|
2051 | _a.sent();
|
2052 | if (!argv.watch) return [3, 3];
|
2053 | return [4, FileWatcher_1.FileWatcher.watch(path.resolve(process.cwd(), "packages", packName, "src/**/*.ts"), ["add", "change"], function (files) {
|
2054 | try {
|
2055 | worker.send(files.map(function (item) { return item.filePath; }));
|
2056 | }
|
2057 | catch (err) {
|
2058 | logger.error(err);
|
2059 | }
|
2060 | })];
|
2061 | case 2:
|
2062 | _a.sent();
|
2063 | _a.label = 3;
|
2064 | case 3: return [2];
|
2065 | }
|
2066 | });
|
2067 | }); };
|
2068 | if (!argv.watch) {
|
2069 | rootPackageJsonPath = path.resolve(process.cwd(), "package.json");
|
2070 | rootPackageJson = fs.readJsonSync(rootPackageJsonPath);
|
2071 | rootPackageJson.version = semver.inc(rootPackageJson.version, "patch");
|
2072 | for (_b = 0, _c = projectConfig.packages; _b < _c.length; _b++) {
|
2073 | pack = _c[_b];
|
2074 | packageJsonPath = path.resolve(process.cwd(), "packages/" + pack.name, "package.json");
|
2075 | packageJson = fs.readJsonSync(packageJsonPath);
|
2076 | packageJson.version = rootPackageJson.version;
|
2077 | packageJson.repository = rootPackageJson.repository;
|
2078 | depTypeNames = ["dependencies", "peerDependencies", "optionalDependencies"];
|
2079 | for (_d = 0, depTypeNames_1 = depTypeNames; _d < depTypeNames_1.length; _d++) {
|
2080 | depTypeName = depTypeNames_1[_d];
|
2081 | for (_e = 0, _f = Object.keys(packageJson[depTypeName] || {}); _e < _f.length; _e++) {
|
2082 | depName = _f[_e];
|
2083 | if (depName.startsWith("@" + rootPackageJson.name)) {
|
2084 | packageJson[depTypeName][depName] = "~" + rootPackageJson.version;
|
2085 | }
|
2086 | else if (__assign({}, rootPackageJson.dependencies, rootPackageJson.devDependencies)[depName]) {
|
2087 | packageJson[depTypeName][depName] = __assign({}, rootPackageJson.dependencies, rootPackageJson.devDependencies)[depName];
|
2088 | }
|
2089 | else {
|
2090 | throw new Error("'" + pack.name + "'\uD328\uD0A4\uC9C0\uC758 \uC758\uC874\uC131 \uD328\uD0A4\uC9C0\uC778 \"" + depName + "\" \uC815\uBCF4\uAC00 \uB8E8\uD2B8 \uD328\uD0A4\uC9C0\uC5D0 \uC5C6\uC2B5\uB2C8\uB2E4.");
|
2091 | }
|
2092 | }
|
2093 | }
|
2094 | fs.writeJsonSync(rootPackageJsonPath, rootPackageJson, { spaces: 2, EOL: os.EOL });
|
2095 | fs.writeJsonSync(packageJsonPath, packageJson, { spaces: 2, EOL: os.EOL });
|
2096 | }
|
2097 | }
|
2098 | if (!argv.package) {
|
2099 | for (_g = 0, _h = projectConfig.packages; _g < _h.length; _g++) {
|
2100 | pack = _h[_g];
|
2101 | promiseList.push(lintAsync(pack.name));
|
2102 | }
|
2103 | }
|
2104 | else {
|
2105 | for (_j = 0, _k = argv.package.split(","); _j < _k.length; _j++) {
|
2106 | packName = _k[_j];
|
2107 | promiseList.push(lintAsync(packName));
|
2108 | }
|
2109 | }
|
2110 | if (!argv.package) {
|
2111 | packageConfigs_1 = (argv.package
|
2112 | ? projectConfig.packages.filter(function (item) { return argv.package.split(",").includes(item.name); })
|
2113 | : projectConfig.packages)
|
2114 | .map(function (pack) { return (__assign({}, pack, { config: fs.readJsonSync(path.resolve(process.cwd(), "packages", pack.name, "package.json")) })); });
|
2115 | completedPackNames_1 = [];
|
2116 | _loop_1 = function (pack) {
|
2117 | promiseList.push(new Promise(function (resolve, reject) { return __awaiter(_this, void 0, void 0, function () {
|
2118 | var thisPackageConfig, thisPackageDependencies_1, depPackNames_1, err_1;
|
2119 | return __generator(this, function (_a) {
|
2120 | switch (_a.label) {
|
2121 | case 0:
|
2122 | _a.trys.push([0, 4, , 5]);
|
2123 | thisPackageConfig = packageConfigs_1.single(function (item) { return item.name === pack.name; });
|
2124 | thisPackageDependencies_1 = __assign({}, thisPackageConfig.config.peerDependencies, thisPackageConfig.config.dependencies);
|
2125 | if (!thisPackageDependencies_1) return [3, 2];
|
2126 | depPackNames_1 = packageConfigs_1
|
2127 | .filter(function (otherPackageConfig) { return Object.keys(thisPackageDependencies_1).some(function (depKey) { return otherPackageConfig.config.name === depKey; }); })
|
2128 | .map(function (item) { return item.name; });
|
2129 | return [4, core_1.Wait.true(function () { return depPackNames_1.every(function (depPackName) { return completedPackNames_1.includes(depPackName); }); })];
|
2130 | case 1:
|
2131 | _a.sent();
|
2132 | _a.label = 2;
|
2133 | case 2: return [4, runAsync(pack)];
|
2134 | case 3:
|
2135 | _a.sent();
|
2136 | completedPackNames_1.push(pack.name);
|
2137 | resolve();
|
2138 | return [3, 5];
|
2139 | case 4:
|
2140 | err_1 = _a.sent();
|
2141 | reject(err_1);
|
2142 | return [3, 5];
|
2143 | case 5: return [2];
|
2144 | }
|
2145 | });
|
2146 | }); }));
|
2147 | };
|
2148 | for (_l = 0, _m = argv.package ? argv.package.split(",").map(function (item) { return packageConfigs_1.single(function (item1) { return item1.name === item; }); }) : projectConfig.packages; _l < _m.length; _l++) {
|
2149 | pack = _m[_l];
|
2150 | _loop_1(pack);
|
2151 | }
|
2152 | }
|
2153 | else {
|
2154 | _loop_2 = function (packName) {
|
2155 | promiseList.push(runAsync(projectConfig.packages.single(function (item) { return item.name === packName; })));
|
2156 | };
|
2157 | for (_o = 0, _p = argv.package.split(","); _o < _p.length; _o++) {
|
2158 | packName = _p[_o];
|
2159 | _loop_2(packName);
|
2160 | }
|
2161 | }
|
2162 | return [4, Promise.all(promiseList)];
|
2163 | case 2:
|
2164 | _q.sent();
|
2165 | return [2];
|
2166 | }
|
2167 | });
|
2168 | });
|
2169 | }
|
2170 | exports.buildAsync = buildAsync;
|
2171 |
|
2172 | }.call(this, "packages\\cli\\src\\commands"))
|
2173 |
|
2174 | }),
|
2175 |
|
2176 | (function(module, exports) {
|
2177 |
|
2178 | module.exports = require("chokidar");
|
2179 |
|
2180 | }),
|
2181 |
|
2182 | (function(module, exports) {
|
2183 |
|
2184 | module.exports = require("webpack-node-externals");
|
2185 |
|
2186 | }),
|
2187 |
|
2188 | (function(module, exports) {
|
2189 |
|
2190 | module.exports = require("html-webpack-plugin");
|
2191 |
|
2192 | }),
|
2193 |
|
2194 | (function(module, exports) {
|
2195 |
|
2196 | module.exports = require("webpack-dev-server");
|
2197 |
|
2198 | }),
|
2199 |
|
2200 | (function(module, exports) {
|
2201 |
|
2202 | module.exports = require("semver");
|
2203 |
|
2204 | }),
|
2205 |
|
2206 | (function(module, exports, __webpack_require__) {
|
2207 |
|
2208 | "use strict";
|
2209 |
|
2210 | var __assign = (this && this.__assign) || function () {
|
2211 | __assign = Object.assign || function(t) {
|
2212 | for (var s, i = 1, n = arguments.length; i < n; i++) {
|
2213 | s = arguments[i];
|
2214 | for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
|
2215 | t[p] = s[p];
|
2216 | }
|
2217 | return t;
|
2218 | };
|
2219 | return __assign.apply(this, arguments);
|
2220 | };
|
2221 | var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
2222 | return new (P || (P = Promise))(function (resolve, reject) {
|
2223 | function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
2224 | function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
2225 | function step(result) { result.done ? resolve(result.value) : new P(function (resolve) { resolve(result.value); }).then(fulfilled, rejected); }
|
2226 | step((generator = generator.apply(thisArg, _arguments || [])).next());
|
2227 | });
|
2228 | };
|
2229 | var __generator = (this && this.__generator) || function (thisArg, body) {
|
2230 | var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
|
2231 | return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
2232 | function verb(n) { return function (v) { return step([n, v]); }; }
|
2233 | function step(op) {
|
2234 | if (f) throw new TypeError("Generator is already executing.");
|
2235 | while (_) try {
|
2236 | if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
|
2237 | if (y = 0, t) op = [op[0] & 2, t.value];
|
2238 | switch (op[0]) {
|
2239 | case 0: case 1: t = op; break;
|
2240 | case 4: _.label++; return { value: op[1], done: false };
|
2241 | case 5: _.label++; y = op[1]; op = [0]; continue;
|
2242 | case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
2243 | default:
|
2244 | if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
2245 | if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
2246 | if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
2247 | if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
2248 | if (t[2]) _.ops.pop();
|
2249 | _.trys.pop(); continue;
|
2250 | }
|
2251 | op = body.call(thisArg, _);
|
2252 | } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
2253 | if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
2254 | }
|
2255 | };
|
2256 | Object.defineProperty(exports, "__esModule", { value: true });
|
2257 | var fs = __webpack_require__(0);
|
2258 | var path = __webpack_require__(1);
|
2259 | var LibraryPackageBuilder_1 = __webpack_require__(12);
|
2260 | var ServerPackageBuilder_1 = __webpack_require__(13);
|
2261 | var ClientPackageBuilder_1 = __webpack_require__(16);
|
2262 | function publishAsync(argv) {
|
2263 | return __awaiter(this, void 0, Promise, function () {
|
2264 | var configFilePath, projectConfig, promiseList, _i, _a, config, _b, _c, config;
|
2265 | return __generator(this, function (_d) {
|
2266 | switch (_d.label) {
|
2267 | case 0:
|
2268 | process.env.NODE_ENV = "production";
|
2269 | configFilePath = argv.config;
|
2270 | configFilePath = configFilePath ? path.resolve(process.cwd(), configFilePath)
|
2271 | : fs.existsSync(path.resolve(process.cwd(), "simplism.ts")) ? path.resolve(process.cwd(), "simplism.ts")
|
2272 | : fs.existsSync(path.resolve(process.cwd(), "simplism.js")) ? path.resolve(process.cwd(), "simplism.js")
|
2273 | : path.resolve(process.cwd(), "simplism.json");
|
2274 | if (path.extname(configFilePath) === ".ts") {
|
2275 | __webpack_require__(4);
|
2276 | Object.assign(process.env, argv.env);
|
2277 | }
|
2278 | projectConfig = eval("require(configFilePath)");
|
2279 | promiseList = [];
|
2280 | for (_i = 0, _a = projectConfig.packages.filter(function (item) { return item.type === "library" && item.publish !== false; }); _i < _a.length; _i++) {
|
2281 | config = _a[_i];
|
2282 | if (!argv.package || argv.package.split(",").includes(config.name)) {
|
2283 | promiseList.push(new LibraryPackageBuilder_1.LibraryPackageBuilder(config).publishAsync());
|
2284 | }
|
2285 | }
|
2286 | return [4, Promise.all(promiseList)];
|
2287 | case 1:
|
2288 | _d.sent();
|
2289 | _b = 0, _c = projectConfig.packages.filter(function (item) { return item.type !== "library" && item.publish !== undefined && item.publish !== false; });
|
2290 | _d.label = 2;
|
2291 | case 2:
|
2292 | if (!(_b < _c.length)) return [3, 8];
|
2293 | config = _c[_b];
|
2294 | if (!(config.type === "library")) return [3, 3];
|
2295 | return [3, 7];
|
2296 | case 3:
|
2297 | if (!(!argv.package || argv.package.split(",").includes(config.name))) return [3, 7];
|
2298 | if (!(config.type === "server")) return [3, 5];
|
2299 | return [4, new ServerPackageBuilder_1.ServerPackageBuilder(__assign({}, config, { "env": __assign({}, projectConfig.env, config.env, argv.env), "env.production": __assign({}, projectConfig["env.production"], config["env.production"]) })).publishAsync()];
|
2300 | case 4:
|
2301 | _d.sent();
|
2302 | return [3, 7];
|
2303 | case 5: return [4, new ClientPackageBuilder_1.ClientPackageBuilder(__assign({}, config, { "env": __assign({}, projectConfig.env, config.env, argv.env), "env.production": __assign({}, projectConfig["env.production"], config["env.production"]) })).publishAsync()];
|
2304 | case 6:
|
2305 | _d.sent();
|
2306 | _d.label = 7;
|
2307 | case 7:
|
2308 | _b++;
|
2309 | return [3, 2];
|
2310 | case 8: return [2];
|
2311 | }
|
2312 | });
|
2313 | });
|
2314 | }
|
2315 | exports.publishAsync = publishAsync;
|
2316 |
|
2317 |
|
2318 | }),
|
2319 |
|
2320 | (function(module, exports, __webpack_require__) {
|
2321 |
|
2322 | "use strict";
|
2323 |
|
2324 | var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
2325 | return new (P || (P = Promise))(function (resolve, reject) {
|
2326 | function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
2327 | function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
2328 | function step(result) { result.done ? resolve(result.value) : new P(function (resolve) { resolve(result.value); }).then(fulfilled, rejected); }
|
2329 | step((generator = generator.apply(thisArg, _arguments || [])).next());
|
2330 | });
|
2331 | };
|
2332 | var __generator = (this && this.__generator) || function (thisArg, body) {
|
2333 | var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
|
2334 | return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
2335 | function verb(n) { return function (v) { return step([n, v]); }; }
|
2336 | function step(op) {
|
2337 | if (f) throw new TypeError("Generator is already executing.");
|
2338 | while (_) try {
|
2339 | if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
|
2340 | if (y = 0, t) op = [op[0] & 2, t.value];
|
2341 | switch (op[0]) {
|
2342 | case 0: case 1: t = op; break;
|
2343 | case 4: _.label++; return { value: op[1], done: false };
|
2344 | case 5: _.label++; y = op[1]; op = [0]; continue;
|
2345 | case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
2346 | default:
|
2347 | if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
2348 | if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
2349 | if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
2350 | if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
2351 | if (t[2]) _.ops.pop();
|
2352 | _.trys.pop(); continue;
|
2353 | }
|
2354 | op = body.call(thisArg, _);
|
2355 | } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
2356 | if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
2357 | }
|
2358 | };
|
2359 | Object.defineProperty(exports, "__esModule", { value: true });
|
2360 | var fs = __webpack_require__(0);
|
2361 | var path = __webpack_require__(1);
|
2362 | var LocalUpdater_1 = __webpack_require__(10);
|
2363 | function localUpdateAsync(argv) {
|
2364 | return __awaiter(this, void 0, Promise, function () {
|
2365 | var configFilePath, projectConfig, promiseList, _i, _a, packageName, packagePath;
|
2366 | return __generator(this, function (_b) {
|
2367 | switch (_b.label) {
|
2368 | case 0:
|
2369 | process.env.NODE_ENV = "development";
|
2370 | configFilePath = argv.config;
|
2371 | configFilePath = configFilePath ? path.resolve(process.cwd(), configFilePath)
|
2372 | : fs.existsSync(path.resolve(process.cwd(), "simplism.ts")) ? path.resolve(process.cwd(), "simplism.ts")
|
2373 | : fs.existsSync(path.resolve(process.cwd(), "simplism.js")) ? path.resolve(process.cwd(), "simplism.js")
|
2374 | : path.resolve(process.cwd(), "simplism.json");
|
2375 | if (path.extname(configFilePath) === ".ts") {
|
2376 | __webpack_require__(4);
|
2377 | }
|
2378 | projectConfig = eval("require(configFilePath)");
|
2379 | promiseList = [];
|
2380 | if (projectConfig.localDependencies) {
|
2381 | for (_i = 0, _a = Object.keys(projectConfig.localDependencies); _i < _a.length; _i++) {
|
2382 | packageName = _a[_i];
|
2383 | packagePath = projectConfig.localDependencies[packageName];
|
2384 | if (fs.existsSync(packagePath)) {
|
2385 | promiseList.push(new LocalUpdater_1.LocalUpdater(packageName, packagePath).runAsync());
|
2386 | if (argv.watch) {
|
2387 | promiseList.push(new LocalUpdater_1.LocalUpdater(packageName, packagePath).runAsync(true));
|
2388 | }
|
2389 | }
|
2390 | }
|
2391 | }
|
2392 | return [4, Promise.all(promiseList)];
|
2393 | case 1:
|
2394 | _b.sent();
|
2395 | return [2];
|
2396 | }
|
2397 | });
|
2398 | });
|
2399 | }
|
2400 | exports.localUpdateAsync = localUpdateAsync;
|
2401 |
|
2402 |
|
2403 | }),
|
2404 |
|
2405 | (function(module, exports) {
|
2406 |
|
2407 | module.exports = require("events");
|
2408 |
|
2409 | }),
|
2410 |
|
2411 | (function(module, exports, __webpack_require__) {
|
2412 |
|
2413 | "use strict";
|
2414 |
|
2415 | var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
2416 | return new (P || (P = Promise))(function (resolve, reject) {
|
2417 | function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
2418 | function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
2419 | function step(result) { result.done ? resolve(result.value) : new P(function (resolve) { resolve(result.value); }).then(fulfilled, rejected); }
|
2420 | step((generator = generator.apply(thisArg, _arguments || [])).next());
|
2421 | });
|
2422 | };
|
2423 | var __generator = (this && this.__generator) || function (thisArg, body) {
|
2424 | var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
|
2425 | return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
2426 | function verb(n) { return function (v) { return step([n, v]); }; }
|
2427 | function step(op) {
|
2428 | if (f) throw new TypeError("Generator is already executing.");
|
2429 | while (_) try {
|
2430 | if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
|
2431 | if (y = 0, t) op = [op[0] & 2, t.value];
|
2432 | switch (op[0]) {
|
2433 | case 0: case 1: t = op; break;
|
2434 | case 4: _.label++; return { value: op[1], done: false };
|
2435 | case 5: _.label++; y = op[1]; op = [0]; continue;
|
2436 | case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
2437 | default:
|
2438 | if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
2439 | if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
2440 | if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
2441 | if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
2442 | if (t[2]) _.ops.pop();
|
2443 | _.trys.pop(); continue;
|
2444 | }
|
2445 | op = body.call(thisArg, _);
|
2446 | } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
2447 | if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
2448 | }
|
2449 | };
|
2450 | Object.defineProperty(exports, "__esModule", { value: true });
|
2451 | var path = __webpack_require__(1);
|
2452 | var glob = __webpack_require__(9);
|
2453 | var fs = __webpack_require__(0);
|
2454 | var iconv = __webpack_require__(30);
|
2455 | var child_process_1 = __webpack_require__(3);
|
2456 | function keygenAsync(argv) {
|
2457 | return __awaiter(this, void 0, Promise, function () {
|
2458 | var keytoolPaths, keytoolPath, cmd;
|
2459 | return __generator(this, function (_a) {
|
2460 | switch (_a.label) {
|
2461 | case 0:
|
2462 | keytoolPaths = glob.sync(path.resolve("c:", "Program Files", "Java", "jdk*", "bin", "keytool.exe"));
|
2463 | keytoolPath = keytoolPaths.last();
|
2464 | if (fs.existsSync(path.resolve(process.cwd(), ".sign", argv.alias, "release-signing.jks"))) {
|
2465 | throw new Error("키쌍이 이미 존재합니다.");
|
2466 | }
|
2467 | fs.mkdirsSync(path.resolve(process.cwd(), ".sign", argv.alias));
|
2468 | cmd = child_process_1.spawn("\"" + keytoolPath + "\"", [
|
2469 | "-genkey", "-noprompt",
|
2470 | "-alias", argv.alias,
|
2471 | "-dname", "CN=",
|
2472 | "-keyalg", "RSA",
|
2473 | "-keysize", "2048",
|
2474 | "-validity", "10000",
|
2475 | "-keystore", "release-signing.jks",
|
2476 | "-storepass", argv.password,
|
2477 | "-keypass", argv.password
|
2478 | ], {
|
2479 | shell: true,
|
2480 | cwd: path.resolve(process.cwd(), ".sign", argv.alias)
|
2481 | });
|
2482 | return [4, new Promise(function (resolve, reject) {
|
2483 | var errorMessage = "";
|
2484 | cmd.stdout.on("data", function (data) {
|
2485 | errorMessage += iconv.decode(data, "euc-kr");
|
2486 | });
|
2487 | cmd.stderr.on("data", function (data) {
|
2488 | var str = iconv.decode(data, "euc-kr");
|
2489 | if (!str.includes("PKCS12") && !str.includes("Warning")) {
|
2490 | console.log(str);
|
2491 | }
|
2492 | });
|
2493 | cmd.on("exit", function (code) {
|
2494 | if (code !== 0) {
|
2495 | reject(new Error(errorMessage));
|
2496 | }
|
2497 | resolve();
|
2498 | });
|
2499 | })];
|
2500 | case 1:
|
2501 | _a.sent();
|
2502 | fs.writeFileSync(path.resolve(process.cwd(), ".sign", argv.alias, "release-signing.properties"), "key.store=release-signing.jks" + "\n" +
|
2503 | "key.store.password=" + argv.password + "\n" +
|
2504 | "key.alias=" + argv.alias + "\n" +
|
2505 | "key.alias.password=" + argv.password);
|
2506 | return [2];
|
2507 | }
|
2508 | });
|
2509 | });
|
2510 | }
|
2511 | exports.keygenAsync = keygenAsync;
|
2512 |
|
2513 |
|
2514 | }),
|
2515 |
|
2516 | (function(module, exports) {
|
2517 |
|
2518 | module.exports = require("iconv-lite");
|
2519 |
|
2520 | }),
|
2521 |
|
2522 | (function(module, exports, __webpack_require__) {
|
2523 |
|
2524 | "use strict";
|
2525 |
|
2526 | var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
2527 | return new (P || (P = Promise))(function (resolve, reject) {
|
2528 | function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
2529 | function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
2530 | function step(result) { result.done ? resolve(result.value) : new P(function (resolve) { resolve(result.value); }).then(fulfilled, rejected); }
|
2531 | step((generator = generator.apply(thisArg, _arguments || [])).next());
|
2532 | });
|
2533 | };
|
2534 | var __generator = (this && this.__generator) || function (thisArg, body) {
|
2535 | var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
|
2536 | return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
2537 | function verb(n) { return function (v) { return step([n, v]); }; }
|
2538 | function step(op) {
|
2539 | if (f) throw new TypeError("Generator is already executing.");
|
2540 | while (_) try {
|
2541 | if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
|
2542 | if (y = 0, t) op = [op[0] & 2, t.value];
|
2543 | switch (op[0]) {
|
2544 | case 0: case 1: t = op; break;
|
2545 | case 4: _.label++; return { value: op[1], done: false };
|
2546 | case 5: _.label++; y = op[1]; op = [0]; continue;
|
2547 | case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
2548 | default:
|
2549 | if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
2550 | if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
2551 | if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
2552 | if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
2553 | if (t[2]) _.ops.pop();
|
2554 | _.trys.pop(); continue;
|
2555 | }
|
2556 | op = body.call(thisArg, _);
|
2557 | } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
2558 | if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
2559 | }
|
2560 | };
|
2561 | Object.defineProperty(exports, "__esModule", { value: true });
|
2562 | var path = __webpack_require__(1);
|
2563 | var fs = __webpack_require__(0);
|
2564 | var childProcess = __webpack_require__(3);
|
2565 | var CliHelper_1 = __webpack_require__(32);
|
2566 | function runDeviceAsync(argv) {
|
2567 | return __awaiter(this, void 0, Promise, function () {
|
2568 | var configFilePath, projectConfig, config, cordovaProjectPath, configFileContent, cordovaBinPath, host, devServerUrl, cordovaProjectPath, configFileContent;
|
2569 | return __generator(this, function (_a) {
|
2570 | process.env.NODE_ENV = "development";
|
2571 | configFilePath = argv.config;
|
2572 | configFilePath = configFilePath ? path.resolve(process.cwd(), configFilePath)
|
2573 | : fs.existsSync(path.resolve(process.cwd(), "simplism.ts")) ? path.resolve(process.cwd(), "simplism.ts")
|
2574 | : fs.existsSync(path.resolve(process.cwd(), "simplism.js")) ? path.resolve(process.cwd(), "simplism.js")
|
2575 | : path.resolve(process.cwd(), "simplism.json");
|
2576 | if (path.extname(configFilePath) === ".ts") {
|
2577 | __webpack_require__(4);
|
2578 | }
|
2579 | projectConfig = eval("require(configFilePath)");
|
2580 | config = projectConfig.packages.single(function (item) { return item.name === argv.package; });
|
2581 | if (!config || !config.cordova || !config.platforms || !config.platforms.includes("android") || !config.devServer) {
|
2582 | throw new Error("클라이언트 설정이 잘못되었습니다. [패키지: " + argv.package + "]");
|
2583 | }
|
2584 | if (argv.release || argv.debug) {
|
2585 | cordovaProjectPath = path.resolve(process.cwd(), "packages", argv.package, ".cordova");
|
2586 | if (argv.release && config.cordova.sign) {
|
2587 | fs.copySync(path.resolve(process.cwd(), ".sign", config.cordova.sign, "release-signing.jks"), path.resolve(cordovaProjectPath, "platforms", "android", "release-signing.jks"));
|
2588 | fs.copySync(path.resolve(process.cwd(), ".sign", config.cordova.sign, "release-signing.properties"), path.resolve(cordovaProjectPath, "platforms", "android", "release-signing.properties"));
|
2589 | }
|
2590 | configFileContent = fs.readFileSync(path.resolve(cordovaProjectPath, "config.xml"), "utf-8");
|
2591 | configFileContent = configFileContent.replace(/<allow-navigation href="[^"]"\s?\/>/g, "");
|
2592 | fs.writeFileSync(path.resolve(cordovaProjectPath, "config.xml"), configFileContent, "utf-8");
|
2593 | cordovaBinPath = path.resolve(process.cwd(), "node_modules", ".bin", "cordova.cmd");
|
2594 | childProcess.spawnSync(cordovaBinPath, [
|
2595 | "run",
|
2596 | "android",
|
2597 | "--device",
|
2598 | argv.release ? "--release" : ""
|
2599 | ], {
|
2600 | shell: true,
|
2601 | stdio: "inherit",
|
2602 | cwd: cordovaProjectPath
|
2603 | });
|
2604 | }
|
2605 | else {
|
2606 | host = CliHelper_1.CliHelper.getCurrentIP(config.devServer.host);
|
2607 | devServerUrl = "http://" + host + ":" + config.devServer.port;
|
2608 | cordovaProjectPath = path.resolve(process.cwd(), "packages", argv.package, ".cordova");
|
2609 | fs.removeSync(path.resolve(cordovaProjectPath, "www"));
|
2610 | fs.mkdirsSync(path.resolve(cordovaProjectPath, "www"));
|
2611 | fs.writeFileSync(path.resolve(cordovaProjectPath, "www/index.html"), ("'" + devServerUrl + "'\uB85C \uC774\uB3D9\uC911... <script>window.location.href = \"" + devServerUrl + "\";</script>").trim(), "utf-8");
|
2612 | configFileContent = fs.readFileSync(path.resolve(cordovaProjectPath, "config.xml"), "utf-8");
|
2613 | if (!new RegExp("<allow-navigation href=\"" + devServerUrl + "(/\\*)?\"\\s?/>").test(configFileContent)) {
|
2614 | configFileContent = configFileContent.replace("</widget>", "<allow-navigation href=\"" + devServerUrl + "\" /></widget>");
|
2615 | configFileContent = configFileContent.replace("</widget>", "<allow-navigation href=\"" + devServerUrl + "/*\" /></widget>");
|
2616 | fs.writeFileSync(path.resolve(cordovaProjectPath, "config.xml"), configFileContent, "utf-8");
|
2617 | }
|
2618 | childProcess.spawnSync("cordova", ["run", "android", "--device"], {
|
2619 | stdio: "inherit",
|
2620 | shell: true,
|
2621 | cwd: cordovaProjectPath
|
2622 | });
|
2623 | }
|
2624 | return [2];
|
2625 | });
|
2626 | });
|
2627 | }
|
2628 | exports.runDeviceAsync = runDeviceAsync;
|
2629 |
|
2630 |
|
2631 | }),
|
2632 |
|
2633 | (function(module, exports, __webpack_require__) {
|
2634 |
|
2635 | "use strict";
|
2636 |
|
2637 | Object.defineProperty(exports, "__esModule", { value: true });
|
2638 | var os = __webpack_require__(17);
|
2639 | var core_1 = __webpack_require__(2);
|
2640 | var CliHelper = (function () {
|
2641 | function CliHelper() {
|
2642 | }
|
2643 | CliHelper.getCurrentIP = function (hostOrHosts) {
|
2644 | var selectors = hostOrHosts
|
2645 | ? typeof hostOrHosts === "string"
|
2646 | ? [hostOrHosts]
|
2647 | : hostOrHosts
|
2648 | : [undefined];
|
2649 | var _loop_1 = function (selector) {
|
2650 | if (selector && !selector.includes(".")) {
|
2651 | return { value: selector };
|
2652 | }
|
2653 | var ipRegExpString = selector
|
2654 | ? selector.replace(/\./g, "\\.").replace(/\*/g, "[0-9]*")
|
2655 | : ".*";
|
2656 | var ifaces = os.networkInterfaces();
|
2657 | var result = Object.keys(ifaces)
|
2658 | .map(function (key) { return ifaces[key].filter(function (item) { return item.family === "IPv4" && !item.internal; }); })
|
2659 | .filter(function (item) { return item.length > 0; }).mapMany(function (item) { return item.map(function (item1) { return item1.address; }); })
|
2660 | .filter(function (addr) { return new RegExp(ipRegExpString).test(addr); });
|
2661 | if (result.length < 1) {
|
2662 | return "continue";
|
2663 | }
|
2664 | if (result.length > 1) {
|
2665 | new core_1.Logger("@simplism/cli", "CliHelper: ").warn("IP " + result.join(", ") + "\uC911 " + result[0] + "\uC774 \uC120\uD0DD\uB418\uC5C8\uC2B5\uB2C8\uB2E4.");
|
2666 | }
|
2667 | return { value: result[0] };
|
2668 | };
|
2669 | for (var _i = 0, selectors_1 = selectors; _i < selectors_1.length; _i++) {
|
2670 | var selector = selectors_1[_i];
|
2671 | var state_1 = _loop_1(selector);
|
2672 | if (typeof state_1 === "object")
|
2673 | return state_1.value;
|
2674 | }
|
2675 | throw new Error("\"" + selectors.join("\", \"") + "\"\uC640 \uB9E4\uCE6D\uB418\uB294 \uC544\uC774\uD53C \uC8FC\uC18C\uB97C \uCC3E\uC744 \uC218 \uC5C6\uC2B5\uB2C8\uB2E4.");
|
2676 | };
|
2677 | return CliHelper;
|
2678 | }());
|
2679 | exports.CliHelper = CliHelper;
|
2680 |
|
2681 |
|
2682 | }),
|
2683 |
|
2684 | (function(module, exports) {
|
2685 |
|
2686 | module.exports = require("source-map-support");
|
2687 |
|
2688 | })
|
2689 | ]);
|
2690 | });
|
2691 |
|
\ | No newline at end of file |