@vtex/checkout 0.0.4 → 0.0.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +15 -0
- package/README.md +31 -0
- package/dist/commands/dev.d.ts +3 -8
- package/dist/commands/dev.js +58 -18
- package/dist/commands/dev.js.map +1 -1
- package/eslintrc.json +18 -0
- package/package.json +9 -4
- package/src/commands/dev.ts +92 -21
- package/.next/BUILD_ID +0 -1
- package/.next/app.js +0 -13723
- package/.next/build-manifest.json +0 -34
- package/.next/cache/webpack/client-development/0.pack.gz +0 -0
- package/.next/cache/webpack/client-development/1.pack.gz +0 -0
- package/.next/cache/webpack/client-development/10.pack.gz +0 -0
- package/.next/cache/webpack/client-development/11.pack.gz +0 -0
- package/.next/cache/webpack/client-development/12.pack.gz +0 -0
- package/.next/cache/webpack/client-development/13.pack.gz +0 -0
- package/.next/cache/webpack/client-development/14.pack.gz +0 -0
- package/.next/cache/webpack/client-development/15.pack.gz +0 -0
- package/.next/cache/webpack/client-development/2.pack.gz +0 -0
- package/.next/cache/webpack/client-development/3.pack.gz +0 -0
- package/.next/cache/webpack/client-development/4.pack.gz +0 -0
- package/.next/cache/webpack/client-development/5.pack.gz +0 -0
- package/.next/cache/webpack/client-development/6.pack.gz +0 -0
- package/.next/cache/webpack/client-development/7.pack.gz +0 -0
- package/.next/cache/webpack/client-development/8.pack.gz +0 -0
- package/.next/cache/webpack/client-development/9.pack.gz +0 -0
- package/.next/cache/webpack/client-development/index.pack.gz +0 -0
- package/.next/cache/webpack/client-development/index.pack.gz.old +0 -0
- package/.next/cache/webpack/client-development-fallback/0.pack.gz +0 -0
- package/.next/cache/webpack/client-development-fallback/1.pack.gz +0 -0
- package/.next/cache/webpack/client-development-fallback/2.pack.gz +0 -0
- package/.next/cache/webpack/client-development-fallback/index.pack.gz +0 -0
- package/.next/cache/webpack/client-development-fallback/index.pack.gz.old +0 -0
- package/.next/cache/webpack/client-production/0.pack +0 -0
- package/.next/cache/webpack/client-production/1.pack +0 -0
- package/.next/cache/webpack/client-production/2.pack +0 -0
- package/.next/cache/webpack/client-production/index.pack +0 -0
- package/.next/cache/webpack/client-production/index.pack.old +0 -0
- package/.next/cache/webpack/server-development/0.pack.gz +0 -0
- package/.next/cache/webpack/server-development/1.pack.gz +0 -0
- package/.next/cache/webpack/server-development/10.pack.gz +0 -0
- package/.next/cache/webpack/server-development/11.pack.gz +0 -0
- package/.next/cache/webpack/server-development/12.pack.gz +0 -0
- package/.next/cache/webpack/server-development/13.pack.gz +0 -0
- package/.next/cache/webpack/server-development/14.pack.gz +0 -0
- package/.next/cache/webpack/server-development/15.pack.gz +0 -0
- package/.next/cache/webpack/server-development/16.pack.gz +0 -0
- package/.next/cache/webpack/server-development/17.pack.gz +0 -0
- package/.next/cache/webpack/server-development/2.pack.gz +0 -0
- package/.next/cache/webpack/server-development/3.pack.gz +0 -0
- package/.next/cache/webpack/server-development/4.pack.gz +0 -0
- package/.next/cache/webpack/server-development/5.pack.gz +0 -0
- package/.next/cache/webpack/server-development/6.pack.gz +0 -0
- package/.next/cache/webpack/server-development/7.pack.gz +0 -0
- package/.next/cache/webpack/server-development/8.pack.gz +0 -0
- package/.next/cache/webpack/server-development/9.pack.gz +0 -0
- package/.next/cache/webpack/server-development/index.pack.gz +0 -0
- package/.next/cache/webpack/server-development/index.pack.gz.old +0 -0
- package/.next/cache/webpack/server-production/0.pack +0 -0
- package/.next/cache/webpack/server-production/1.pack +0 -0
- package/.next/cache/webpack/server-production/2.pack +0 -0
- package/.next/cache/webpack/server-production/index.pack +0 -0
- package/.next/cache/webpack/server-production/index.pack.old +0 -0
- package/.next/export-marker.json +0 -1
- package/.next/images-manifest.json +0 -1
- package/.next/next-minimal-server.js.nft.json +0 -1
- package/.next/next-server.js.nft.json +0 -1
- package/.next/package.json +0 -1
- package/.next/prerender-manifest.js +0 -1
- package/.next/prerender-manifest.json +0 -1
- package/.next/react-loadable-manifest.json +0 -16
- package/.next/required-server-files.json +0 -1
- package/.next/routes-manifest.json +0 -1
- package/.next/server/child.js.nft.json +0 -1
- package/.next/server/chunks/13.js +0 -6
- package/.next/server/chunks/196.js +0 -6
- package/.next/server/chunks/229.js +0 -1
- package/.next/server/chunks/360.js +0 -1
- package/.next/server/chunks/591.js +0 -1
- package/.next/server/chunks/596.js +0 -1
- package/.next/server/chunks/597.js +0 -1
- package/.next/server/chunks/614.js +0 -1
- package/.next/server/chunks/666.js +0 -1
- package/.next/server/chunks/font-manifest.json +0 -1
- package/.next/server/font-manifest.json +0 -1
- package/.next/server/functions-config-manifest.json +0 -1
- package/.next/server/middleware-build-manifest.js +0 -1
- package/.next/server/middleware-manifest.json +0 -6
- package/.next/server/middleware-react-loadable-manifest.js +0 -1
- package/.next/server/next-font-manifest.js +0 -1
- package/.next/server/next-font-manifest.json +0 -1
- package/.next/server/pages/404.html +0 -1
- package/.next/server/pages/500.html +0 -1
- package/.next/server/pages/_app.js +0 -1
- package/.next/server/pages/_app.js.nft.json +0 -1
- package/.next/server/pages/_document.js +0 -1
- package/.next/server/pages/_document.js.nft.json +0 -1
- package/.next/server/pages/_error.js +0 -1
- package/.next/server/pages/_error.js.nft.json +0 -1
- package/.next/server/pages/cart.html +0 -1
- package/.next/server/pages/cart.js.nft.json +0 -1
- package/.next/server/pages/error.html +0 -1
- package/.next/server/pages/error.js.nft.json +0 -1
- package/.next/server/pages/index.html +0 -1
- package/.next/server/pages/index.js.nft.json +0 -1
- package/.next/server/pages/information.html +0 -1
- package/.next/server/pages/information.js.nft.json +0 -1
- package/.next/server/pages/order-placed.html +0 -1
- package/.next/server/pages/order-placed.js.nft.json +0 -1
- package/.next/server/pages/payment.html +0 -1
- package/.next/server/pages/payment.js.nft.json +0 -1
- package/.next/server/pages/review.html +0 -1
- package/.next/server/pages/review.js.nft.json +0 -1
- package/.next/server/pages/shipping.html +0 -1
- package/.next/server/pages/shipping.js.nft.json +0 -1
- package/.next/server/pages-manifest.json +0 -6
- package/.next/server/webpack-runtime.js +0 -1
- package/.next/static/chunks/283.ae878e569cc1c6c6.js +0 -1
- package/.next/static/chunks/289.89baf2cd56f364dd.js +0 -1
- package/.next/static/chunks/452-c9c42e82e193c149.js +0 -28
- package/.next/static/chunks/48.74f8ccf7093fc97e.js +0 -1
- package/.next/static/chunks/511.17354af5cc99484a.js +0 -1
- package/.next/static/chunks/547.ecc657de7f828c6d.js +0 -1
- package/.next/static/chunks/580.8522f095114392b2.js +0 -1
- package/.next/static/chunks/767.f21d4bef2cf4abb9.js +0 -1
- package/.next/static/chunks/837.9ce4bf09b289da12.js +0 -1
- package/.next/static/chunks/875.250c8953ac0e1470.js +0 -1
- package/.next/static/chunks/962-065fc9005ff494bc.js +0 -1
- package/.next/static/chunks/__federation_expose_next__router.b5a9abc98090a2de.js +0 -1
- package/.next/static/chunks/__federation_expose_noop.963a2fdd1fba2758.js +0 -1
- package/.next/static/chunks/framework.f78291b49cc273b4.js +0 -33
- package/.next/static/chunks/host_partial-b86a775d37294c54.js +0 -1
- package/.next/static/chunks/main-3ae760138ff00173.js +0 -76
- package/.next/static/chunks/mf-manifest.json +0 -453
- package/.next/static/chunks/mf-stats.json +0 -498
- package/.next/static/chunks/pages/_app-87fced03b9a5ef01.js +0 -221
- package/.next/static/chunks/pages/_error-e4e778d2d8049b12.js +0 -1
- package/.next/static/chunks/pages/cart-0d27ec2ce6a7ac2d.js +0 -1
- package/.next/static/chunks/pages/error-4a2a3f28162165a4.js +0 -1
- package/.next/static/chunks/pages/index-f92bc70523038de7.js +0 -1
- package/.next/static/chunks/pages/information-197e9e0c818079e5.js +0 -1
- package/.next/static/chunks/pages/order-placed-59e1c2f665999f97.js +0 -1
- package/.next/static/chunks/pages/payment-fae274060d8ce413.js +0 -1
- package/.next/static/chunks/pages/review-0463130f56c64916.js +0 -23
- package/.next/static/chunks/pages/shipping-bdbb0236fa276e0e.js +0 -1
- package/.next/static/chunks/polyfills-c67a75d1b6f99dc8.js +0 -1
- package/.next/static/chunks/webpack-c6dea4423a3bdf06.js +0 -76
- package/.next/static/chunks/webpack.js +0 -13846
- package/.next/static/css/367069ca192a3be0.css +0 -1
- package/.next/static/css/7ada7ff2171415dd.css +0 -1
- package/.next/static/css/7e55abe6b1a50030.css +0 -1
- package/.next/static/css/abd736512eec0dda.css +0 -1
- package/.next/static/css/bdeabaa9a05c8691.css +0 -1
- package/.next/static/css/ced75b88bedb7923.css +0 -1
- package/.next/static/css/d7fb6f2fa4eb6c74.css +0 -1
- package/.next/static/css/f24e8b26d29a4a20.css +0 -1
- package/.next/static/css/f7984d2f0908e4e9.css +0 -1
- package/.next/static/css/fd5216a8997e095a.css +0 -1
- package/.next/static/development/_buildManifest.js +0 -1
- package/.next/static/development/_ssgManifest.js +0 -1
- package/.next/static/qX6JDFFRlMB8TltGpbcXL/_buildManifest.js +0 -1
- package/.next/static/qX6JDFFRlMB8TltGpbcXL/_ssgManifest.js +0 -1
- package/.next/static/webpack/e52f4408c9780957.host.hot-update.json +0 -1
- package/.next/static/webpack/e52f4408c9780957.webpack.hot-update.json +0 -1
- package/.next/static/webpack/host.e52f4408c9780957.hot-update.js +0 -65
- package/.next/static/webpack/webpack.e52f4408c9780957.hot-update.js +0 -65
- package/.next/trace +0 -257
package/CHANGELOG.md
CHANGED
|
@@ -7,6 +7,21 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|
|
7
7
|
|
|
8
8
|
## [Unreleased]
|
|
9
9
|
|
|
10
|
+
## [0.0.6] - 2024-09-05
|
|
11
|
+
|
|
12
|
+
### Added
|
|
13
|
+
- feat: Added local extensions server
|
|
14
|
+
|
|
15
|
+
## [0.0.5] - 2024-08-24
|
|
16
|
+
|
|
17
|
+
### Fix
|
|
18
|
+
- fix: Added missing runtime dependency
|
|
19
|
+
|
|
20
|
+
### Added
|
|
21
|
+
|
|
22
|
+
- feat: Added `dev`, `build` and `init` commands
|
|
23
|
+
|
|
24
|
+
|
|
10
25
|
## [0.0.4] - 2024-08-20
|
|
11
26
|
|
|
12
27
|
### Feature
|
package/README.md
ADDED
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
## @vtex/checkout
|
|
2
|
+
This package contains everything a merchant engineer needs to customize FastCheckout.
|
|
3
|
+
In summary, it provides:
|
|
4
|
+
- The UI of FastCheckout as a package that can be run locally (in extensions mode).
|
|
5
|
+
- The Checkout CLI, which can run FastCheckout locally and build the extensions in both development and production modes.
|
|
6
|
+
- Utility types and hooks to build extensions for FastCheckout.
|
|
7
|
+
|
|
8
|
+
## Setup and Running
|
|
9
|
+
To test locally, we'll use the `extensions-sample/` app package.
|
|
10
|
+
This package emulates the storefront monorepo. However, you need to follow a few steps to get this package ready for testing.
|
|
11
|
+
|
|
12
|
+
1. Modify your .env.local of Next.js project
|
|
13
|
+
```
|
|
14
|
+
# Add or modify the following lines
|
|
15
|
+
NEXT_PUBLIC_EXTENSIONS_MODE='development'
|
|
16
|
+
NEXT_PUBLIC_ENABLE_EXTENSIONS='true'
|
|
17
|
+
```
|
|
18
|
+
2. Run the whole build pipeline
|
|
19
|
+
```
|
|
20
|
+
yarn nx run extensions:build
|
|
21
|
+
```
|
|
22
|
+
3. Now, navigate to `packages/apps/extensions-sample/`
|
|
23
|
+
```
|
|
24
|
+
yarn checkout:dev
|
|
25
|
+
```
|
|
26
|
+
Now you can modify the content of `@vtex/checkout` as needed, with the packages properly linked through `node_modules`.
|
|
27
|
+
|
|
28
|
+
|
|
29
|
+
|
|
30
|
+
|
|
31
|
+
|
package/dist/commands/dev.d.ts
CHANGED
|
@@ -1,13 +1,8 @@
|
|
|
1
1
|
import { Command } from '@oclif/core';
|
|
2
2
|
export declare class Dev extends Command {
|
|
3
|
-
static args: {
|
|
4
|
-
file: import("@oclif/core/interfaces").Arg<string | undefined, Record<string, unknown>>;
|
|
5
|
-
};
|
|
3
|
+
static args: {};
|
|
6
4
|
static description: string;
|
|
7
|
-
static examples:
|
|
8
|
-
static flags: {
|
|
9
|
-
force: import("@oclif/core/interfaces").BooleanFlag<boolean>;
|
|
10
|
-
name: import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
|
|
11
|
-
};
|
|
5
|
+
static examples: never[];
|
|
6
|
+
static flags: {};
|
|
12
7
|
run(): Promise<void>;
|
|
13
8
|
}
|
package/dist/commands/dev.js
CHANGED
|
@@ -1,23 +1,63 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
1
|
+
import { Command } from '@oclif/core';
|
|
2
|
+
import getPort from 'get-port';
|
|
3
|
+
import express from 'express';
|
|
4
|
+
import path from 'path';
|
|
5
|
+
import fs from 'fs/promises';
|
|
6
|
+
import { existsSync } from 'fs';
|
|
7
|
+
import { spawn } from 'child_process';
|
|
8
|
+
const CORE_PATH = path.resolve('node_modules', '@vtex', 'checkout', '.next');
|
|
9
|
+
const CHECKOUT_PORT = 4301;
|
|
10
|
+
const IS_VERBOSE = process.env.CHECKOUT_CLI_VERBOSE === 'true';
|
|
11
|
+
const debug = (...args) => {
|
|
12
|
+
if (IS_VERBOSE) {
|
|
13
|
+
console.log(...args);
|
|
14
|
+
}
|
|
15
|
+
};
|
|
16
|
+
const createTempFolder = async ({ accountName, }) => {
|
|
17
|
+
const tmpFolder = path.resolve(accountName, 'checkout', '.tmp');
|
|
18
|
+
const checkoutTmpFolder = path.resolve(tmpFolder, '.next');
|
|
19
|
+
if (existsSync(tmpFolder)) {
|
|
20
|
+
await fs.rm(tmpFolder, { recursive: true, force: true });
|
|
21
|
+
}
|
|
22
|
+
await fs.mkdir(tmpFolder);
|
|
23
|
+
await fs.cp(CORE_PATH, checkoutTmpFolder, { recursive: true });
|
|
24
|
+
return {
|
|
25
|
+
checkoutTmpFolder,
|
|
13
26
|
};
|
|
27
|
+
};
|
|
28
|
+
const createExtensionsServer = async ({ accountName, checkoutTmpFolder, }) => {
|
|
29
|
+
const app = express();
|
|
30
|
+
app.get('/extensions-config', (_, res) => res.json({
|
|
31
|
+
accountName,
|
|
32
|
+
// TODO: Change after creating the static server using CLI
|
|
33
|
+
staticServer: 'http://localhost:4302',
|
|
34
|
+
}));
|
|
35
|
+
const EXTENSIONS_SERVER_PORT = await getPort();
|
|
36
|
+
app.listen(EXTENSIONS_SERVER_PORT, () => {
|
|
37
|
+
debug(`Checkout running at htt://localhost:${EXTENSIONS_SERVER_PORT}`);
|
|
38
|
+
});
|
|
39
|
+
const checkoutServer = path.resolve(checkoutTmpFolder, 'standalone', 'server.js');
|
|
40
|
+
const child = spawn(process.execPath, [checkoutServer], {
|
|
41
|
+
stdio: IS_VERBOSE ? 'inherit' : 'ignore',
|
|
42
|
+
env: {
|
|
43
|
+
PORT: CHECKOUT_PORT.toString(),
|
|
44
|
+
CHECKOUT_CLI_EXTENSIONS_SERVER_PORT: EXTENSIONS_SERVER_PORT.toString(),
|
|
45
|
+
},
|
|
46
|
+
shell: true,
|
|
47
|
+
});
|
|
48
|
+
child.on('close', (code) => {
|
|
49
|
+
debug(`Next.js server exited with code: ${code}`);
|
|
50
|
+
});
|
|
51
|
+
};
|
|
52
|
+
export class Dev extends Command {
|
|
53
|
+
static args = {};
|
|
54
|
+
static description = 'Run checkout in development mode';
|
|
55
|
+
static examples = [];
|
|
56
|
+
static flags = {};
|
|
14
57
|
async run() {
|
|
15
|
-
const {
|
|
16
|
-
const
|
|
17
|
-
|
|
18
|
-
if (args.file && flags.force) {
|
|
19
|
-
this.log(`you input --force and --file: ${args.file}`);
|
|
20
|
-
}
|
|
58
|
+
const storeInfo = { accountName: 'vtexgame1' };
|
|
59
|
+
const { checkoutTmpFolder } = await createTempFolder(storeInfo);
|
|
60
|
+
await createExtensionsServer({ ...storeInfo, checkoutTmpFolder });
|
|
21
61
|
}
|
|
22
62
|
}
|
|
23
63
|
//# sourceMappingURL=dev.js.map
|
package/dist/commands/dev.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"dev.js","sourceRoot":"","sources":["../../src/commands/dev.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"dev.js","sourceRoot":"","sources":["../../src/commands/dev.ts"],"names":[],"mappings":"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"}
|
package/eslintrc.json
ADDED
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
{
|
|
2
|
+
"extends": ["../../../.eslintrc.json"],
|
|
3
|
+
"ignorePatterns": ["!**/*"],
|
|
4
|
+
"overrides": [
|
|
5
|
+
{
|
|
6
|
+
"files": ["*.ts", "*.tsx", "*.js", "*.jsx"],
|
|
7
|
+
"rules": {}
|
|
8
|
+
},
|
|
9
|
+
{
|
|
10
|
+
"files": ["*.ts", "*.tsx"],
|
|
11
|
+
"rules": {}
|
|
12
|
+
},
|
|
13
|
+
{
|
|
14
|
+
"files": ["*.js", "*.jsx"],
|
|
15
|
+
"rules": {}
|
|
16
|
+
}
|
|
17
|
+
]
|
|
18
|
+
}
|
package/package.json
CHANGED
|
@@ -1,18 +1,21 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@vtex/checkout",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.6",
|
|
4
4
|
"author": "VTEX",
|
|
5
5
|
"bin": {
|
|
6
6
|
"checkout": "./bin/run.js"
|
|
7
7
|
},
|
|
8
8
|
"dependencies": {
|
|
9
9
|
"@oclif/core": "^4",
|
|
10
|
-
"@oclif/plugin-help": "^6"
|
|
10
|
+
"@oclif/plugin-help": "^6",
|
|
11
|
+
"express": "^4.19.2",
|
|
12
|
+
"get-port": "^7.1.0",
|
|
13
|
+
"http-proxy-middleware": "^3.0.0",
|
|
14
|
+
"oclif": "^4"
|
|
11
15
|
},
|
|
12
16
|
"engines": {
|
|
13
17
|
"node": ">=18.0.0"
|
|
14
18
|
},
|
|
15
|
-
"homepage": "https://github.com/libs/extensions-cli",
|
|
16
19
|
"license": "MIT",
|
|
17
20
|
"main": "dist/index.js",
|
|
18
21
|
"type": "module",
|
|
@@ -29,6 +32,8 @@
|
|
|
29
32
|
],
|
|
30
33
|
"topicSeparator": " "
|
|
31
34
|
},
|
|
32
|
-
"scripts": {
|
|
35
|
+
"scripts": {
|
|
36
|
+
"cli": "./bin/dev.js"
|
|
37
|
+
},
|
|
33
38
|
"types": "dist/index.d.ts"
|
|
34
39
|
}
|
package/src/commands/dev.ts
CHANGED
|
@@ -1,30 +1,101 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { Command } from '@oclif/core';
|
|
2
|
+
import getPort from 'get-port';
|
|
3
|
+
import express from 'express';
|
|
4
|
+
import path from 'path';
|
|
5
|
+
import fs from 'fs/promises';
|
|
6
|
+
import { existsSync } from 'fs';
|
|
7
|
+
import { spawn } from 'child_process';
|
|
2
8
|
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
9
|
+
type BaseProps = {
|
|
10
|
+
accountName: string;
|
|
11
|
+
};
|
|
12
|
+
|
|
13
|
+
type TmpFolderFields = {
|
|
14
|
+
checkoutTmpFolder: string;
|
|
15
|
+
};
|
|
7
16
|
|
|
8
|
-
|
|
17
|
+
type CreateExtensionsServer = BaseProps & TmpFolderFields;
|
|
18
|
+
|
|
19
|
+
const CORE_PATH = path.resolve('node_modules', '@vtex', 'checkout', '.next');
|
|
20
|
+
const CHECKOUT_PORT = 4301;
|
|
21
|
+
const IS_VERBOSE = process.env.CHECKOUT_CLI_VERBOSE === 'true';
|
|
22
|
+
|
|
23
|
+
const debug = (...args: any[]) => {
|
|
24
|
+
if (IS_VERBOSE) {
|
|
25
|
+
console.log(...args);
|
|
26
|
+
}
|
|
27
|
+
};
|
|
9
28
|
|
|
10
|
-
|
|
29
|
+
const createTempFolder = async ({
|
|
30
|
+
accountName,
|
|
31
|
+
}: BaseProps): Promise<TmpFolderFields> => {
|
|
32
|
+
const tmpFolder = path.resolve(accountName, 'checkout', '.tmp');
|
|
33
|
+
const checkoutTmpFolder = path.resolve(tmpFolder, '.next');
|
|
11
34
|
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
35
|
+
if (existsSync(tmpFolder)) {
|
|
36
|
+
await fs.rm(tmpFolder, { recursive: true, force: true });
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
await fs.mkdir(tmpFolder);
|
|
40
|
+
await fs.cp(CORE_PATH, checkoutTmpFolder, { recursive: true });
|
|
41
|
+
|
|
42
|
+
return {
|
|
43
|
+
checkoutTmpFolder,
|
|
17
44
|
};
|
|
45
|
+
};
|
|
46
|
+
|
|
47
|
+
const createExtensionsServer = async ({
|
|
48
|
+
accountName,
|
|
49
|
+
checkoutTmpFolder,
|
|
50
|
+
}: CreateExtensionsServer) => {
|
|
51
|
+
const app = express();
|
|
52
|
+
|
|
53
|
+
app.get('/extensions-config', (_, res) =>
|
|
54
|
+
res.json({
|
|
55
|
+
accountName,
|
|
56
|
+
// TODO: Change after creating the static server using CLI
|
|
57
|
+
staticServer: 'http://localhost:4302',
|
|
58
|
+
})
|
|
59
|
+
);
|
|
60
|
+
|
|
61
|
+
const EXTENSIONS_SERVER_PORT = await getPort();
|
|
62
|
+
|
|
63
|
+
app.listen(EXTENSIONS_SERVER_PORT, () => {
|
|
64
|
+
debug(`Checkout running at htt://localhost:${EXTENSIONS_SERVER_PORT}`);
|
|
65
|
+
});
|
|
66
|
+
|
|
67
|
+
const checkoutServer = path.resolve(
|
|
68
|
+
checkoutTmpFolder,
|
|
69
|
+
'standalone',
|
|
70
|
+
'server.js'
|
|
71
|
+
);
|
|
72
|
+
|
|
73
|
+
const child = spawn(process.execPath, [checkoutServer], {
|
|
74
|
+
stdio: IS_VERBOSE ? 'inherit' : 'ignore',
|
|
75
|
+
env: {
|
|
76
|
+
PORT: CHECKOUT_PORT.toString(),
|
|
77
|
+
CHECKOUT_CLI_EXTENSIONS_SERVER_PORT: EXTENSIONS_SERVER_PORT.toString(),
|
|
78
|
+
},
|
|
79
|
+
shell: true,
|
|
80
|
+
});
|
|
81
|
+
|
|
82
|
+
child.on('close', (code) => {
|
|
83
|
+
debug(`Next.js server exited with code: ${code}`);
|
|
84
|
+
});
|
|
85
|
+
};
|
|
86
|
+
|
|
87
|
+
export class Dev extends Command {
|
|
88
|
+
static override args = {};
|
|
89
|
+
|
|
90
|
+
static override description = 'Run checkout in development mode';
|
|
91
|
+
|
|
92
|
+
static override examples = [];
|
|
93
|
+
|
|
94
|
+
static override flags = {};
|
|
18
95
|
|
|
19
96
|
public async run(): Promise<void> {
|
|
20
|
-
const {
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
this.log(
|
|
24
|
-
`hello ${name} from /Users/marcosoliveira/projects/vtex/fastcheckout/packages/libs/extensions/src/commands/dev.ts test2`
|
|
25
|
-
);
|
|
26
|
-
if (args.file && flags.force) {
|
|
27
|
-
this.log(`you input --force and --file: ${args.file}`);
|
|
28
|
-
}
|
|
97
|
+
const storeInfo = { accountName: 'vtexgame1' };
|
|
98
|
+
const { checkoutTmpFolder } = await createTempFolder(storeInfo);
|
|
99
|
+
await createExtensionsServer({ ...storeInfo, checkoutTmpFolder });
|
|
29
100
|
}
|
|
30
101
|
}
|
package/.next/BUILD_ID
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
qX6JDFFRlMB8TltGpbcXL
|