sugar-scripts 0.2.0-beta.0 → 1.0.0-beta.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (90) hide show
  1. package/lib/bin/cli-ts.d.ts +1 -0
  2. package/lib/bin/cli-ts.js +4 -0
  3. package/lib/bin/cli-ts.js.map +1 -0
  4. package/lib/bin/cli.d.ts +1 -0
  5. package/lib/bin/cli.js +4 -0
  6. package/lib/bin/cli.js.map +1 -0
  7. package/lib/commander/index.d.ts +1 -0
  8. package/lib/commander/index.js +79 -0
  9. package/lib/commander/index.js.map +1 -0
  10. package/lib/constants/index.d.ts +4 -0
  11. package/lib/constants/index.js +8 -0
  12. package/lib/constants/index.js.map +1 -0
  13. package/lib/core/build.d.ts +2 -0
  14. package/lib/core/build.js +74 -0
  15. package/lib/core/build.js.map +1 -0
  16. package/lib/core/cache.d.ts +2 -0
  17. package/lib/core/cache.js +9 -0
  18. package/lib/core/cache.js.map +1 -0
  19. package/lib/core/info.d.ts +1 -0
  20. package/lib/core/info.js +6 -0
  21. package/lib/core/info.js.map +1 -0
  22. package/lib/core/init-running-context.d.ts +2 -0
  23. package/lib/core/init-running-context.js +30 -0
  24. package/lib/core/init-running-context.js.map +1 -0
  25. package/lib/core/run-application.d.ts +2 -0
  26. package/lib/core/run-application.js +9 -0
  27. package/lib/core/run-application.js.map +1 -0
  28. package/lib/core/running-context.d.ts +23 -0
  29. package/lib/core/running-context.js +52 -0
  30. package/lib/core/running-context.js.map +1 -0
  31. package/lib/custom-config.type.d.ts +51 -0
  32. package/lib/custom-config.type.js +8 -0
  33. package/lib/custom-config.type.js.map +1 -0
  34. package/lib/index.d.ts +1 -0
  35. package/lib/index.js +6 -0
  36. package/lib/index.js.map +1 -0
  37. package/lib/shared/file-helpers.d.ts +18 -0
  38. package/lib/shared/file-helpers.js +227 -0
  39. package/lib/shared/file-helpers.js.map +1 -0
  40. package/lib/webpack/dll-dependencies-manifest-plugin.d.ts +15 -0
  41. package/lib/webpack/dll-dependencies-manifest-plugin.js +79 -0
  42. package/lib/webpack/dll-dependencies-manifest-plugin.js.map +1 -0
  43. package/lib/webpack/load-manifest.d.ts +11 -0
  44. package/lib/webpack/load-manifest.js +47 -0
  45. package/lib/webpack/load-manifest.js.map +1 -0
  46. package/lib/webpack/run-webpack.d.ts +2 -0
  47. package/lib/webpack/run-webpack.js +23 -0
  48. package/lib/webpack/run-webpack.js.map +1 -0
  49. package/lib/webpack/server-browser-entry.d.ts +12 -0
  50. package/lib/webpack/server-browser-entry.js +41 -0
  51. package/lib/webpack/server-browser-entry.js.map +1 -0
  52. package/lib/webpack/webpack.browser.d.ts +4 -0
  53. package/lib/webpack/webpack.browser.js +88 -0
  54. package/lib/webpack/webpack.browser.js.map +1 -0
  55. package/lib/webpack/webpack.common.d.ts +7 -0
  56. package/lib/webpack/webpack.common.js +66 -0
  57. package/lib/webpack/webpack.common.js.map +1 -0
  58. package/lib/webpack/webpack.server.d.ts +4 -0
  59. package/lib/webpack/webpack.server.js +86 -0
  60. package/lib/webpack/webpack.server.js.map +1 -0
  61. package/package.json +17 -32
  62. package/src/bin/cli-ts.ts +3 -0
  63. package/src/index.ts +0 -3
  64. package/CHANGELOG.md +0 -26
  65. package/bin/cli-ts.js +0 -3
  66. package/bin/cli.js +0 -3
  67. package/src/app-utils/index.ts +0 -1
  68. package/src/app-utils/static.ts +0 -42
  69. package/src/commander/index.ts +0 -95
  70. package/src/configs/babel.server.config.ts +0 -42
  71. package/src/configs/babel.static.config.ts +0 -43
  72. package/src/constants/index.ts +0 -5
  73. package/src/core/build.ts +0 -98
  74. package/src/core/cache.ts +0 -15
  75. package/src/core/entry.ts +0 -189
  76. package/src/core/info.ts +0 -5
  77. package/src/core/init-running-context.ts +0 -27
  78. package/src/core/run-application.ts +0 -12
  79. package/src/core/running-context.ts +0 -92
  80. package/src/custom-config.type.ts +0 -66
  81. package/src/shared/file-helpers.ts +0 -192
  82. package/src/typings.d.ts +0 -8
  83. package/src/webpack/auto-entries.ts +0 -5
  84. package/src/webpack/dll-dependencies-manifest-plugin.ts +0 -115
  85. package/src/webpack/load-manifest.ts +0 -73
  86. package/src/webpack/run-webpack.ts +0 -22
  87. package/src/webpack/webpack.browser.ts +0 -107
  88. package/src/webpack/webpack.common.ts +0 -146
  89. package/src/webpack/webpack.server.ts +0 -100
  90. package/tsconfig.json +0 -25
@@ -0,0 +1 @@
1
+ #!/usr/bin/env ts-node
@@ -0,0 +1,4 @@
1
+ #!/usr/bin/env ts-node
2
+ "use strict";
3
+ require('../commander');
4
+ //# sourceMappingURL=cli-ts.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"cli-ts.js","sourceRoot":"","sources":["../../src/bin/cli-ts.ts"],"names":[],"mappings":";;AAEA,OAAO,CAAC,cAAc,CAAC,CAAC"}
@@ -0,0 +1 @@
1
+ #!/usr/bin/env node
package/lib/bin/cli.js ADDED
@@ -0,0 +1,4 @@
1
+ #!/usr/bin/env node
2
+ "use strict";
3
+ require('../commander');
4
+ //# sourceMappingURL=cli.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"cli.js","sourceRoot":"","sources":["../../src/bin/cli.ts"],"names":[],"mappings":";;AAEA,OAAO,CAAC,cAAc,CAAC,CAAC"}
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,79 @@
1
+ "use strict";
2
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
+ return new (P || (P = Promise))(function (resolve, reject) {
5
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
6
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
7
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
8
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
9
+ });
10
+ };
11
+ var __importDefault = (this && this.__importDefault) || function (mod) {
12
+ return (mod && mod.__esModule) ? mod : { "default": mod };
13
+ };
14
+ Object.defineProperty(exports, "__esModule", { value: true });
15
+ const path_1 = __importDefault(require("path"));
16
+ const chalk_1 = __importDefault(require("chalk"));
17
+ const commander_1 = require("commander");
18
+ const init_running_context_1 = require("../core/init-running-context");
19
+ const build_1 = require("../core/build");
20
+ const cache_1 = require("../core/cache");
21
+ const run_application_1 = require("../core/run-application");
22
+ const program = new commander_1.Command();
23
+ program
24
+ .version('1.0.0');
25
+ program
26
+ .command('info')
27
+ .description('工程信息')
28
+ .option('--dir <dir>', '自定义运行的目录')
29
+ .action((options, command) => __awaiter(void 0, void 0, void 0, function* () {
30
+ const cwd = process.cwd();
31
+ const dir = options.dir ? path_1.default.resolve(cwd, options.dir) : cwd;
32
+ // process.exit();
33
+ }));
34
+ program
35
+ .command('build')
36
+ .description('构建服务')
37
+ .option('--dir <dir>', '自定义运行的目录')
38
+ .action((options, command) => __awaiter(void 0, void 0, void 0, function* () {
39
+ const cwd = process.cwd();
40
+ const dir = options.dir ? path_1.default.resolve(cwd, options.dir) : cwd;
41
+ const context = yield (0, init_running_context_1.initRunningContext)(dir);
42
+ yield (0, build_1.build)(context);
43
+ console.log(`✅ ${chalk_1.default.bold.green('构建成功')}`);
44
+ }));
45
+ const cacheCommand = new commander_1.Command();
46
+ cacheCommand
47
+ .name('cache')
48
+ .description('构建缓存管理');
49
+ cacheCommand
50
+ .command('clean')
51
+ .description('清理构建缓存')
52
+ .option('--dir <dir>', '自定义运行的目录')
53
+ .action((options, command) => __awaiter(void 0, void 0, void 0, function* () {
54
+ const cwd = process.cwd();
55
+ const dir = options.dir ? path_1.default.resolve(cwd, options.dir) : cwd;
56
+ const context = yield (0, init_running_context_1.initRunningContext)(dir);
57
+ yield (0, cache_1.clean)(context);
58
+ console.log(`✅ ${chalk_1.default.bold.green('清理构建缓存成功')}`);
59
+ }));
60
+ program.addCommand(cacheCommand);
61
+ program
62
+ .command('start')
63
+ .description('启动开发服务')
64
+ .option('--dir <dir>', '自定义运行的目录')
65
+ .option('--port <port>', '指定运行的端口')
66
+ .action((options, command) => __awaiter(void 0, void 0, void 0, function* () {
67
+ const cwd = process.cwd();
68
+ const dir = options.dir ? path_1.default.resolve(cwd, options.dir) : cwd;
69
+ const port = +options.port;
70
+ const context = yield (0, init_running_context_1.initRunningContext)(dir);
71
+ const appFilePath = context.getStartFilePath();
72
+ if (!appFilePath)
73
+ return;
74
+ const App = require(appFilePath).default;
75
+ (0, run_application_1.runApplication)(App, port);
76
+ console.log(`✅ ${chalk_1.default.bold.green(`启动服务成功,端口:${port}`)}`);
77
+ }));
78
+ program.parse(process.argv);
79
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/commander/index.ts"],"names":[],"mappings":"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"}
@@ -0,0 +1,4 @@
1
+ export declare const SUGAR_PACKAGE_CONFIG_FILENAME = "sugar.package";
2
+ export declare const SUGAR_PROJECT_CONFIG_FILENAME = "sugar.project";
3
+ export declare const SUGAR_BUILD_EXPORT_BROWSER = "browserWebpackConfig";
4
+ export declare const SUGAR_BUILD_EXPORT_SERVER = "serverWebpackConfig";
@@ -0,0 +1,8 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.SUGAR_BUILD_EXPORT_SERVER = exports.SUGAR_BUILD_EXPORT_BROWSER = exports.SUGAR_PROJECT_CONFIG_FILENAME = exports.SUGAR_PACKAGE_CONFIG_FILENAME = void 0;
4
+ exports.SUGAR_PACKAGE_CONFIG_FILENAME = 'sugar.package';
5
+ exports.SUGAR_PROJECT_CONFIG_FILENAME = 'sugar.project';
6
+ exports.SUGAR_BUILD_EXPORT_BROWSER = 'browserWebpackConfig';
7
+ exports.SUGAR_BUILD_EXPORT_SERVER = 'serverWebpackConfig';
8
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/constants/index.ts"],"names":[],"mappings":";;;AAAa,QAAA,6BAA6B,GAAG,eAAe,CAAC;AAChD,QAAA,6BAA6B,GAAG,eAAe,CAAC;AAEhD,QAAA,0BAA0B,GAAG,sBAAsB,CAAC;AACpD,QAAA,yBAAyB,GAAG,qBAAqB,CAAC"}
@@ -0,0 +1,2 @@
1
+ import { SugarScriptsContext } from './running-context';
2
+ export declare const build: (context: SugarScriptsContext) => Promise<void>;
@@ -0,0 +1,74 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
15
+ }) : function(o, v) {
16
+ o["default"] = v;
17
+ });
18
+ var __importStar = (this && this.__importStar) || function (mod) {
19
+ if (mod && mod.__esModule) return mod;
20
+ var result = {};
21
+ if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
22
+ __setModuleDefault(result, mod);
23
+ return result;
24
+ };
25
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
26
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
27
+ return new (P || (P = Promise))(function (resolve, reject) {
28
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
29
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
30
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
31
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
32
+ });
33
+ };
34
+ var __importDefault = (this && this.__importDefault) || function (mod) {
35
+ return (mod && mod.__esModule) ? mod : { "default": mod };
36
+ };
37
+ Object.defineProperty(exports, "__esModule", { value: true });
38
+ exports.build = void 0;
39
+ const path_1 = __importDefault(require("path"));
40
+ const tsNode = __importStar(require("ts-node"));
41
+ const webpack_browser_1 = require("../webpack/webpack.browser");
42
+ const webpack_server_1 = require("../webpack/webpack.server");
43
+ const webpack_common_1 = require("../webpack/webpack.common");
44
+ const run_webpack_1 = require("../webpack/run-webpack");
45
+ const build = (context) => __awaiter(void 0, void 0, void 0, function* () {
46
+ tsNode.register({
47
+ cwd: context.root,
48
+ projectSearchDir: context.root,
49
+ project: path_1.default.resolve(context.root, './tsconfig.json'),
50
+ transpileOnly: true
51
+ });
52
+ yield buildServer(context);
53
+ yield buildBrowser(context);
54
+ });
55
+ exports.build = build;
56
+ const buildBrowser = (context) => __awaiter(void 0, void 0, void 0, function* () {
57
+ if (!context.packageConfig.browser)
58
+ return;
59
+ const browserConfig = context.packageConfig.browser;
60
+ const chainConfig = yield (0, webpack_common_1.createCommonChainConfig)(context, browserConfig.output);
61
+ yield (0, webpack_browser_1.mergeBrowserEntry)(context, chainConfig);
62
+ yield (0, webpack_browser_1.mergeBrowserCustomConfig)(context, chainConfig);
63
+ yield (0, run_webpack_1.runWebpack)(chainConfig);
64
+ });
65
+ const buildServer = (context) => __awaiter(void 0, void 0, void 0, function* () {
66
+ if (!context.packageConfig.server)
67
+ return;
68
+ const serverConfig = context.packageConfig.server;
69
+ const chainConfig = yield (0, webpack_common_1.createCommonChainConfig)(context, serverConfig.output);
70
+ yield (0, webpack_server_1.mergeServerEntry)(context, chainConfig);
71
+ yield (0, webpack_server_1.mergeServerCustomConfig)(context, chainConfig);
72
+ yield (0, run_webpack_1.runWebpack)(chainConfig);
73
+ });
74
+ //# sourceMappingURL=build.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"build.js","sourceRoot":"","sources":["../../src/core/build.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,gDAAwB;AACxB,gDAAkC;AAMlC,gEAGoC;AACpC,8DAGmC;AACnC,8DAEmC;AACnC,wDAEgC;AAGzB,MAAM,KAAK,GAAG,CACnB,OAA4B,EAC5B,EAAE;IACF,MAAM,CAAC,QAAQ,CAAC;QACd,GAAG,EAAE,OAAO,CAAC,IAAI;QACjB,gBAAgB,EAAE,OAAO,CAAC,IAAI;QAC9B,OAAO,EAAE,cAAI,CAAC,OAAO,CAAC,OAAO,CAAC,IAAI,EAAE,iBAAiB,CAAC;QACtD,aAAa,EAAE,IAAI;KACpB,CAAC,CAAA;IAEF,MAAM,WAAW,CACf,OAAO,CACR,CAAA;IAED,MAAM,YAAY,CAChB,OAAO,CACR,CAAA;AACH,CAAC,CAAA,CAAA;AAjBY,QAAA,KAAK,SAiBjB;AAED,MAAM,YAAY,GAAG,CAAO,OAA4B,EAAE,EAAE;IAC1D,IAAI,CAAC,OAAO,CAAC,aAAa,CAAC,OAAO;QAAE,OAAO;IAC3C,MAAM,aAAa,GAAG,OAAO,CAAC,aAAa,CAAC,OAAO,CAAC;IAEpD,MAAM,WAAW,GAAG,MAAM,IAAA,wCAAuB,EAC/C,OAAO,EACP,aAAa,CAAC,MAAM,CACrB,CAAC;IAEF,MAAM,IAAA,mCAAiB,EACrB,OAAO,EACP,WAAW,CACZ,CAAA;IAED,MAAM,IAAA,0CAAwB,EAC5B,OAAO,EACP,WAAW,CACZ,CAAA;IAED,MAAM,IAAA,wBAAU,EAAC,WAAW,CAAC,CAAC;AAChC,CAAC,CAAA,CAAA;AAGD,MAAM,WAAW,GAAG,CAAO,OAA4B,EAAE,EAAE;IACzD,IAAI,CAAC,OAAO,CAAC,aAAa,CAAC,MAAM;QAAE,OAAO;IAC1C,MAAM,YAAY,GAAG,OAAO,CAAC,aAAa,CAAC,MAAM,CAAC;IAElD,MAAM,WAAW,GAAG,MAAM,IAAA,wCAAuB,EAC/C,OAAO,EACP,YAAY,CAAC,MAAM,CACpB,CAAC;IAEF,MAAM,IAAA,iCAAgB,EACpB,OAAO,EACP,WAAW,CACZ,CAAC;IACF,MAAM,IAAA,wCAAuB,EAC3B,OAAO,EACP,WAAW,CACZ,CAAC;IACF,MAAM,IAAA,wBAAU,EAAC,WAAW,CAAC,CAAC;AAChC,CAAC,CAAA,CAAA"}
@@ -0,0 +1,2 @@
1
+ import { SugarScriptsContext } from './running-context';
2
+ export declare const clean: (context: SugarScriptsContext) => Promise<void>;
@@ -0,0 +1,9 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.clean = void 0;
4
+ const file_helpers_1 = require("../shared/file-helpers");
5
+ const clean = (context) => {
6
+ return (0, file_helpers_1.rm)(context.getCacheRootDir());
7
+ };
8
+ exports.clean = clean;
9
+ //# sourceMappingURL=cache.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"cache.js","sourceRoot":"","sources":["../../src/core/cache.ts"],"names":[],"mappings":";;;AAIA,yDAEgC;AAEzB,MAAM,KAAK,GAAG,CACnB,OAA4B,EAC5B,EAAE;IACF,OAAO,IAAA,iBAAE,EACP,OAAO,CAAC,eAAe,EAAE,CAC1B,CAAC;AACJ,CAAC,CAAA;AANY,QAAA,KAAK,SAMjB"}
@@ -0,0 +1 @@
1
+ export declare const info: () => void;
@@ -0,0 +1,6 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.info = void 0;
4
+ const info = () => { };
5
+ exports.info = info;
6
+ //# sourceMappingURL=info.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"info.js","sourceRoot":"","sources":["../../src/core/info.ts"],"names":[],"mappings":";;;AAIO,MAAM,IAAI,GAAG,GAAG,EAAE,GAAE,CAAC,CAAA;AAAf,QAAA,IAAI,QAAW"}
@@ -0,0 +1,2 @@
1
+ import { SugarScriptsContext } from './running-context';
2
+ export declare const initRunningContext: (dir: string) => Promise<SugarScriptsContext>;
@@ -0,0 +1,30 @@
1
+ "use strict";
2
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
+ return new (P || (P = Promise))(function (resolve, reject) {
5
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
6
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
7
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
8
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
9
+ });
10
+ };
11
+ Object.defineProperty(exports, "__esModule", { value: true });
12
+ exports.initRunningContext = void 0;
13
+ const file_helpers_1 = require("../shared/file-helpers");
14
+ const running_context_1 = require("./running-context");
15
+ const initRunningContext = (dir) => __awaiter(void 0, void 0, void 0, function* () {
16
+ const { root, packageJson, packageConfigs } = yield (0, file_helpers_1.findPackage)(dir);
17
+ const { projectRoot, projectConfigs } = yield (0, file_helpers_1.findProject)(root);
18
+ if (!packageConfigs || !projectConfigs) {
19
+ throw new Error('');
20
+ }
21
+ return new running_context_1.SugarScriptsContext({
22
+ root,
23
+ packageName: packageJson.name,
24
+ packageConfigs,
25
+ projectRoot,
26
+ projectConfigs
27
+ });
28
+ });
29
+ exports.initRunningContext = initRunningContext;
30
+ //# sourceMappingURL=init-running-context.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"init-running-context.js","sourceRoot":"","sources":["../../src/core/init-running-context.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,yDAGgC;AAEhC,uDAE2B;AAEpB,MAAM,kBAAkB,GAAG,CAAO,GAAW,EAAE,EAAE;IACtD,MAAM,EACJ,IAAI,EACJ,WAAW,EACX,cAAc,EACf,GAAG,MAAM,IAAA,0BAAW,EAAC,GAAG,CAAC,CAAC;IAC3B,MAAM,EACJ,WAAW,EACX,cAAc,EACf,GAAG,MAAM,IAAA,0BAAW,EAAC,IAAI,CAAC,CAAC;IAC5B,IAAI,CAAC,cAAc,IAAI,CAAC,cAAc,EAAE;QACtC,MAAM,IAAI,KAAK,CAAC,EAAE,CAAC,CAAA;KACpB;IACD,OAAO,IAAI,qCAAmB,CAAC;QAC7B,IAAI;QACJ,WAAW,EAAE,WAAW,CAAC,IAAI;QAC7B,cAAc;QACd,WAAW;QACX,cAAc;KACf,CAAC,CAAA;AACJ,CAAC,CAAA,CAAA;AApBY,QAAA,kBAAkB,sBAoB9B"}
@@ -0,0 +1,2 @@
1
+ import { Application } from 'sugar-server';
2
+ export declare const runApplication: (ApplicationClass: typeof Application, port: number) => void;
@@ -0,0 +1,9 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.runApplication = void 0;
4
+ const runApplication = (ApplicationClass, port) => {
5
+ const app = new ApplicationClass();
6
+ app.listen(port);
7
+ };
8
+ exports.runApplication = runApplication;
9
+ //# sourceMappingURL=run-application.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"run-application.js","sourceRoot":"","sources":["../../src/core/run-application.ts"],"names":[],"mappings":";;;AAIO,MAAM,cAAc,GAAG,CAC5B,gBAAoC,EACpC,IAAY,EACZ,EAAE;IACF,MAAM,GAAG,GAAG,IAAI,gBAAgB,EAAE,CAAC;IAEnC,GAAG,CAAC,MAAM,CAAC,IAAI,CAAC,CAAA;AAClB,CAAC,CAAA;AAPY,QAAA,cAAc,kBAO1B"}
@@ -0,0 +1,23 @@
1
+ import type { SugarScriptsProject } from '../custom-config.type';
2
+ export declare class SugarScriptsContext {
3
+ root: string;
4
+ rootHash: string;
5
+ packageName: string;
6
+ projectRoot: string;
7
+ packageConfigs: SugarScriptsProject.SugarPackageConfigs;
8
+ projectConfigs: SugarScriptsProject.SugarProjectConfigs;
9
+ constructor({ root, packageName, packageConfigs, projectRoot, projectConfigs }: {
10
+ root: string;
11
+ packageName: string;
12
+ packageConfigs: SugarScriptsProject.SugarPackageConfigs;
13
+ projectRoot: string;
14
+ projectConfigs: SugarScriptsProject.SugarProjectConfigs;
15
+ });
16
+ serverEntryName: string;
17
+ get packageConfig(): SugarScriptsProject.PackageConfig;
18
+ get projectConfig(): SugarScriptsProject.ProjectConfig;
19
+ getStartFilePath(): string | undefined;
20
+ getCacheRootDir(): string;
21
+ getCacheDir(): string;
22
+ getDirHash(): Promise<unknown>;
23
+ }
@@ -0,0 +1,52 @@
1
+ "use strict";
2
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
+ return new (P || (P = Promise))(function (resolve, reject) {
5
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
6
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
7
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
8
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
9
+ });
10
+ };
11
+ var __importDefault = (this && this.__importDefault) || function (mod) {
12
+ return (mod && mod.__esModule) ? mod : { "default": mod };
13
+ };
14
+ Object.defineProperty(exports, "__esModule", { value: true });
15
+ exports.SugarScriptsContext = void 0;
16
+ const path_1 = __importDefault(require("path"));
17
+ const file_helpers_1 = require("../shared/file-helpers");
18
+ class SugarScriptsContext {
19
+ constructor({ root, packageName, packageConfigs, projectRoot, projectConfigs }) {
20
+ this.serverEntryName = 'main';
21
+ this.root = root;
22
+ this.packageName = packageName;
23
+ this.projectRoot = projectRoot;
24
+ this.packageConfigs = packageConfigs;
25
+ this.projectConfigs = projectConfigs;
26
+ this.rootHash = (0, file_helpers_1.getHashFromRoot)(root);
27
+ }
28
+ get packageConfig() {
29
+ return this.packageConfigs.packageConfig;
30
+ }
31
+ get projectConfig() {
32
+ return this.projectConfigs.projectConfig;
33
+ }
34
+ getStartFilePath() {
35
+ if (this.packageConfig.server) {
36
+ return path_1.default.resolve(this.root, this.packageConfig.server.output, this.serverEntryName);
37
+ }
38
+ }
39
+ getCacheRootDir() {
40
+ return path_1.default.resolve(this.projectRoot, this.projectConfig.cacheDir);
41
+ }
42
+ getCacheDir() {
43
+ return path_1.default.resolve(this.projectRoot, this.projectConfig.cacheDir, path_1.default.relative(this.projectRoot, this.root));
44
+ }
45
+ getDirHash() {
46
+ return __awaiter(this, void 0, void 0, function* () {
47
+ return yield (0, file_helpers_1.asyncGetDirHash)(this.root);
48
+ });
49
+ }
50
+ }
51
+ exports.SugarScriptsContext = SugarScriptsContext;
52
+ //# sourceMappingURL=running-context.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"running-context.js","sourceRoot":"","sources":["../../src/core/running-context.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;AAAA,gDAAwB;AAKxB,yDAGgC;AAEhC,MAAa,mBAAmB;IAQ9B,YACE,EACE,IAAI,EACJ,WAAW,EACX,cAAc,EACd,WAAW,EACX,cAAc,EAOf;QAUH,oBAAe,GAAG,MAAM,CAAC;QARvB,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC;QACjB,IAAI,CAAC,WAAW,GAAG,WAAW,CAAC;QAC/B,IAAI,CAAC,WAAW,GAAG,WAAW,CAAC;QAC/B,IAAI,CAAC,cAAc,GAAG,cAAc,CAAC;QACrC,IAAI,CAAC,cAAc,GAAG,cAAc,CAAC;QACrC,IAAI,CAAC,QAAQ,GAAG,IAAA,8BAAe,EAAC,IAAI,CAAC,CAAC;IACxC,CAAC;IAID,IAAI,aAAa;QACf,OAAO,IAAI,CAAC,cAAc,CAAC,aAAa,CAAC;IAC3C,CAAC;IAED,IAAI,aAAa;QACf,OAAO,IAAI,CAAC,cAAc,CAAC,aAAa,CAAC;IAC3C,CAAC;IAED,gBAAgB;QACd,IAAI,IAAI,CAAC,aAAa,CAAC,MAAM,EAAE;YAC7B,OAAO,cAAI,CAAC,OAAO,CACjB,IAAI,CAAC,IAAI,EACT,IAAI,CAAC,aAAa,CAAC,MAAM,CAAC,MAAM,EAChC,IAAI,CAAC,eAAe,CACrB,CAAA;SACF;IACH,CAAC;IAED,eAAe;QACb,OAAO,cAAI,CAAC,OAAO,CACjB,IAAI,CAAC,WAAW,EAChB,IAAI,CAAC,aAAa,CAAC,QAAQ,CAC5B,CAAA;IACH,CAAC;IAED,WAAW;QACT,OAAO,cAAI,CAAC,OAAO,CACjB,IAAI,CAAC,WAAW,EAChB,IAAI,CAAC,aAAa,CAAC,QAAQ,EAC3B,cAAI,CAAC,QAAQ,CACX,IAAI,CAAC,WAAW,EAChB,IAAI,CAAC,IAAI,CACV,CACF,CAAA;IACH,CAAC;IAEK,UAAU;;YACd,OAAO,MAAM,IAAA,8BAAe,EAAC,IAAI,CAAC,IAAI,CAAC,CAAC;QAC1C,CAAC;KAAA;CACF;AAxED,kDAwEC"}
@@ -0,0 +1,51 @@
1
+ import type { Controller } from 'sugar-server';
2
+ import type WebpackChainConfig from 'webpack-chain';
3
+ import { SugarScriptsContext } from './core/running-context';
4
+ declare type ControllerContext = Controller["context"];
5
+ export declare namespace SugarScriptsProject {
6
+ type BrowserWebpackConfig = CustomWebpackConfig;
7
+ type ServerWebpackConfig = CustomWebpackConfig;
8
+ interface PackageConfig {
9
+ browser?: {
10
+ /**
11
+ * 是否构建dll用的输出
12
+ */
13
+ /**
14
+ * 输出目录
15
+ */
16
+ output: string;
17
+ entry?: BuildEntry;
18
+ };
19
+ server?: {
20
+ output: string;
21
+ entry: string;
22
+ render?: string;
23
+ };
24
+ }
25
+ interface ProjectConfig {
26
+ cacheDir: string;
27
+ }
28
+ type SugarPackageConfigs = {
29
+ packageConfig: PackageConfig;
30
+ browserWebpackConfig?: BrowserWebpackConfig;
31
+ serverWebpackConfig?: ServerWebpackConfig;
32
+ };
33
+ type SugarProjectConfigs = {
34
+ projectConfig: ProjectConfig;
35
+ browserWebpackConfig?: BrowserWebpackConfig;
36
+ serverWebpackConfig?: ServerWebpackConfig;
37
+ };
38
+ interface CustomRender<C = any> {
39
+ (ctx: ControllerContext, entries: string[] | {
40
+ [key: string]: string[];
41
+ }, custom: C): string;
42
+ }
43
+ }
44
+ declare type BuildEntry = {
45
+ [key: string]: string | string[];
46
+ };
47
+ export declare type CustomWebpackConfig = (webpackChainConfig: WebpackChainConfig, context: SugarScriptsContext) => void;
48
+ export declare type CustomRender<C = any> = (ctx: ControllerContext, entries: string[] | {
49
+ [key: string]: string[];
50
+ }, custom: C) => string;
51
+ export {};
@@ -0,0 +1,8 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.SugarScriptsProject = void 0;
4
+ var SugarScriptsProject;
5
+ (function (SugarScriptsProject) {
6
+ ;
7
+ })(SugarScriptsProject = exports.SugarScriptsProject || (exports.SugarScriptsProject = {}));
8
+ //# sourceMappingURL=custom-config.type.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"custom-config.type.js","sourceRoot":"","sources":["../src/custom-config.type.ts"],"names":[],"mappings":";;;AAWA,IAAiB,mBAAmB,CAmDnC;AAnDD,WAAiB,mBAAmB;IAkDjC,CAAC;AACJ,CAAC,EAnDgB,mBAAmB,GAAnB,2BAAmB,KAAnB,2BAAmB,QAmDnC"}
package/lib/index.d.ts ADDED
@@ -0,0 +1 @@
1
+ export { SugarScriptsProject } from './custom-config.type';
package/lib/index.js ADDED
@@ -0,0 +1,6 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.SugarScriptsProject = void 0;
4
+ var custom_config_type_1 = require("./custom-config.type");
5
+ Object.defineProperty(exports, "SugarScriptsProject", { enumerable: true, get: function () { return custom_config_type_1.SugarScriptsProject; } });
6
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;AAAA,2DAE8B;AAD5B,yHAAA,mBAAmB,OAAA"}
@@ -0,0 +1,18 @@
1
+ import { SugarScriptsProject } from '../custom-config.type';
2
+ export declare const searchFiles: (dir: string, fileCheck: string | ((filePath: string) => boolean), exclude?: string) => Promise<string[]>;
3
+ export declare const findSiblingFile: (currentFilePath: string, searchFileName: string) => Promise<string | null>;
4
+ export declare const findParentFile: (currentFilePath: string, searchFileName: string) => Promise<string | null>;
5
+ export declare const loadJSON: (filePath: string) => Promise<any>;
6
+ export declare const writeFileSync: (filePath: string, data: string | NodeJS.ArrayBufferView) => void;
7
+ export declare const findPackage: (dir: string) => Promise<{
8
+ root: string;
9
+ packageJson: any;
10
+ packageConfigs: SugarScriptsProject.SugarPackageConfigs | null;
11
+ }>;
12
+ export declare const findProject: (dir: string) => Promise<{
13
+ projectRoot: string;
14
+ projectConfigs: SugarScriptsProject.SugarProjectConfigs;
15
+ }>;
16
+ export declare const rm: (filePath: string) => Promise<void>;
17
+ export declare function getHashFromRoot(root: string): string;
18
+ export declare function asyncGetDirHash(dirPath: string): Promise<unknown>;