@celljs/vercel-adapter 3.8.0 → 4.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,3 @@
1
+ export declare const DEFAULT_SERVER_OPTIONS: {
2
+ port: number;
3
+ };
@@ -0,0 +1,4 @@
1
+ export const DEFAULT_SERVER_OPTIONS = {
2
+ port: 3000
3
+ };
4
+ //# sourceMappingURL=context.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"context.js","sourceRoot":"","sources":["../../src/node/context.ts"],"names":[],"mappings":"AAAA,MAAM,CAAC,MAAM,sBAAsB,GAAG;IAClC,IAAI,EAAE,IAAI;CACb,CAAC"}
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,20 @@
1
+ import { container } from '@celljs/core/lib/common/container/dynamic-container';
2
+ import { Dispatcher, Context } from '@celljs/web/lib/node';
3
+ import express from 'express';
4
+ import { DEFAULT_SERVER_OPTIONS } from './context.js';
5
+ import { ContainerProvider, Application, ConfigProvider } from '@celljs/core';
6
+ container.then(async (c) => {
7
+ ContainerProvider.set(c);
8
+ await c.get(Application).start();
9
+ const configProvider = c.get(ConfigProvider);
10
+ const { port } = configProvider.get('cell.server', DEFAULT_SERVER_OPTIONS);
11
+ const app = express();
12
+ app.all('*', async (req, res) => {
13
+ const dispatcher = c.get(Dispatcher);
14
+ const httpContext = new Context(req, res);
15
+ Context.run(() => dispatcher.dispatch(httpContext));
16
+ });
17
+ app.listen(port);
18
+ console.log(`serve ${port}`);
19
+ });
20
+ //# sourceMappingURL=http-application-entry.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"http-application-entry.js","sourceRoot":"","sources":["../../src/node/http-application-entry.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,qDAAqD,CAAC;AAChF,OAAO,EAAE,UAAU,EAAE,OAAO,EAAE,MAAM,sBAAsB,CAAC;AAC3D,OAAO,OAAO,MAAM,SAAS,CAAC;AAC9B,OAAO,EAAE,sBAAsB,EAAE,MAAM,WAAW,CAAC;AACnD,OAAO,EAAE,iBAAiB,EAAE,WAAW,EAAE,cAAc,EAAE,MAAM,cAAc,CAAC;AAE9E,SAAS,CAAC,IAAI,CAAC,KAAK,EAAC,CAAC,EAAC,EAAE;IACrB,iBAAiB,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC;IACzB,MAAM,CAAC,CAAC,GAAG,CAAc,WAAW,CAAC,CAAC,KAAK,EAAE,CAAC;IAC9C,MAAM,cAAc,GAAG,CAAC,CAAC,GAAG,CAAiB,cAAc,CAAC,CAAC;IAC7D,MAAM,EAAE,IAAI,EAAE,GAAG,cAAc,CAAC,GAAG,CAAM,aAAa,EAAE,sBAAsB,CAAC,CAAC;IAEhF,MAAM,GAAG,GAAG,OAAO,EAAE,CAAC;IACtB,GAAG,CAAC,GAAG,CAAC,GAAG,EAAE,KAAK,EAAE,GAAQ,EAAE,GAAQ,EAAE,EAAE;QACtC,MAAM,UAAU,GAAG,CAAC,CAAC,GAAG,CAAsB,UAAU,CAAC,CAAC;QAC1D,MAAM,WAAW,GAAG,IAAI,OAAO,CAAC,GAAG,EAAE,GAAG,CAAC,CAAC;QAC1C,OAAO,CAAC,GAAG,CAAC,GAAG,EAAE,CAAC,UAAU,CAAC,QAAQ,CAAC,WAAW,CAAC,CAAC,CAAC;IACxD,CAAC,CAAC,CAAC;IACH,GAAG,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC;IACjB,OAAO,CAAC,GAAG,CAAC,SAAS,IAAI,EAAE,CAAC,CAAC;AACjC,CAAC,CAAC,CAAC"}
@@ -0,0 +1 @@
1
+ export * from './context.js';
@@ -0,0 +1,2 @@
1
+ export * from './context.js';
2
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/node/index.ts"],"names":[],"mappings":"AAAA,cAAc,WAAW,CAAC"}
@@ -0,0 +1,2 @@
1
+ declare const _default: import("inversify").interfaces.ContainerModule;
2
+ export default _default;
@@ -0,0 +1,3 @@
1
+ import { autoBind } from '@celljs/core';
2
+ export default autoBind();
3
+ //# sourceMappingURL=module.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"module.js","sourceRoot":"","sources":["../../src/node/module.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,cAAc,CAAC;AAExC,eAAe,QAAQ,EAAE,CAAC"}
@@ -0,0 +1,3 @@
1
+ {
2
+ "type": "module"
3
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@celljs/vercel-adapter",
3
- "version": "3.8.0",
3
+ "version": "4.0.0",
4
4
  "description": "",
5
5
  "keywords": [
6
6
  "cell-component"
@@ -18,30 +18,50 @@
18
18
  "typings": "lib/node/index.d.ts",
19
19
  "files": [
20
20
  "lib",
21
+ "esm",
21
22
  "src",
22
- "cell.yml",
23
- "cell-remote.yml"
23
+ "cell.yml"
24
24
  ],
25
25
  "scripts": {
26
- "build": "tsc -b",
27
- "clean": "rm -rf lib *.tsbuildinfo",
26
+ "build": "tsc -b && bun ../../scripts/build-esm.ts",
27
+ "clean": "rm -rf lib esm *.tsbuildinfo",
28
28
  "test": "bun test --preload reflect-metadata ./lib",
29
29
  "watch": "tsc -b -w --preserveWatchOutput"
30
30
  },
31
31
  "dependencies": {
32
- "@celljs/cli-common": "3.8.0",
33
- "@celljs/core": "3.8.0",
34
- "@celljs/web": "3.8.0",
35
- "chalk": "^4.1.0",
36
- "command-exists": "^1.2.9",
32
+ "@celljs/core": "4.0.0",
33
+ "@celljs/web": "4.0.0",
37
34
  "express": "^4.17.1",
38
- "fs-extra": "^9.0.13",
39
35
  "tslib": "^2.8.0"
40
36
  },
41
- "devDependencies": {
42
- "@celljs/cli-service": "3.8.0"
43
- },
44
37
  "publishConfig": {
45
38
  "access": "public"
39
+ },
40
+ "exports": {
41
+ ".": {
42
+ "import": "./esm/node/index.js",
43
+ "default": "./lib/node/index.js"
44
+ },
45
+ "./package.json": "./package.json",
46
+ "./lib/node": {
47
+ "import": "./esm/node/index.js",
48
+ "default": "./lib/node/index.js"
49
+ },
50
+ "./lib/*.js": {
51
+ "import": "./esm/*.js",
52
+ "default": "./lib/*.js"
53
+ },
54
+ "./lib/*": {
55
+ "import": "./esm/*.js",
56
+ "default": "./lib/*.js"
57
+ },
58
+ "./*": "./*"
59
+ },
60
+ "cell": {
61
+ "modules": {
62
+ "backend": [
63
+ "lib/node/module"
64
+ ]
65
+ }
46
66
  }
47
67
  }
package/cell-remote.yml DELETED
@@ -1,10 +0,0 @@
1
- cell:
2
- vercel:
3
- config:
4
- version: 2
5
- builds:
6
- - src: ${ 'dist/backend/**' | onTarget('backend') || 'dist/frontend/**' }
7
- use: ${ '@vercel/node' | onTarget('backend') || '@vercel/static' }
8
- routes:
9
- - src: ${ '/api' | onTarget('backend') || '/(.*).js' }
10
- dest: ${ 'dist/backend/index.js' | onTarget('backend') || 'dist/frontend/$1.js' }
@@ -1,4 +0,0 @@
1
- import { BuildContext } from '@celljs/cli-common';
2
- export default _default;
3
- declare function _default(context: BuildContext): Promise<void>;
4
- //# sourceMappingURL=build.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"build.d.ts","sourceRoot":"","sources":["../../src/hooks/build.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAyD,MAAM,oBAAoB,CAAC;;0BAInF,OAAO,EAAE,YAAY"}
@@ -1,30 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- const cli_common_1 = require("@celljs/cli-common");
4
- const path_1 = require("path");
5
- const fs_extra_1 = require("fs-extra");
6
- exports.default = async (context) => {
7
- const { cfg } = context;
8
- let vercelConfig = {};
9
- for (const target of [cli_common_1.BACKEND_TARGET, cli_common_1.FRONTEND_TARGET]) {
10
- if (cli_common_1.ConfigUtil.support(cfg, target)) {
11
- const config = cli_common_1.ConfigUtil.getCellConfig(cfg, target).vercel.config;
12
- if (target === cli_common_1.BACKEND_TARGET) {
13
- vercelConfig = cli_common_1.ConfigUtil.merge(config, vercelConfig);
14
- }
15
- else {
16
- vercelConfig = cli_common_1.ConfigUtil.merge(vercelConfig, config);
17
- }
18
- }
19
- }
20
- if (!cli_common_1.ConfigUtil.support(cfg, cli_common_1.FRONTEND_TARGET)) {
21
- vercelConfig.routes.push({
22
- src: '/.*',
23
- dest: 'dist/backend/index.js'
24
- });
25
- }
26
- await (0, fs_extra_1.ensureDir)(cli_common_1.PathUtil.getProjectHomePath());
27
- const configPath = (0, path_1.resolve)(cli_common_1.PathUtil.getProjectHomePath(), 'vercel.json');
28
- await (0, fs_extra_1.writeJSON)(configPath, vercelConfig, { spaces: 2 });
29
- };
30
- //# sourceMappingURL=build.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"build.js","sourceRoot":"","sources":["../../src/hooks/build.ts"],"names":[],"mappings":";;AAAA,mDAAyG;AACzG,+BAA+B;AAC/B,uCAAgD;kBAEjC,KAAK,EAAE,OAAqB,EAAE,EAAE;IAC3C,MAAM,EAAE,GAAG,EAAE,GAAG,OAAO,CAAC;IACxB,IAAI,YAAY,GAAQ,EAAE,CAAC;IAE3B,KAAK,MAAM,MAAM,IAAI,CAAE,2BAAc,EAAE,4BAAe,CAAE,EAAE,CAAC;QACvD,IAAI,uBAAU,CAAC,OAAO,CAAC,GAAG,EAAE,MAAM,CAAC,EAAE,CAAC;YAClC,MAAM,MAAM,GAAG,uBAAU,CAAC,aAAa,CAAC,GAAG,EAAE,MAAM,CAAC,CAAC,MAAM,CAAC,MAAM,CAAC;YACnE,IAAI,MAAM,KAAK,2BAAc,EAAE,CAAC;gBAC5B,YAAY,GAAG,uBAAU,CAAC,KAAK,CAAC,MAAM,EAAE,YAAY,CAAC,CAAC;YAC1D,CAAC;iBAAM,CAAC;gBACJ,YAAY,GAAG,uBAAU,CAAC,KAAK,CAAC,YAAY,EAAE,MAAM,CAAC,CAAC;YAC1D,CAAC;QACL,CAAC;IACL,CAAC;IAED,IAAI,CAAC,uBAAU,CAAC,OAAO,CAAC,GAAG,EAAE,4BAAe,CAAC,EAAE,CAAC;QAC5C,YAAY,CAAC,MAAM,CAAC,IAAI,CAAC;YACrB,GAAG,EAAE,KAAK;YACV,IAAI,EAAE,uBAAuB;SAChC,CAAC,CAAC;IACP,CAAC;IACD,MAAM,IAAA,oBAAS,EAAC,qBAAQ,CAAC,kBAAkB,EAAE,CAAC,CAAC;IAC/C,MAAM,UAAU,GAAG,IAAA,cAAO,EAAC,qBAAQ,CAAC,kBAAkB,EAAE,EAAE,aAAa,CAAC,CAAC;IACzE,MAAM,IAAA,oBAAS,EAAC,UAAU,EAAE,YAAY,EAAE,EAAE,MAAM,EAAE,CAAC,EAAE,CAAC,CAAC;AAC7D,CAAC"}
@@ -1,4 +0,0 @@
1
- import { DeployContext } from '@celljs/cli-common';
2
- export default _default;
3
- declare function _default(context: DeployContext): Promise<void>;
4
- //# sourceMappingURL=deploy.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"deploy.d.ts","sourceRoot":"","sources":["../../src/hooks/deploy.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAY,MAAM,oBAAoB,CAAC;;0BAMvC,OAAO,EAAE,aAAa"}
@@ -1,25 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- const cli_common_1 = require("@celljs/cli-common");
4
- const path_1 = require("path");
5
- const chalk = require('chalk');
6
- const child_process_1 = require("child_process");
7
- const commandExists = require('command-exists');
8
- exports.default = async (context) => {
9
- const { pkg, prod } = context;
10
- console.log(`Deploying ${chalk.bold.yellow(pkg.pkg.name)} to Vercel...`);
11
- try {
12
- await commandExists('vercel');
13
- }
14
- catch (err) {
15
- console.log(chalk `The vercel command does not exist, please install it first: {yellow.bold npm i -g vercel}`);
16
- process.exit(-1);
17
- }
18
- const args = [];
19
- if (prod) {
20
- args.push('--prod');
21
- }
22
- args.push(...['--local-config', (0, path_1.join)(cli_common_1.PathUtil.getProjectHomePath(), 'vercel.json')]);
23
- (0, child_process_1.spawnSync)('vercel', { cwd: cli_common_1.PathUtil.getProjectHomePath(), stdio: 'inherit', shell: true });
24
- };
25
- //# sourceMappingURL=deploy.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"deploy.js","sourceRoot":"","sources":["../../src/hooks/deploy.ts"],"names":[],"mappings":";;AAAA,mDAA6D;AAC7D,+BAA4B;AAC5B,MAAM,KAAK,GAAG,OAAO,CAAC,OAAO,CAAC,CAAC;AAC/B,iDAA0C;AAC1C,MAAM,aAAa,GAAG,OAAO,CAAC,gBAAgB,CAAC,CAAC;kBAEjC,KAAK,EAAE,OAAsB,EAAE,EAAE;IAC5C,MAAM,EAAE,GAAG,EAAE,IAAI,EAAC,GAAG,OAAO,CAAC;IAC7B,OAAO,CAAC,GAAG,CAAC,aAAa,KAAK,CAAC,IAAI,CAAC,MAAM,CAAC,GAAG,CAAC,GAAG,CAAC,IAAI,CAAC,eAAe,CAAC,CAAC;IACzE,IAAI,CAAC;QACD,MAAM,aAAa,CAAC,QAAQ,CAAC,CAAC;IAClC,CAAC;IAAC,OAAO,GAAG,EAAE,CAAC;QACX,OAAO,CAAC,GAAG,CAAC,KAAK,CAAA,2FAA2F,CAAC,CAAC;QAC9G,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,CAAC;IACrB,CAAC;IACD,MAAM,IAAI,GAAG,EAAE,CAAC;IAChB,IAAI,IAAI,EAAE,CAAC;QACP,IAAI,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC;IACxB,CAAC;IACD,IAAI,CAAC,IAAI,CAAC,GAAG,CAAC,gBAAgB,EAAE,IAAA,WAAI,EAAC,qBAAQ,CAAC,kBAAkB,EAAE,EAAE,aAAa,CAAC,CAAC,CAAC,CAAC;IACrF,IAAA,yBAAS,EAAC,QAAQ,EAAE,EAAE,GAAG,EAAE,qBAAQ,CAAC,kBAAkB,EAAE,EAAE,KAAK,EAAE,SAAS,EAAE,KAAK,EAAE,IAAI,EAAE,CAAC,CAAC;AAC/F,CAAC"}
@@ -1,29 +0,0 @@
1
- import { BuildContext, FRONTEND_TARGET, BACKEND_TARGET, ConfigUtil, PathUtil } from '@celljs/cli-common';
2
- import { resolve } from 'path';
3
- import { writeJSON, ensureDir } from 'fs-extra';
4
-
5
- export default async (context: BuildContext) => {
6
- const { cfg } = context;
7
- let vercelConfig: any = {};
8
-
9
- for (const target of [ BACKEND_TARGET, FRONTEND_TARGET ]) {
10
- if (ConfigUtil.support(cfg, target)) {
11
- const config = ConfigUtil.getCellConfig(cfg, target).vercel.config;
12
- if (target === BACKEND_TARGET) {
13
- vercelConfig = ConfigUtil.merge(config, vercelConfig);
14
- } else {
15
- vercelConfig = ConfigUtil.merge(vercelConfig, config);
16
- }
17
- }
18
- }
19
-
20
- if (!ConfigUtil.support(cfg, FRONTEND_TARGET)) {
21
- vercelConfig.routes.push({
22
- src: '/.*',
23
- dest: 'dist/backend/index.js'
24
- });
25
- }
26
- await ensureDir(PathUtil.getProjectHomePath());
27
- const configPath = resolve(PathUtil.getProjectHomePath(), 'vercel.json');
28
- await writeJSON(configPath, vercelConfig, { spaces: 2 });
29
- };
@@ -1,22 +0,0 @@
1
- import { DeployContext, PathUtil } from '@celljs/cli-common';
2
- import { join } from 'path';
3
- const chalk = require('chalk');
4
- import { spawnSync } from 'child_process';
5
- const commandExists = require('command-exists');
6
-
7
- export default async (context: DeployContext) => {
8
- const { pkg, prod} = context;
9
- console.log(`Deploying ${chalk.bold.yellow(pkg.pkg.name)} to Vercel...`);
10
- try {
11
- await commandExists('vercel');
12
- } catch (err) {
13
- console.log(chalk`The vercel command does not exist, please install it first: {yellow.bold npm i -g vercel}`);
14
- process.exit(-1);
15
- }
16
- const args = [];
17
- if (prod) {
18
- args.push('--prod');
19
- }
20
- args.push(...['--local-config', join(PathUtil.getProjectHomePath(), 'vercel.json')]);
21
- spawnSync('vercel', { cwd: PathUtil.getProjectHomePath(), stdio: 'inherit', shell: true });
22
- };