@vtex/checkout 0.0.8 → 0.0.10
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/.next/BUILD_ID +1 -1
- package/.next/app.js +1 -1
- package/.next/build-manifest.json +26 -26
- package/.next/cache/config.json +3 -3
- package/.next/cache/webpack/client-production/0.pack +0 -0
- package/.next/cache/webpack/client-production/index.pack +0 -0
- package/.next/cache/webpack/edge-server-production/index.pack +0 -0
- package/.next/cache/webpack/server-production/0.pack +0 -0
- package/.next/cache/webpack/server-production/index.pack +0 -0
- package/.next/prerender-manifest.json +1 -1
- package/.next/server/chunks/400.js +1 -1
- package/.next/server/middleware-build-manifest.js +1 -1
- package/.next/server/pages/404.html +1 -1
- package/.next/server/pages/500.html +1 -1
- package/.next/server/pages/cart.html +1 -1
- package/.next/server/pages/error.html +1 -1
- package/.next/server/pages/index.html +1 -1
- package/.next/server/pages/information.html +1 -1
- package/.next/server/pages/order-placed.html +1 -1
- package/.next/server/pages/payment.html +1 -1
- package/.next/server/pages/review.html +1 -1
- package/.next/server/pages/shipping.html +1 -1
- package/.next/standalone/.next/BUILD_ID +1 -1
- package/.next/standalone/.next/build-manifest.json +26 -26
- package/.next/standalone/.next/prerender-manifest.json +1 -1
- package/.next/standalone/.next/server/chunks/400.js +1 -1
- package/.next/standalone/.next/server/middleware-build-manifest.js +1 -1
- package/.next/standalone/.next/server/pages/404.html +1 -1
- package/.next/standalone/.next/server/pages/500.html +1 -1
- package/.next/standalone/.next/server/pages/cart.html +1 -1
- package/.next/standalone/.next/server/pages/error.html +1 -1
- package/.next/standalone/.next/server/pages/index.html +1 -1
- package/.next/standalone/.next/server/pages/information.html +1 -1
- package/.next/standalone/.next/server/pages/order-placed.html +1 -1
- package/.next/standalone/.next/server/pages/payment.html +1 -1
- package/.next/standalone/.next/server/pages/review.html +1 -1
- package/.next/standalone/.next/server/pages/shipping.html +1 -1
- package/.next/standalone/.next/static/{d3rnv_PTmize_AfdZT0mQ → D39HhaRdycmVapGyJTwER}/_buildManifest.js +1 -1
- package/.next/standalone/.next/static/chunks/main-e2254fa47db149d4.js +57 -0
- package/.next/standalone/.next/static/chunks/mf-manifest.json +32 -32
- package/.next/standalone/.next/static/chunks/mf-stats.json +32 -32
- package/.next/standalone/.next/static/chunks/pages/{_app-9f47f29ca781c0d2.js → _app-5614585568072a7b.js} +4 -4
- package/.next/standalone/.next/static/chunks/pages/order-placed-bc02732f16535ebb.js +1 -0
- package/.next/standalone/.next/static/chunks/polyfills-42372ed130431b0a.js +1 -0
- package/.next/standalone/.next/static/chunks/{webpack-9611ecf3bafb6ec9.js → webpack-a9c09a4cddf677b4.js} +1 -1
- package/.next/standalone/.next/static/css/{33cd250a1c4a6bb2.css → 6f48a3a477d7e03e.css} +1 -1
- package/.next/standalone/package.json +2 -2
- package/.next/trace +275 -272
- package/README.md +8 -29
- package/dist/commands/build.d.ts +9 -5
- package/dist/commands/build.js +26 -15
- package/dist/commands/build.js.map +1 -1
- package/dist/commands/create.d.ts +10 -0
- package/dist/commands/create.js +34 -0
- package/dist/commands/create.js.map +1 -0
- package/dist/commands/dev.d.ts +11 -2
- package/dist/commands/dev.js +55 -100
- package/dist/commands/dev.js.map +1 -1
- package/dist/commands/index.d.ts +1 -1
- package/dist/commands/index.js +1 -1
- package/dist/commands/index.js.map +1 -1
- package/dist/index.d.ts +2 -2
- package/dist/index.js +2 -2
- package/dist/index.js.map +1 -1
- package/dist/lib/bundler.d.ts +14 -0
- package/dist/lib/bundler.js +120 -0
- package/dist/lib/bundler.js.map +1 -0
- package/dist/lib/constants.d.ts +3 -2
- package/dist/lib/constants.js +3 -2
- package/dist/lib/constants.js.map +1 -1
- package/dist/lib/logger.d.ts +5 -0
- package/dist/lib/logger.js +12 -0
- package/dist/lib/logger.js.map +1 -0
- package/package.json +8 -5
- package/scripts/set-as-pristine.sh +2 -0
- package/template/package.template.json +11 -0
- package/template/src/HelloWorld.tsx +12 -0
- package/template/src/hello-world.css +6 -0
- package/template/src/index.tsx +6 -0
- package/template/tsconfig.json +18 -0
- package/.next/standalone/.next/static/chunks/main-0a2b108d0f6b9d42.js +0 -57
- package/.next/standalone/.next/static/chunks/pages/order-placed-19c94f6f42e62dae.js +0 -1
- package/.next/standalone/.next/static/chunks/polyfills-78c92fac7aa8fdd8.js +0 -1
- package/dist/commands/init.d.ts +0 -13
- package/dist/commands/init.js +0 -23
- package/dist/commands/init.js.map +0 -1
- /package/.next/standalone/.next/static/{d3rnv_PTmize_AfdZT0mQ → D39HhaRdycmVapGyJTwER}/_ssgManifest.js +0 -0
package/README.md
CHANGED
|
@@ -1,31 +1,10 @@
|
|
|
1
|
-
|
|
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
|
-
|
|
1
|
+
# @vtex/checkout 🛒
|
|
30
2
|
|
|
3
|
+
This package provides the utility types, hooks, and tools needed to build extensions for VTEX's Checkout. In summary, this package allows you to:
|
|
4
|
+
- Start a Checkout extension project from scratch;
|
|
5
|
+
- Set up your development environment with live preview for the extensions you're building;
|
|
6
|
+
- Access the utility types, hooks, and tools to create custom extensions;
|
|
7
|
+
- Configure a Checkout extension project from start to production deployment.
|
|
31
8
|
|
|
9
|
+
## License ⚖️
|
|
10
|
+
MIT
|
package/dist/commands/build.d.ts
CHANGED
|
@@ -1,13 +1,17 @@
|
|
|
1
1
|
import { Command } from '@oclif/core';
|
|
2
2
|
export declare class Build extends Command {
|
|
3
3
|
static args: {
|
|
4
|
-
|
|
4
|
+
path: import("@oclif/core/interfaces").Arg<string, Record<string, unknown>>;
|
|
5
5
|
};
|
|
6
6
|
static description: string;
|
|
7
7
|
static examples: string[];
|
|
8
|
-
static flags: {
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
8
|
+
static flags: {};
|
|
9
|
+
/**
|
|
10
|
+
* TODO: Currently, we're getting PATH via CLI arguments.
|
|
11
|
+
* However, this information will later come from
|
|
12
|
+
* the FastStore CLI when the developer runs a command like:
|
|
13
|
+
* faststore build <account-name>. The remaining information will be
|
|
14
|
+
* sourced from the faststore.config.json file.
|
|
15
|
+
*/
|
|
12
16
|
run(): Promise<void>;
|
|
13
17
|
}
|
package/dist/commands/build.js
CHANGED
|
@@ -1,23 +1,34 @@
|
|
|
1
|
-
import { Args, Command
|
|
1
|
+
import { Args, Command } from '@oclif/core';
|
|
2
|
+
import path from 'path';
|
|
3
|
+
import { bundle, compileTs } from '../lib/bundler.js';
|
|
4
|
+
import { logger } from '../lib/logger.js';
|
|
2
5
|
export class Build extends Command {
|
|
3
6
|
static args = {
|
|
4
|
-
|
|
7
|
+
path: Args.string({
|
|
8
|
+
description: 'The path where the extensions are located.',
|
|
9
|
+
required: true,
|
|
10
|
+
}),
|
|
5
11
|
};
|
|
6
|
-
static description = '
|
|
12
|
+
static description = 'Build extensions for production deployment.';
|
|
7
13
|
static examples = ['<%= config.bin %> <%= command.id %>'];
|
|
8
|
-
static flags = {
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
+
static flags = {};
|
|
15
|
+
/**
|
|
16
|
+
* TODO: Currently, we're getting PATH via CLI arguments.
|
|
17
|
+
* However, this information will later come from
|
|
18
|
+
* the FastStore CLI when the developer runs a command like:
|
|
19
|
+
* faststore build <account-name>. The remaining information will be
|
|
20
|
+
* sourced from the faststore.config.json file.
|
|
21
|
+
*/
|
|
14
22
|
async run() {
|
|
15
|
-
const { args
|
|
16
|
-
const
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
23
|
+
const { args } = await this.parse(Build);
|
|
24
|
+
const projectPath = path.resolve(args.path);
|
|
25
|
+
logger.info('1. 🔎 Looking for type errors with TypeScript.');
|
|
26
|
+
compileTs({ path: projectPath });
|
|
27
|
+
logger.info('2. 📦 Building extensions for production deployment.');
|
|
28
|
+
bundle({
|
|
29
|
+
mode: 'production',
|
|
30
|
+
path: projectPath,
|
|
31
|
+
});
|
|
21
32
|
}
|
|
22
33
|
}
|
|
23
34
|
//# sourceMappingURL=build.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"build.js","sourceRoot":"","sources":["../../src/commands/build.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"build.js","sourceRoot":"","sources":["../../src/commands/build.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,OAAO,EAAE,MAAM,aAAa,CAAC;AAC5C,OAAO,IAAI,MAAM,MAAM,CAAC;AACxB,OAAO,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,mBAAmB,CAAC;AACtD,OAAO,EAAE,MAAM,EAAE,MAAM,kBAAkB,CAAC;AAE1C,MAAM,OAAO,KAAM,SAAQ,OAAO;IAChC,MAAM,CAAU,IAAI,GAAG;QACrB,IAAI,EAAE,IAAI,CAAC,MAAM,CAAC;YAChB,WAAW,EAAE,4CAA4C;YACzD,QAAQ,EAAE,IAAI;SACf,CAAC;KACH,CAAC;IAEF,MAAM,CAAU,WAAW,GAAG,6CAA6C,CAAC;IAE5E,MAAM,CAAU,QAAQ,GAAG,CAAC,qCAAqC,CAAC,CAAC;IAEnE,MAAM,CAAU,KAAK,GAAG,EAAE,CAAC;IAC3B;;;;;;OAMG;IACI,KAAK,CAAC,GAAG;QACd,MAAM,EAAE,IAAI,EAAE,GAAG,MAAM,IAAI,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC;QACzC,MAAM,WAAW,GAAG,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;QAE5C,MAAM,CAAC,IAAI,CAAC,gDAAgD,CAAC,CAAC;QAC9D,SAAS,CAAC,EAAE,IAAI,EAAE,WAAW,EAAE,CAAC,CAAC;QAEjC,MAAM,CAAC,IAAI,CAAC,uDAAuD,CAAC,CAAC;QACrE,MAAM,CAAC;YACL,IAAI,EAAE,YAAY;YAClB,IAAI,EAAE,WAAW;SAClB,CAAC,CAAC;IACL,CAAC"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { Command } from '@oclif/core';
|
|
2
|
+
export declare class Create extends Command {
|
|
3
|
+
static args: {
|
|
4
|
+
path: import("@oclif/core/interfaces").Arg<string, Record<string, unknown>>;
|
|
5
|
+
};
|
|
6
|
+
static description: string;
|
|
7
|
+
static examples: string[];
|
|
8
|
+
static flags: {};
|
|
9
|
+
run(): Promise<void>;
|
|
10
|
+
}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import fs from 'fs/promises';
|
|
2
|
+
import { Args, Command } from '@oclif/core';
|
|
3
|
+
import path from 'path';
|
|
4
|
+
import { PACKAGE_JSON_TEMPLATE, TEMPLATE_PATH } from '../lib/constants.js';
|
|
5
|
+
export class Create extends Command {
|
|
6
|
+
static args = {
|
|
7
|
+
path: Args.string({
|
|
8
|
+
description: 'The path where the project will be initialized.',
|
|
9
|
+
required: true,
|
|
10
|
+
}),
|
|
11
|
+
};
|
|
12
|
+
static description = 'Initialize a new Checkout extensions project.';
|
|
13
|
+
static examples = ['<%= config.bin %> <%= command.id %>'];
|
|
14
|
+
static flags = {};
|
|
15
|
+
async run() {
|
|
16
|
+
const { args } = await this.parse(Create);
|
|
17
|
+
const projectPath = path.resolve(args.path);
|
|
18
|
+
const packageJsonTemplate = path.resolve(projectPath, PACKAGE_JSON_TEMPLATE);
|
|
19
|
+
try {
|
|
20
|
+
const packageJson = path.resolve(projectPath, 'package.json');
|
|
21
|
+
await fs.mkdir(projectPath, {
|
|
22
|
+
recursive: true,
|
|
23
|
+
});
|
|
24
|
+
await fs.cp(TEMPLATE_PATH, projectPath, {
|
|
25
|
+
recursive: true,
|
|
26
|
+
});
|
|
27
|
+
await fs.rename(packageJsonTemplate, packageJson);
|
|
28
|
+
}
|
|
29
|
+
catch (error) {
|
|
30
|
+
console.error('An error occurred while setting up your extensions project:', error);
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
//# sourceMappingURL=create.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"create.js","sourceRoot":"","sources":["../../src/commands/create.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,aAAa,CAAC;AAC7B,OAAO,EAAE,IAAI,EAAE,OAAO,EAAE,MAAM,aAAa,CAAC;AAC5C,OAAO,IAAI,MAAM,MAAM,CAAC;AACxB,OAAO,EAAE,qBAAqB,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAC;AAE3E,MAAM,OAAO,MAAO,SAAQ,OAAO;IACjC,MAAM,CAAU,IAAI,GAAG;QACrB,IAAI,EAAE,IAAI,CAAC,MAAM,CAAC;YAChB,WAAW,EAAE,iDAAiD;YAC9D,QAAQ,EAAE,IAAI;SACf,CAAC;KACH,CAAC;IAEF,MAAM,CAAU,WAAW,GAAG,+CAA+C,CAAC;IAE9E,MAAM,CAAU,QAAQ,GAAG,CAAC,qCAAqC,CAAC,CAAC;IAEnE,MAAM,CAAU,KAAK,GAAG,EAAE,CAAC;IAEpB,KAAK,CAAC,GAAG;QACd,MAAM,EAAE,IAAI,EAAE,GAAG,MAAM,IAAI,CAAC,KAAK,CAAC,MAAM,CAAC,CAAC;QAC1C,MAAM,WAAW,GAAG,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;QAC5C,MAAM,mBAAmB,GAAG,IAAI,CAAC,OAAO,CACtC,WAAW,EACX,qBAAqB,CACtB,CAAC;QACF,IAAI,CAAC;YACH,MAAM,WAAW,GAAG,IAAI,CAAC,OAAO,CAAC,WAAW,EAAE,cAAc,CAAC,CAAC;YAC9D,MAAM,EAAE,CAAC,KAAK,CAAC,WAAW,EAAE;gBAC1B,SAAS,EAAE,IAAI;aAChB,CAAC,CAAC;YACH,MAAM,EAAE,CAAC,EAAE,CAAC,aAAa,EAAE,WAAW,EAAE;gBACtC,SAAS,EAAE,IAAI;aAChB,CAAC,CAAC;YACH,MAAM,EAAE,CAAC,MAAM,CAAC,mBAAmB,EAAE,WAAW,CAAC,CAAC;QACpD,CAAC;QAAC,OAAO,KAAK,EAAE,CAAC;YACf,OAAO,CAAC,KAAK,CACX,6DAA6D,EAC7D,KAAK,CACN,CAAC;QACJ,CAAC;IACH,CAAC"}
|
package/dist/commands/dev.d.ts
CHANGED
|
@@ -1,8 +1,17 @@
|
|
|
1
1
|
import { Command } from '@oclif/core';
|
|
2
2
|
export declare class Dev extends Command {
|
|
3
|
-
static args: {
|
|
3
|
+
static args: {
|
|
4
|
+
path: import("@oclif/core/interfaces").Arg<string, Record<string, unknown>>;
|
|
5
|
+
accountName: import("@oclif/core/interfaces").Arg<string, Record<string, unknown>>;
|
|
6
|
+
};
|
|
4
7
|
static description: string;
|
|
5
8
|
static examples: never[];
|
|
6
9
|
static flags: {};
|
|
7
|
-
|
|
10
|
+
/**
|
|
11
|
+
* TODO: Currently, we're getting PATH, ACCOUNT_NAME, and PORT
|
|
12
|
+
* via CLI arguments. However, this information will later come from
|
|
13
|
+
* the FastStore CLI when the developer runs a command like:
|
|
14
|
+
* faststore dev <account-name>. The remaining information will be
|
|
15
|
+
* sourced from the faststore.config.json file.
|
|
16
|
+
*/ run(): Promise<void>;
|
|
8
17
|
}
|
package/dist/commands/dev.js
CHANGED
|
@@ -1,20 +1,16 @@
|
|
|
1
1
|
import getPort from 'get-port';
|
|
2
2
|
import express from 'express';
|
|
3
|
-
import
|
|
3
|
+
import cors from 'cors';
|
|
4
4
|
import fs from 'fs/promises';
|
|
5
5
|
import path from 'path';
|
|
6
6
|
import http from 'http';
|
|
7
7
|
import { WebSocket, WebSocketServer } from 'ws';
|
|
8
8
|
import { spawn, spawnSync } from 'child_process';
|
|
9
|
-
import { Command } from '@oclif/core';
|
|
10
|
-
import
|
|
11
|
-
import {
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
if (IS_DEBUGGING) {
|
|
15
|
-
console.log('[CHECKOUT]', ...args);
|
|
16
|
-
}
|
|
17
|
-
};
|
|
9
|
+
import { Command, Args } from '@oclif/core';
|
|
10
|
+
import { IS_DEBUGGING, CORE_PATH, STANDALONE_PATH, CHECKOUTRC_PATH, STATIC_TMP_FOLDER, } from '../lib/constants.js';
|
|
11
|
+
import { createProxyMiddleware } from 'http-proxy-middleware';
|
|
12
|
+
import { bundle } from '../lib/bundler.js';
|
|
13
|
+
import { logger } from '../lib/logger.js';
|
|
18
14
|
const isCorePristine = async () => {
|
|
19
15
|
const content = await fs.readFile(CHECKOUTRC_PATH);
|
|
20
16
|
return content.toString().trim() === 'pristine';
|
|
@@ -32,7 +28,8 @@ const setupCheckoutCore = async () => {
|
|
|
32
28
|
const isPristine = await isCorePristine();
|
|
33
29
|
if (isPristine) {
|
|
34
30
|
const packageManager = getPackageManager();
|
|
35
|
-
|
|
31
|
+
logger.info('Installing internal dependencies, may take a while 🕑');
|
|
32
|
+
logger.debug('Installing dependencies using: ', packageManager);
|
|
36
33
|
spawnSync(packageManager, {
|
|
37
34
|
cwd: STANDALONE_PATH,
|
|
38
35
|
shell: true,
|
|
@@ -41,113 +38,53 @@ const setupCheckoutCore = async () => {
|
|
|
41
38
|
await fs.writeFile(CHECKOUTRC_PATH, 'updated');
|
|
42
39
|
}
|
|
43
40
|
};
|
|
44
|
-
const
|
|
45
|
-
const compiler = webpack({
|
|
46
|
-
infrastructureLogging: {
|
|
47
|
-
level: 'none',
|
|
48
|
-
},
|
|
49
|
-
stats: 'none',
|
|
50
|
-
context: checkoutPath,
|
|
51
|
-
entry: './src/index.tsx',
|
|
52
|
-
target: 'web',
|
|
53
|
-
mode: 'development',
|
|
54
|
-
output: {
|
|
55
|
-
publicPath: 'auto',
|
|
56
|
-
path: path.resolve(checkoutPath, STATIC_TMP_FOLDER),
|
|
57
|
-
},
|
|
58
|
-
resolve: {
|
|
59
|
-
extensions: ['.tsx', '.ts', '.js'],
|
|
60
|
-
},
|
|
61
|
-
module: {
|
|
62
|
-
rules: [
|
|
63
|
-
{
|
|
64
|
-
test: /\.(ts|tsx)$/,
|
|
65
|
-
loader: 'babel-loader',
|
|
66
|
-
exclude: /node_modules/,
|
|
67
|
-
options: {
|
|
68
|
-
presets: [
|
|
69
|
-
'@babel/preset-env',
|
|
70
|
-
['@babel/preset-react', { runtime: 'automatic' }],
|
|
71
|
-
'@babel/preset-typescript',
|
|
72
|
-
],
|
|
73
|
-
},
|
|
74
|
-
},
|
|
75
|
-
{
|
|
76
|
-
test: /\.css$/i,
|
|
77
|
-
use: ['style-loader', 'css-loader'],
|
|
78
|
-
},
|
|
79
|
-
],
|
|
80
|
-
},
|
|
81
|
-
plugins: [
|
|
82
|
-
new ModuleFederationPlugin({
|
|
83
|
-
name: 'extensions',
|
|
84
|
-
library: { type: 'var', name: 'extensions' },
|
|
85
|
-
filename: 'fastcheckout-extensions.js',
|
|
86
|
-
exposes: {
|
|
87
|
-
'./components': './src/index.tsx',
|
|
88
|
-
},
|
|
89
|
-
shared: {
|
|
90
|
-
react: {
|
|
91
|
-
import: 'react',
|
|
92
|
-
shareKey: 'react',
|
|
93
|
-
shareScope: 'default',
|
|
94
|
-
singleton: true,
|
|
95
|
-
requiredVersion: '^18',
|
|
96
|
-
},
|
|
97
|
-
'react/jsx-runtime': {
|
|
98
|
-
singleton: true,
|
|
99
|
-
requiredVersion: '^18',
|
|
100
|
-
},
|
|
101
|
-
'react-dom': {
|
|
102
|
-
singleton: true,
|
|
103
|
-
requiredVersion: '^18',
|
|
104
|
-
},
|
|
105
|
-
},
|
|
106
|
-
}),
|
|
107
|
-
],
|
|
108
|
-
});
|
|
109
|
-
compiler.watch({}, (err) => {
|
|
110
|
-
if (err) {
|
|
111
|
-
debug(err);
|
|
112
|
-
return;
|
|
113
|
-
}
|
|
114
|
-
onFileChange();
|
|
115
|
-
});
|
|
116
|
-
};
|
|
117
|
-
const createExtensionsServer = async ({ accountName, path: checkoutPath, }) => {
|
|
41
|
+
const createExtensionsServer = async ({ port, accountName, path: checkoutPath, }) => {
|
|
118
42
|
const app = express();
|
|
43
|
+
app.use(cors({
|
|
44
|
+
origin: `http://localhost:${port}`,
|
|
45
|
+
credentials: true,
|
|
46
|
+
}));
|
|
119
47
|
const server = http.createServer(app);
|
|
120
48
|
const wss = new WebSocketServer({ server });
|
|
121
49
|
const EXTENSIONS_SERVER_PORT = await getPort();
|
|
122
50
|
const clients = new Set();
|
|
123
51
|
wss.on('connection', (ws) => {
|
|
124
|
-
debug('New WS client connected');
|
|
52
|
+
logger.debug('New WS client connected');
|
|
125
53
|
clients.add(ws);
|
|
126
54
|
ws.on('close', () => {
|
|
127
|
-
debug('Client disconnected');
|
|
55
|
+
logger.debug('Client disconnected');
|
|
128
56
|
clients.delete(ws);
|
|
129
57
|
});
|
|
130
58
|
});
|
|
131
59
|
app.get('/extensions-config', (_, res) => res.json({
|
|
132
60
|
accountName,
|
|
133
|
-
|
|
134
|
-
|
|
61
|
+
extensionsServerPort: EXTENSIONS_SERVER_PORT,
|
|
62
|
+
}));
|
|
63
|
+
app.post('/graphql', createProxyMiddleware({
|
|
64
|
+
target: `https://${accountName}.vtexcommercestable.com.br/api/checkout-bff/graphql`,
|
|
65
|
+
changeOrigin: true,
|
|
66
|
+
cookieDomainRewrite: 'localhost',
|
|
67
|
+
cookiePathRewrite: '/',
|
|
68
|
+
pathRewrite: {
|
|
69
|
+
'^/graphql': '',
|
|
70
|
+
},
|
|
71
|
+
...(IS_DEBUGGING && { logger: console }),
|
|
135
72
|
}));
|
|
136
73
|
app.use('/assets', express.static(path.resolve(checkoutPath, STATIC_TMP_FOLDER)));
|
|
137
74
|
server.listen(EXTENSIONS_SERVER_PORT, () => {
|
|
138
|
-
debug(`Extensions server running at http://localhost:${EXTENSIONS_SERVER_PORT} `);
|
|
75
|
+
logger.debug(`Extensions server running at http://localhost:${EXTENSIONS_SERVER_PORT} `);
|
|
139
76
|
});
|
|
140
77
|
const checkoutServer = path.resolve(CORE_PATH, 'standalone', 'server.js');
|
|
141
78
|
const child = spawn(process.execPath, [checkoutServer], {
|
|
142
79
|
stdio: IS_DEBUGGING ? 'inherit' : 'ignore',
|
|
143
80
|
env: {
|
|
144
|
-
PORT:
|
|
81
|
+
PORT: port,
|
|
145
82
|
CHECKOUT_CLI_EXTENSIONS_SERVER_PORT: EXTENSIONS_SERVER_PORT.toString(),
|
|
146
83
|
},
|
|
147
84
|
shell: true,
|
|
148
85
|
});
|
|
149
86
|
child.on('close', (code) => {
|
|
150
|
-
debug(`Next.js server exited with code: ${code}`);
|
|
87
|
+
logger.debug(`Next.js server exited with code: ${code}`);
|
|
151
88
|
});
|
|
152
89
|
return {
|
|
153
90
|
emit: () => {
|
|
@@ -159,22 +96,40 @@ const createExtensionsServer = async ({ accountName, path: checkoutPath, }) => {
|
|
|
159
96
|
};
|
|
160
97
|
};
|
|
161
98
|
export class Dev extends Command {
|
|
162
|
-
static args = {
|
|
99
|
+
static args = {
|
|
100
|
+
path: Args.string({
|
|
101
|
+
description: 'The path where the extensions are located.',
|
|
102
|
+
required: true,
|
|
103
|
+
}),
|
|
104
|
+
accountName: Args.string({
|
|
105
|
+
description: 'The account name of the store.',
|
|
106
|
+
required: true,
|
|
107
|
+
}),
|
|
108
|
+
};
|
|
163
109
|
static description = 'Run checkout in development mode';
|
|
164
110
|
static examples = [];
|
|
165
111
|
static flags = {};
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
112
|
+
/**
|
|
113
|
+
* TODO: Currently, we're getting PATH, ACCOUNT_NAME, and PORT
|
|
114
|
+
* via CLI arguments. However, this information will later come from
|
|
115
|
+
* the FastStore CLI when the developer runs a command like:
|
|
116
|
+
* faststore dev <account-name>. The remaining information will be
|
|
117
|
+
* sourced from the faststore.config.json file.
|
|
118
|
+
*/ async run() {
|
|
119
|
+
const CHECKOUT_PORT = '4301';
|
|
120
|
+
const { args } = await this.parse(Dev);
|
|
121
|
+
const checkoutPath = path.resolve(args.path);
|
|
169
122
|
await setupCheckoutCore();
|
|
170
123
|
const extensionsServer = await createExtensionsServer({
|
|
171
|
-
|
|
124
|
+
port: CHECKOUT_PORT,
|
|
125
|
+
accountName: args.accountName,
|
|
172
126
|
path: checkoutPath,
|
|
173
127
|
});
|
|
174
|
-
|
|
128
|
+
bundle({
|
|
129
|
+
mode: 'development',
|
|
175
130
|
path: checkoutPath,
|
|
176
|
-
|
|
177
|
-
debug('Reloading Checkout UI');
|
|
131
|
+
onChange: () => {
|
|
132
|
+
logger.debug('Reloading Checkout UI');
|
|
178
133
|
extensionsServer.emit('reload');
|
|
179
134
|
},
|
|
180
135
|
});
|
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,OAAO,MAAM,UAAU,CAAC;AAC/B,OAAO,OAAO,MAA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AgB,GAAG,MAAM,sBAAsB,CAAC;YACpD,IAAI,EAAE,aAAa;YACnB,WAAW,EAAE,IAAI,CAAC,WAAW;YAC7B,IAAI,EAAE,YAAY;SACnB,CAAC,CAAC;QAEH,MAAM,CAAC;YACL,IAAI,EAAE,aAAa;YACnB,IAAI,EAAE,YAAY;YAClB,QAAQ,EAAE,GAAG,EAAE;gBACb,MAAM,CAAC,KAAK,CAAC,uBAAuB,CAAC,CAAC;gBACtC,gBAAgB,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC;YAClC,CAAC;SACF,CAAC,CAAC;IACL,CAAC"}
|
package/dist/commands/index.d.ts
CHANGED
package/dist/commands/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/commands/index.ts"],"names":[],"mappings":"AAAA,cAAc,UAAU,CAAC;AACzB,cAAc,YAAY,CAAC;AAC3B,cAAc,
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/commands/index.ts"],"names":[],"mappings":"AAAA,cAAc,UAAU,CAAC;AACzB,cAAc,YAAY,CAAC;AAC3B,cAAc,aAAa,CAAC"}
|
package/dist/index.d.ts
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
export { run } from '@oclif/core';
|
|
2
2
|
export * from './types.js';
|
|
3
3
|
import * as hooks_ from './hooks/index.js';
|
|
4
|
-
import { Dev as dev, Build as build,
|
|
4
|
+
import { Dev as dev, Build as build, Create as create } from './commands/index.js';
|
|
5
5
|
export declare const hooks: typeof hooks_;
|
|
6
6
|
export declare const commands: {
|
|
7
7
|
dev: typeof dev;
|
|
8
8
|
build: typeof build;
|
|
9
|
-
|
|
9
|
+
create: typeof create;
|
|
10
10
|
};
|
package/dist/index.js
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
export { run } from '@oclif/core';
|
|
2
2
|
export * from './types.js';
|
|
3
3
|
import * as hooks_ from './hooks/index.js';
|
|
4
|
-
import { Dev as dev, Build as build,
|
|
4
|
+
import { Dev as dev, Build as build, Create as create, } from './commands/index.js';
|
|
5
5
|
export const hooks = hooks_;
|
|
6
6
|
export const commands = {
|
|
7
7
|
dev,
|
|
8
8
|
build,
|
|
9
|
-
|
|
9
|
+
create,
|
|
10
10
|
};
|
|
11
11
|
//# sourceMappingURL=index.js.map
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,GAAG,EAAE,MAAM,aAAa,CAAC;AAClC,cAAc,YAAY,CAAC;AAE3B,OAAO,KAAK,MAAM,MAAM,kBAAkB,CAAC;AAE3C,OAAO,
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,GAAG,EAAE,MAAM,aAAa,CAAC;AAClC,cAAc,YAAY,CAAC;AAE3B,OAAO,KAAK,MAAM,MAAM,kBAAkB,CAAC;AAE3C,OAAO,EACL,GAAG,IAAI,GAAG,EACV,KAAK,IAAI,KAAK,EACd,MAAM,IAAI,MAAM,GACjB,MAAM,qBAAqB,CAAC;AAE7B,MAAM,CAAC,MAAM,KAAK,GAAG,MAAM,CAAC;AAE5B,MAAM,CAAC,MAAM,QAAQ,GAAG;IACtB,GAAG;IACH,KAAK;IACL,MAAM;CACP,CAAC"}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
type TsCompilerParams = {
|
|
2
|
+
path: string;
|
|
3
|
+
};
|
|
4
|
+
type BundleParams = {
|
|
5
|
+
mode: 'development';
|
|
6
|
+
path: string;
|
|
7
|
+
onChange: () => void;
|
|
8
|
+
} | {
|
|
9
|
+
mode: 'production';
|
|
10
|
+
path: string;
|
|
11
|
+
};
|
|
12
|
+
export declare const bundle: (config: BundleParams) => void;
|
|
13
|
+
export declare const compileTs: ({ path: projectPath }: TsCompilerParams) => void;
|
|
14
|
+
export {};
|
|
@@ -0,0 +1,120 @@
|
|
|
1
|
+
import path from 'path';
|
|
2
|
+
import ModuleFederation from '@module-federation/enhanced';
|
|
3
|
+
import webpack from 'webpack';
|
|
4
|
+
import { STATIC_TMP_FOLDER } from './constants.js';
|
|
5
|
+
import { logger } from './logger.js';
|
|
6
|
+
import { spawnSync } from 'child_process';
|
|
7
|
+
const ModuleFederationPlugin = ModuleFederation.ModuleFederationPlugin;
|
|
8
|
+
const logStats = (stats) => {
|
|
9
|
+
const statsMessage = stats.toString({
|
|
10
|
+
all: false,
|
|
11
|
+
errors: true,
|
|
12
|
+
warnings: true,
|
|
13
|
+
colors: true,
|
|
14
|
+
});
|
|
15
|
+
if (statsMessage)
|
|
16
|
+
logger.info(statsMessage);
|
|
17
|
+
if (stats.hasErrors())
|
|
18
|
+
logger.error('❌ Build failed unexpectedly. Check the logs above.');
|
|
19
|
+
if (stats.hasWarnings())
|
|
20
|
+
logger.info('⚠️ Build completed with warnings.');
|
|
21
|
+
};
|
|
22
|
+
export const bundle = (config) => {
|
|
23
|
+
const { path: checkoutPath, mode } = config;
|
|
24
|
+
const compiler = webpack({
|
|
25
|
+
stats: 'verbose',
|
|
26
|
+
context: checkoutPath,
|
|
27
|
+
entry: './src/index.tsx',
|
|
28
|
+
target: 'web',
|
|
29
|
+
mode,
|
|
30
|
+
output: {
|
|
31
|
+
publicPath: 'auto',
|
|
32
|
+
path: path.resolve(checkoutPath, STATIC_TMP_FOLDER),
|
|
33
|
+
},
|
|
34
|
+
resolve: {
|
|
35
|
+
extensions: ['.tsx', '.ts', '.js'],
|
|
36
|
+
},
|
|
37
|
+
module: {
|
|
38
|
+
rules: [
|
|
39
|
+
{
|
|
40
|
+
test: /\.(ts|tsx)$/,
|
|
41
|
+
loader: 'babel-loader',
|
|
42
|
+
exclude: /node_modules/,
|
|
43
|
+
options: {
|
|
44
|
+
presets: [
|
|
45
|
+
'@babel/preset-env',
|
|
46
|
+
['@babel/preset-react', { runtime: 'automatic' }],
|
|
47
|
+
'@babel/preset-typescript',
|
|
48
|
+
],
|
|
49
|
+
},
|
|
50
|
+
},
|
|
51
|
+
{
|
|
52
|
+
test: /\.css$/i,
|
|
53
|
+
use: ['style-loader', 'css-loader'],
|
|
54
|
+
},
|
|
55
|
+
],
|
|
56
|
+
},
|
|
57
|
+
plugins: [
|
|
58
|
+
new ModuleFederationPlugin({
|
|
59
|
+
name: 'extensions',
|
|
60
|
+
library: { type: 'var', name: 'extensions' },
|
|
61
|
+
filename: 'fastcheckout-extensions.js',
|
|
62
|
+
exposes: {
|
|
63
|
+
'./components': './src/index.tsx',
|
|
64
|
+
},
|
|
65
|
+
shared: {
|
|
66
|
+
react: {
|
|
67
|
+
import: 'react',
|
|
68
|
+
shareKey: 'react',
|
|
69
|
+
shareScope: 'default',
|
|
70
|
+
singleton: true,
|
|
71
|
+
requiredVersion: '^18',
|
|
72
|
+
},
|
|
73
|
+
'react/jsx-runtime': {
|
|
74
|
+
singleton: true,
|
|
75
|
+
requiredVersion: '^18',
|
|
76
|
+
},
|
|
77
|
+
'react-dom': {
|
|
78
|
+
singleton: true,
|
|
79
|
+
requiredVersion: '^18',
|
|
80
|
+
},
|
|
81
|
+
},
|
|
82
|
+
}),
|
|
83
|
+
],
|
|
84
|
+
});
|
|
85
|
+
if (mode === 'development') {
|
|
86
|
+
compiler.watch({}, (err, stats) => {
|
|
87
|
+
if (err) {
|
|
88
|
+
logger.debug(err);
|
|
89
|
+
return;
|
|
90
|
+
}
|
|
91
|
+
if (stats)
|
|
92
|
+
logStats(stats);
|
|
93
|
+
config.onChange();
|
|
94
|
+
});
|
|
95
|
+
}
|
|
96
|
+
else {
|
|
97
|
+
compiler.run((err, stats) => {
|
|
98
|
+
if (err) {
|
|
99
|
+
logger.error('⚠️ An error occurred during the extension build:', err);
|
|
100
|
+
process.exit(1);
|
|
101
|
+
}
|
|
102
|
+
if (stats)
|
|
103
|
+
logStats(stats);
|
|
104
|
+
if (stats && stats.hasErrors()) {
|
|
105
|
+
process.exit(1);
|
|
106
|
+
}
|
|
107
|
+
logger.info('✅ Extensions built successfully.');
|
|
108
|
+
});
|
|
109
|
+
}
|
|
110
|
+
};
|
|
111
|
+
export const compileTs = ({ path: projectPath }) => {
|
|
112
|
+
const result = spawnSync('nlx', ['tsc', '--noEmit', '-p', projectPath], {
|
|
113
|
+
stdio: 'inherit',
|
|
114
|
+
});
|
|
115
|
+
if (result.status !== 0) {
|
|
116
|
+
logger.info('❌ Build stopped due to type errors. Check the logs above.');
|
|
117
|
+
process.exit(1);
|
|
118
|
+
}
|
|
119
|
+
};
|
|
120
|
+
//# sourceMappingURL=bundler.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"bundler.js","sourceRoot":"","sources":["../../src/lib/bundler.ts"],"names":[],"mappings":"AAAA,OAAO,IAAI,MAAM,MAAM,CAAC;AACxB,OAAO,gBAAgB,MAAM,6BAA6B,CAAC;AAC3D,OAAO,OAAO,MAAM,SAAS,CAAC;AAE9B,OAAO,EAAE,iBAAiB,EAAE,MAAM,gBAAgB,CAAC;AACnD,OAAO,EAAE,MAAM,EAAE,MAAM,aAAa,CAAC;AACrC,OAAO,EAAE,SAAS,EAAE,MAAM,eAAe,CAAC;AAU1C,MAAM,sBAAsB,GAAG,gBAAgB,CAAC,sBAAsB,CAAC;AAEvE,MAAM,QAAQ,GAAG,CAAC,KAAoB,EAAE,EAAE;IACxC,MAAM,YAAY,GAAG,KAAK,CAAC,QAAQ,CAAC;QAClC,GAAG,EAAE,KAAK;QACV,MAAM,EAAE,IAAI;QACZ,QAAQ,EAAE,IAAI;QACd,MAAM,EAAE,IAAI;KACb,CAAC,CAAC;IAEH,IAAI,YAAY;QAAE,MAAM,CAAC,IAAI,CAAC,YAAY,CAAC,CAAC;IAE5C,IAAI,KAAK,CAAC,SAAS,EAAE;QACnB,MAAM,CAAC,KAAK,CAAC,oDAAoD,CAAC,CAAC;IAErE,IAAI,KAAK,CAAC,WAAW,EAAE;QAA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