@commercetools-frontend/mc-scripts 25.1.0 → 25.2.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.
- package/cli/dist/commercetools-frontend-mc-scripts-cli.cjs.dev.js +20 -7
- package/cli/dist/commercetools-frontend-mc-scripts-cli.cjs.prod.js +20 -7
- package/cli/dist/commercetools-frontend-mc-scripts-cli.esm.js +20 -7
- package/dist/{build-ec10df64.cjs.prod.js → build-182a099c.cjs.prod.js} +3 -3
- package/dist/{build-dbcd0936.esm.js → build-220a1658.esm.js} +3 -3
- package/dist/{build-0a5986d1.cjs.dev.js → build-519d246d.cjs.dev.js} +3 -3
- package/dist/{build-vite-16b1a575.cjs.dev.js → build-vite-837e7c94.cjs.dev.js} +56 -34
- package/dist/{build-vite-59e1f185.esm.js → build-vite-8cae71a0.esm.js} +53 -15
- package/dist/{build-vite-5d317720.cjs.prod.js → build-vite-b007241b.cjs.prod.js} +56 -34
- package/dist/commercetools-frontend-mc-scripts.cjs.dev.js +1 -1
- package/dist/commercetools-frontend-mc-scripts.cjs.prod.js +1 -1
- package/dist/commercetools-frontend-mc-scripts.esm.js +1 -1
- package/dist/config-sync-0b96d430.esm.js +255 -0
- package/dist/config-sync-b3072939.cjs.prod.js +265 -0
- package/dist/config-sync-ci-4a09aa00.cjs.prod.js +305 -0
- package/dist/config-sync-ci-85e3fec2.esm.js +294 -0
- package/dist/config-sync-ci-eadb8bfc.cjs.dev.js +305 -0
- package/dist/config-sync-f8fca39f.cjs.dev.js +265 -0
- package/dist/{config-sync-ce05c66c.cjs.prod.js → config-sync-helpers-11fc328f.cjs.prod.js} +162 -287
- package/dist/{config-sync-dbb43993.cjs.dev.js → config-sync-helpers-dab59ed9.cjs.dev.js} +162 -287
- package/dist/{config-sync-e7f53a98.esm.js → config-sync-helpers-fe6ea729.esm.js} +154 -283
- package/dist/{create-postcss-config-91c09596.cjs.prod.js → create-postcss-config-56b74a34.cjs.prod.js} +1 -1
- package/dist/{create-postcss-config-381b636b.cjs.dev.js → create-postcss-config-78879a12.cjs.dev.js} +1 -1
- package/dist/{create-postcss-config-0a86560d.esm.js → create-postcss-config-95f9bf62.esm.js} +1 -1
- package/dist/{create-webpack-config-for-development-37677a49.cjs.prod.js → create-webpack-config-for-development-3eb1b365.cjs.prod.js} +2 -2
- package/dist/{create-webpack-config-for-development-488742b2.cjs.dev.js → create-webpack-config-for-development-62b89920.cjs.dev.js} +2 -2
- package/dist/{create-webpack-config-for-development-df3f7f7f.esm.js → create-webpack-config-for-development-a28736fa.esm.js} +2 -2
- package/dist/{create-webpack-config-for-production-e22f78d2.esm.js → create-webpack-config-for-production-21ea561f.esm.js} +2 -2
- package/dist/{create-webpack-config-for-production-aad64e2a.cjs.prod.js → create-webpack-config-for-production-3b6599db.cjs.prod.js} +2 -2
- package/dist/{create-webpack-config-for-production-46d817cc.cjs.dev.js → create-webpack-config-for-production-e5ed8805.cjs.dev.js} +2 -2
- package/dist/{credentials-storage-0b89aa0e.cjs.prod.js → credentials-storage-6d592cd6.cjs.prod.js} +20 -2
- package/dist/{credentials-storage-cbb5c559.cjs.dev.js → credentials-storage-c4c5980e.cjs.dev.js} +20 -2
- package/dist/{credentials-storage-4464313c.esm.js → credentials-storage-fcc77fb6.esm.js} +20 -2
- package/dist/declarations/src/types.d.ts +4 -0
- package/dist/{deployment-previews-set-bbef95d2.esm.js → deployment-previews-set-7d49e7df.esm.js} +3 -3
- package/dist/{deployment-previews-set-4edd48db.cjs.dev.js → deployment-previews-set-8d6a1e99.cjs.dev.js} +3 -3
- package/dist/{deployment-previews-set-636fb1a3.cjs.prod.js → deployment-previews-set-f8ce3db7.cjs.prod.js} +3 -3
- package/dist/{graphql-requests-0a6eeb3a.cjs.prod.js → graphql-requests-b57fca4c.cjs.prod.js} +2 -2
- package/dist/{graphql-requests-14074b2b.esm.js → graphql-requests-d2fa2ca7.esm.js} +3 -3
- package/dist/{graphql-requests-23f7ddb1.cjs.dev.js → graphql-requests-da194989.cjs.dev.js} +2 -2
- package/dist/{login-54ebae96.cjs.prod.js → login-9774c9cc.cjs.prod.js} +130 -11
- package/dist/{login-1b222f33.esm.js → login-abb38213.esm.js} +127 -10
- package/dist/{login-a6fd5fbf.cjs.dev.js → login-f4550251.cjs.dev.js} +130 -11
- package/dist/{package-e1f7242c.cjs.prod.js → package-0eebca1b.cjs.dev.js} +20 -10
- package/dist/{package-a34835d9.esm.js → package-9e6910b8.esm.js} +20 -10
- package/dist/{package-d8b1f4c0.cjs.dev.js → package-b9298ce3.cjs.prod.js} +20 -10
- package/dist/{start-890895df.esm.js → start-109f9462.esm.js} +3 -3
- package/dist/{start-37ec4a7e.cjs.dev.js → start-7765f44c.cjs.dev.js} +3 -3
- package/dist/{start-0be8a294.cjs.prod.js → start-e014127c.cjs.prod.js} +3 -3
- package/package.json +20 -10
- package/postcss/dist/commercetools-frontend-mc-scripts-postcss.cjs.dev.js +2 -2
- package/postcss/dist/commercetools-frontend-mc-scripts-postcss.cjs.prod.js +2 -2
- package/postcss/dist/commercetools-frontend-mc-scripts-postcss.esm.js +2 -2
- package/webpack/dist/commercetools-frontend-mc-scripts-webpack.cjs.dev.js +4 -4
- package/webpack/dist/commercetools-frontend-mc-scripts-webpack.cjs.prod.js +4 -4
- package/webpack/dist/commercetools-frontend-mc-scripts-webpack.esm.js +4 -4
|
@@ -10,7 +10,7 @@ var path = require('path');
|
|
|
10
10
|
var commander = require('commander');
|
|
11
11
|
var dotenv = require('dotenv');
|
|
12
12
|
var dotenvExpand = require('dotenv-expand');
|
|
13
|
-
var _package = require('../../dist/package-
|
|
13
|
+
var _package = require('../../dist/package-0eebca1b.cjs.dev.js');
|
|
14
14
|
var doesFileExist = require('../../dist/does-file-exist-eb86baca.cjs.dev.js');
|
|
15
15
|
require('node:fs');
|
|
16
16
|
|
|
@@ -54,7 +54,7 @@ async function run() {
|
|
|
54
54
|
console.log('Experimental Vite bundler enabled! 🚀');
|
|
55
55
|
console.log('');
|
|
56
56
|
}
|
|
57
|
-
const startCommand = shouldUseExperimentalBundler ? await Promise.resolve().then(function () { return require('../../dist/start-vite-068e9f73.cjs.dev.js'); }) : await Promise.resolve().then(function () { return require('../../dist/start-
|
|
57
|
+
const startCommand = shouldUseExperimentalBundler ? await Promise.resolve().then(function () { return require('../../dist/start-vite-068e9f73.cjs.dev.js'); }) : await Promise.resolve().then(function () { return require('../../dist/start-7765f44c.cjs.dev.js'); });
|
|
58
58
|
await startCommand.default();
|
|
59
59
|
});
|
|
60
60
|
|
|
@@ -73,7 +73,7 @@ async function run() {
|
|
|
73
73
|
console.log('Experimental Vite bundler enabled! 🚀');
|
|
74
74
|
console.log('');
|
|
75
75
|
}
|
|
76
|
-
const buildCommand = shouldUseExperimentalBundler ? await Promise.resolve().then(function () { return require('../../dist/build-vite-
|
|
76
|
+
const buildCommand = shouldUseExperimentalBundler ? await Promise.resolve().then(function () { return require('../../dist/build-vite-837e7c94.cjs.dev.js'); }) : await Promise.resolve().then(function () { return require('../../dist/build-519d246d.cjs.dev.js'); });
|
|
77
77
|
await buildCommand.default();
|
|
78
78
|
const shouldAlsoCompile = !options.buildOnly;
|
|
79
79
|
if (shouldAlsoCompile) {
|
|
@@ -116,7 +116,7 @@ async function run() {
|
|
|
116
116
|
// Command: login
|
|
117
117
|
commander.program.command('login').description('Log in to your Merchant Center account through the CLI, using the cloud environment information from the Merchant Center customization config file. An API token is generated and stored in a configuration file for the related cloud environment, and valid for 36 hours.').option('--mc-api-url <url>', '(optional) The URL of the Merchant Center API. If not provided, the command will try to read it from the environment variable `MC_API_URL` or the Merchant Center Customization configuration file. In this case, the command needs to be executed from the folder where the Merchant Center Customization configuration file is located.').option('--project-key <key>', '(optional) The project key to issue an API access token for. If not provided, the command will try to read it from the environment variable `CTP_PROJECT_KEY` or the Merchant Center Customization configuration file. In this case, the command needs to be executed from the folder where the Merchant Center Customization configuration file is located.').option('--oauth-scope <scope...>',
|
|
118
118
|
// Variadic option. It allows multiple `--oauth-scope` options to be provided.
|
|
119
|
-
'(optional) The OAuth Scope to request when generating an API access token. Multiple flags are allowed. If not provided, the command will try to read it from the environment variable `CTP_OAUTH_SCOPES` (comma-separated list) or the Merchant Center Customization configuration file. In this case, the command needs to be executed from the folder where the Merchant Center Customization configuration file is located.').option('--force', '(optional) If defined, the command will force the login even if a valid session already exists.', false).action(async options => {
|
|
119
|
+
'(optional) The OAuth Scope to request when generating an API access token. Multiple flags are allowed. If not provided, the command will try to read it from the environment variable `CTP_OAUTH_SCOPES` (comma-separated list) or the Merchant Center Customization configuration file. In this case, the command needs to be executed from the folder where the Merchant Center Customization configuration file is located.').option('--force', '(optional) If defined, the command will force the login even if a valid session already exists.', false).option('--headless', '(optional) Use Puppeteer for automated headless login. Requires IDENTITY_EMAIL and IDENTITY_PASSWORD environment variables. Useful for CI/CD environments.', false).action(async options => {
|
|
120
120
|
const globalOptions = commander.program.opts();
|
|
121
121
|
|
|
122
122
|
// Load dotenv files into the process environment.
|
|
@@ -125,7 +125,7 @@ async function run() {
|
|
|
125
125
|
|
|
126
126
|
// Do this as the first thing so that any code reading it knows the right env.
|
|
127
127
|
process.env.NODE_ENV = 'production';
|
|
128
|
-
const loginCommand = await Promise.resolve().then(function () { return require('../../dist/login-
|
|
128
|
+
const loginCommand = await Promise.resolve().then(function () { return require('../../dist/login-f4550251.cjs.dev.js'); });
|
|
129
129
|
await loginCommand.default(options);
|
|
130
130
|
});
|
|
131
131
|
|
|
@@ -139,10 +139,23 @@ async function run() {
|
|
|
139
139
|
|
|
140
140
|
// Do this as the first thing so that any code reading it knows the right env.
|
|
141
141
|
process.env.NODE_ENV = 'production';
|
|
142
|
-
const configSyncCommand = await Promise.resolve().then(function () { return require('../../dist/config-sync-
|
|
142
|
+
const configSyncCommand = await Promise.resolve().then(function () { return require('../../dist/config-sync-f8fca39f.cjs.dev.js'); });
|
|
143
143
|
await configSyncCommand.default(options);
|
|
144
144
|
});
|
|
145
145
|
|
|
146
|
+
// Command: config:sync:ci
|
|
147
|
+
commander.program.command('config:sync:ci').description('Synchronizes the local Merchant Center customization config with the Merchant Center (CI mode). ' + 'Designed for non-interactive CI/CD environments.\n\n' + 'Environment variables:\n' + ' MC_ACCESS_TOKEN - Session token for authentication\n' + ' CT_ORGANIZATION_ID - Organization ID (required if multiple orgs)\n' + ' CT_ORGANIZATION_NAME - Organization name (required if multiple orgs)\n\n' + 'On create, outputs the app/view ID to a file in the config directory.\n\n' + 'To obtain MC_ACCESS_TOKEN:\n' + ' Option 1: Run "mc-scripts login --headless" with IDENTITY_EMAIL and IDENTITY_PASSWORD\n' + ' Option 2: Run "mc-scripts login" locally, then extract token from ~/.commercetools/mc-credentials.json\n\n' + 'SSO Authentication:\n' + ' This command does NOT support SSO directly (requires browser interaction).\n' + ' For SSO organizations, use a service account without SSO for CI/CD.').option('--dry-run', '(optional) Executes the command but does not send any mutation request.', false).action(async options => {
|
|
148
|
+
const globalOptions = commander.program.opts();
|
|
149
|
+
|
|
150
|
+
// Load dotenv files into the process environment.
|
|
151
|
+
loadDotEnvFiles(globalOptions);
|
|
152
|
+
|
|
153
|
+
// Do this as the first thing so that any code reading it knows the right env.
|
|
154
|
+
process.env.NODE_ENV = 'production';
|
|
155
|
+
const configSyncCICommand = await Promise.resolve().then(function () { return require('../../dist/config-sync-ci-eadb8bfc.cjs.dev.js'); });
|
|
156
|
+
await configSyncCICommand.default(options);
|
|
157
|
+
});
|
|
158
|
+
|
|
146
159
|
// Command: deployment-previews:set
|
|
147
160
|
commander.program.command('deployment-previews:set').description('Creates or updates a deployment preview for the Custom Application.').option('--alias <deployment-preview-alias>', "(optional) Alias to be used for the deployment preview. If you don't provide an alias, the command will prompt you for it.").option('--url <deployment-preview-url>', "(optional) URL to be used for the deployment preview. If you don't provide a URL, the command will prompt you for it.").option('--dry-run', '(optional) Executes the command but does not send any mutation request.', false).action(async options => {
|
|
148
161
|
const globalOptions = commander.program.opts();
|
|
@@ -153,7 +166,7 @@ async function run() {
|
|
|
153
166
|
|
|
154
167
|
// Do this as the first thing so that any code reading it knows the right env.
|
|
155
168
|
process.env.NODE_ENV = 'production';
|
|
156
|
-
const deploymentsSetCommand = await Promise.resolve().then(function () { return require('../../dist/deployment-previews-set-
|
|
169
|
+
const deploymentsSetCommand = await Promise.resolve().then(function () { return require('../../dist/deployment-previews-set-8d6a1e99.cjs.dev.js'); });
|
|
157
170
|
await deploymentsSetCommand.default(options);
|
|
158
171
|
});
|
|
159
172
|
commander.program.parse();
|
|
@@ -10,7 +10,7 @@ var path = require('path');
|
|
|
10
10
|
var commander = require('commander');
|
|
11
11
|
var dotenv = require('dotenv');
|
|
12
12
|
var dotenvExpand = require('dotenv-expand');
|
|
13
|
-
var _package = require('../../dist/package-
|
|
13
|
+
var _package = require('../../dist/package-b9298ce3.cjs.prod.js');
|
|
14
14
|
var doesFileExist = require('../../dist/does-file-exist-be53305d.cjs.prod.js');
|
|
15
15
|
require('node:fs');
|
|
16
16
|
|
|
@@ -54,7 +54,7 @@ async function run() {
|
|
|
54
54
|
console.log('Experimental Vite bundler enabled! 🚀');
|
|
55
55
|
console.log('');
|
|
56
56
|
}
|
|
57
|
-
const startCommand = shouldUseExperimentalBundler ? await Promise.resolve().then(function () { return require('../../dist/start-vite-29078b3a.cjs.prod.js'); }) : await Promise.resolve().then(function () { return require('../../dist/start-
|
|
57
|
+
const startCommand = shouldUseExperimentalBundler ? await Promise.resolve().then(function () { return require('../../dist/start-vite-29078b3a.cjs.prod.js'); }) : await Promise.resolve().then(function () { return require('../../dist/start-e014127c.cjs.prod.js'); });
|
|
58
58
|
await startCommand.default();
|
|
59
59
|
});
|
|
60
60
|
|
|
@@ -73,7 +73,7 @@ async function run() {
|
|
|
73
73
|
console.log('Experimental Vite bundler enabled! 🚀');
|
|
74
74
|
console.log('');
|
|
75
75
|
}
|
|
76
|
-
const buildCommand = shouldUseExperimentalBundler ? await Promise.resolve().then(function () { return require('../../dist/build-vite-
|
|
76
|
+
const buildCommand = shouldUseExperimentalBundler ? await Promise.resolve().then(function () { return require('../../dist/build-vite-b007241b.cjs.prod.js'); }) : await Promise.resolve().then(function () { return require('../../dist/build-182a099c.cjs.prod.js'); });
|
|
77
77
|
await buildCommand.default();
|
|
78
78
|
const shouldAlsoCompile = !options.buildOnly;
|
|
79
79
|
if (shouldAlsoCompile) {
|
|
@@ -116,7 +116,7 @@ async function run() {
|
|
|
116
116
|
// Command: login
|
|
117
117
|
commander.program.command('login').description('Log in to your Merchant Center account through the CLI, using the cloud environment information from the Merchant Center customization config file. An API token is generated and stored in a configuration file for the related cloud environment, and valid for 36 hours.').option('--mc-api-url <url>', '(optional) The URL of the Merchant Center API. If not provided, the command will try to read it from the environment variable `MC_API_URL` or the Merchant Center Customization configuration file. In this case, the command needs to be executed from the folder where the Merchant Center Customization configuration file is located.').option('--project-key <key>', '(optional) The project key to issue an API access token for. If not provided, the command will try to read it from the environment variable `CTP_PROJECT_KEY` or the Merchant Center Customization configuration file. In this case, the command needs to be executed from the folder where the Merchant Center Customization configuration file is located.').option('--oauth-scope <scope...>',
|
|
118
118
|
// Variadic option. It allows multiple `--oauth-scope` options to be provided.
|
|
119
|
-
'(optional) The OAuth Scope to request when generating an API access token. Multiple flags are allowed. If not provided, the command will try to read it from the environment variable `CTP_OAUTH_SCOPES` (comma-separated list) or the Merchant Center Customization configuration file. In this case, the command needs to be executed from the folder where the Merchant Center Customization configuration file is located.').option('--force', '(optional) If defined, the command will force the login even if a valid session already exists.', false).action(async options => {
|
|
119
|
+
'(optional) The OAuth Scope to request when generating an API access token. Multiple flags are allowed. If not provided, the command will try to read it from the environment variable `CTP_OAUTH_SCOPES` (comma-separated list) or the Merchant Center Customization configuration file. In this case, the command needs to be executed from the folder where the Merchant Center Customization configuration file is located.').option('--force', '(optional) If defined, the command will force the login even if a valid session already exists.', false).option('--headless', '(optional) Use Puppeteer for automated headless login. Requires IDENTITY_EMAIL and IDENTITY_PASSWORD environment variables. Useful for CI/CD environments.', false).action(async options => {
|
|
120
120
|
const globalOptions = commander.program.opts();
|
|
121
121
|
|
|
122
122
|
// Load dotenv files into the process environment.
|
|
@@ -125,7 +125,7 @@ async function run() {
|
|
|
125
125
|
|
|
126
126
|
// Do this as the first thing so that any code reading it knows the right env.
|
|
127
127
|
process.env.NODE_ENV = 'production';
|
|
128
|
-
const loginCommand = await Promise.resolve().then(function () { return require('../../dist/login-
|
|
128
|
+
const loginCommand = await Promise.resolve().then(function () { return require('../../dist/login-9774c9cc.cjs.prod.js'); });
|
|
129
129
|
await loginCommand.default(options);
|
|
130
130
|
});
|
|
131
131
|
|
|
@@ -139,10 +139,23 @@ async function run() {
|
|
|
139
139
|
|
|
140
140
|
// Do this as the first thing so that any code reading it knows the right env.
|
|
141
141
|
process.env.NODE_ENV = 'production';
|
|
142
|
-
const configSyncCommand = await Promise.resolve().then(function () { return require('../../dist/config-sync-
|
|
142
|
+
const configSyncCommand = await Promise.resolve().then(function () { return require('../../dist/config-sync-b3072939.cjs.prod.js'); });
|
|
143
143
|
await configSyncCommand.default(options);
|
|
144
144
|
});
|
|
145
145
|
|
|
146
|
+
// Command: config:sync:ci
|
|
147
|
+
commander.program.command('config:sync:ci').description('Synchronizes the local Merchant Center customization config with the Merchant Center (CI mode). ' + 'Designed for non-interactive CI/CD environments.\n\n' + 'Environment variables:\n' + ' MC_ACCESS_TOKEN - Session token for authentication\n' + ' CT_ORGANIZATION_ID - Organization ID (required if multiple orgs)\n' + ' CT_ORGANIZATION_NAME - Organization name (required if multiple orgs)\n\n' + 'On create, outputs the app/view ID to a file in the config directory.\n\n' + 'To obtain MC_ACCESS_TOKEN:\n' + ' Option 1: Run "mc-scripts login --headless" with IDENTITY_EMAIL and IDENTITY_PASSWORD\n' + ' Option 2: Run "mc-scripts login" locally, then extract token from ~/.commercetools/mc-credentials.json\n\n' + 'SSO Authentication:\n' + ' This command does NOT support SSO directly (requires browser interaction).\n' + ' For SSO organizations, use a service account without SSO for CI/CD.').option('--dry-run', '(optional) Executes the command but does not send any mutation request.', false).action(async options => {
|
|
148
|
+
const globalOptions = commander.program.opts();
|
|
149
|
+
|
|
150
|
+
// Load dotenv files into the process environment.
|
|
151
|
+
loadDotEnvFiles(globalOptions);
|
|
152
|
+
|
|
153
|
+
// Do this as the first thing so that any code reading it knows the right env.
|
|
154
|
+
process.env.NODE_ENV = 'production';
|
|
155
|
+
const configSyncCICommand = await Promise.resolve().then(function () { return require('../../dist/config-sync-ci-4a09aa00.cjs.prod.js'); });
|
|
156
|
+
await configSyncCICommand.default(options);
|
|
157
|
+
});
|
|
158
|
+
|
|
146
159
|
// Command: deployment-previews:set
|
|
147
160
|
commander.program.command('deployment-previews:set').description('Creates or updates a deployment preview for the Custom Application.').option('--alias <deployment-preview-alias>', "(optional) Alias to be used for the deployment preview. If you don't provide an alias, the command will prompt you for it.").option('--url <deployment-preview-url>', "(optional) URL to be used for the deployment preview. If you don't provide a URL, the command will prompt you for it.").option('--dry-run', '(optional) Executes the command but does not send any mutation request.', false).action(async options => {
|
|
148
161
|
const globalOptions = commander.program.opts();
|
|
@@ -153,7 +166,7 @@ async function run() {
|
|
|
153
166
|
|
|
154
167
|
// Do this as the first thing so that any code reading it knows the right env.
|
|
155
168
|
process.env.NODE_ENV = 'production';
|
|
156
|
-
const deploymentsSetCommand = await Promise.resolve().then(function () { return require('../../dist/deployment-previews-set-
|
|
169
|
+
const deploymentsSetCommand = await Promise.resolve().then(function () { return require('../../dist/deployment-previews-set-f8ce3db7.cjs.prod.js'); });
|
|
157
170
|
await deploymentsSetCommand.default(options);
|
|
158
171
|
});
|
|
159
172
|
commander.program.parse();
|
|
@@ -6,7 +6,7 @@ import path from 'path';
|
|
|
6
6
|
import { program } from 'commander';
|
|
7
7
|
import dotenv from 'dotenv';
|
|
8
8
|
import dotenvExpand from 'dotenv-expand';
|
|
9
|
-
import { p as pkgJson } from '../../dist/package-
|
|
9
|
+
import { p as pkgJson } from '../../dist/package-9e6910b8.esm.js';
|
|
10
10
|
import { d as doesFileExist } from '../../dist/does-file-exist-32618334.esm.js';
|
|
11
11
|
import 'node:fs';
|
|
12
12
|
|
|
@@ -40,7 +40,7 @@ async function run() {
|
|
|
40
40
|
console.log('Experimental Vite bundler enabled! 🚀');
|
|
41
41
|
console.log('');
|
|
42
42
|
}
|
|
43
|
-
const startCommand = shouldUseExperimentalBundler ? await import('../../dist/start-vite-7d1161e8.esm.js') : await import('../../dist/start-
|
|
43
|
+
const startCommand = shouldUseExperimentalBundler ? await import('../../dist/start-vite-7d1161e8.esm.js') : await import('../../dist/start-109f9462.esm.js');
|
|
44
44
|
await startCommand.default();
|
|
45
45
|
});
|
|
46
46
|
|
|
@@ -59,7 +59,7 @@ async function run() {
|
|
|
59
59
|
console.log('Experimental Vite bundler enabled! 🚀');
|
|
60
60
|
console.log('');
|
|
61
61
|
}
|
|
62
|
-
const buildCommand = shouldUseExperimentalBundler ? await import('../../dist/build-vite-
|
|
62
|
+
const buildCommand = shouldUseExperimentalBundler ? await import('../../dist/build-vite-8cae71a0.esm.js') : await import('../../dist/build-220a1658.esm.js');
|
|
63
63
|
await buildCommand.default();
|
|
64
64
|
const shouldAlsoCompile = !options.buildOnly;
|
|
65
65
|
if (shouldAlsoCompile) {
|
|
@@ -102,7 +102,7 @@ async function run() {
|
|
|
102
102
|
// Command: login
|
|
103
103
|
program.command('login').description('Log in to your Merchant Center account through the CLI, using the cloud environment information from the Merchant Center customization config file. An API token is generated and stored in a configuration file for the related cloud environment, and valid for 36 hours.').option('--mc-api-url <url>', '(optional) The URL of the Merchant Center API. If not provided, the command will try to read it from the environment variable `MC_API_URL` or the Merchant Center Customization configuration file. In this case, the command needs to be executed from the folder where the Merchant Center Customization configuration file is located.').option('--project-key <key>', '(optional) The project key to issue an API access token for. If not provided, the command will try to read it from the environment variable `CTP_PROJECT_KEY` or the Merchant Center Customization configuration file. In this case, the command needs to be executed from the folder where the Merchant Center Customization configuration file is located.').option('--oauth-scope <scope...>',
|
|
104
104
|
// Variadic option. It allows multiple `--oauth-scope` options to be provided.
|
|
105
|
-
'(optional) The OAuth Scope to request when generating an API access token. Multiple flags are allowed. If not provided, the command will try to read it from the environment variable `CTP_OAUTH_SCOPES` (comma-separated list) or the Merchant Center Customization configuration file. In this case, the command needs to be executed from the folder where the Merchant Center Customization configuration file is located.').option('--force', '(optional) If defined, the command will force the login even if a valid session already exists.', false).action(async options => {
|
|
105
|
+
'(optional) The OAuth Scope to request when generating an API access token. Multiple flags are allowed. If not provided, the command will try to read it from the environment variable `CTP_OAUTH_SCOPES` (comma-separated list) or the Merchant Center Customization configuration file. In this case, the command needs to be executed from the folder where the Merchant Center Customization configuration file is located.').option('--force', '(optional) If defined, the command will force the login even if a valid session already exists.', false).option('--headless', '(optional) Use Puppeteer for automated headless login. Requires IDENTITY_EMAIL and IDENTITY_PASSWORD environment variables. Useful for CI/CD environments.', false).action(async options => {
|
|
106
106
|
const globalOptions = program.opts();
|
|
107
107
|
|
|
108
108
|
// Load dotenv files into the process environment.
|
|
@@ -111,7 +111,7 @@ async function run() {
|
|
|
111
111
|
|
|
112
112
|
// Do this as the first thing so that any code reading it knows the right env.
|
|
113
113
|
process.env.NODE_ENV = 'production';
|
|
114
|
-
const loginCommand = await import('../../dist/login-
|
|
114
|
+
const loginCommand = await import('../../dist/login-abb38213.esm.js');
|
|
115
115
|
await loginCommand.default(options);
|
|
116
116
|
});
|
|
117
117
|
|
|
@@ -125,10 +125,23 @@ async function run() {
|
|
|
125
125
|
|
|
126
126
|
// Do this as the first thing so that any code reading it knows the right env.
|
|
127
127
|
process.env.NODE_ENV = 'production';
|
|
128
|
-
const configSyncCommand = await import('../../dist/config-sync-
|
|
128
|
+
const configSyncCommand = await import('../../dist/config-sync-0b96d430.esm.js');
|
|
129
129
|
await configSyncCommand.default(options);
|
|
130
130
|
});
|
|
131
131
|
|
|
132
|
+
// Command: config:sync:ci
|
|
133
|
+
program.command('config:sync:ci').description('Synchronizes the local Merchant Center customization config with the Merchant Center (CI mode). ' + 'Designed for non-interactive CI/CD environments.\n\n' + 'Environment variables:\n' + ' MC_ACCESS_TOKEN - Session token for authentication\n' + ' CT_ORGANIZATION_ID - Organization ID (required if multiple orgs)\n' + ' CT_ORGANIZATION_NAME - Organization name (required if multiple orgs)\n\n' + 'On create, outputs the app/view ID to a file in the config directory.\n\n' + 'To obtain MC_ACCESS_TOKEN:\n' + ' Option 1: Run "mc-scripts login --headless" with IDENTITY_EMAIL and IDENTITY_PASSWORD\n' + ' Option 2: Run "mc-scripts login" locally, then extract token from ~/.commercetools/mc-credentials.json\n\n' + 'SSO Authentication:\n' + ' This command does NOT support SSO directly (requires browser interaction).\n' + ' For SSO organizations, use a service account without SSO for CI/CD.').option('--dry-run', '(optional) Executes the command but does not send any mutation request.', false).action(async options => {
|
|
134
|
+
const globalOptions = program.opts();
|
|
135
|
+
|
|
136
|
+
// Load dotenv files into the process environment.
|
|
137
|
+
loadDotEnvFiles(globalOptions);
|
|
138
|
+
|
|
139
|
+
// Do this as the first thing so that any code reading it knows the right env.
|
|
140
|
+
process.env.NODE_ENV = 'production';
|
|
141
|
+
const configSyncCICommand = await import('../../dist/config-sync-ci-85e3fec2.esm.js');
|
|
142
|
+
await configSyncCICommand.default(options);
|
|
143
|
+
});
|
|
144
|
+
|
|
132
145
|
// Command: deployment-previews:set
|
|
133
146
|
program.command('deployment-previews:set').description('Creates or updates a deployment preview for the Custom Application.').option('--alias <deployment-preview-alias>', "(optional) Alias to be used for the deployment preview. If you don't provide an alias, the command will prompt you for it.").option('--url <deployment-preview-url>', "(optional) URL to be used for the deployment preview. If you don't provide a URL, the command will prompt you for it.").option('--dry-run', '(optional) Executes the command but does not send any mutation request.', false).action(async options => {
|
|
134
147
|
const globalOptions = program.opts();
|
|
@@ -139,7 +152,7 @@ async function run() {
|
|
|
139
152
|
|
|
140
153
|
// Do this as the first thing so that any code reading it knows the right env.
|
|
141
154
|
process.env.NODE_ENV = 'production';
|
|
142
|
-
const deploymentsSetCommand = await import('../../dist/deployment-previews-set-
|
|
155
|
+
const deploymentsSetCommand = await import('../../dist/deployment-previews-set-7d49e7df.esm.js');
|
|
143
156
|
await deploymentsSetCommand.default(options);
|
|
144
157
|
});
|
|
145
158
|
program.parse();
|
|
@@ -10,7 +10,7 @@ var formatWebpackMessages = require('react-dev-utils/formatWebpackMessages');
|
|
|
10
10
|
var printBuildError = require('react-dev-utils/printBuildError');
|
|
11
11
|
var webpack = require('webpack');
|
|
12
12
|
var assets = require('@commercetools-frontend/assets');
|
|
13
|
-
var createWebpackConfigForProduction = require('./create-webpack-config-for-production-
|
|
13
|
+
var createWebpackConfigForProduction = require('./create-webpack-config-for-production-3b6599db.cjs.prod.js');
|
|
14
14
|
var paths = require('./paths-7768b440.cjs.prod.js');
|
|
15
15
|
var doesFileExist = require('./does-file-exist-be53305d.cjs.prod.js');
|
|
16
16
|
require('@babel/runtime-corejs3/core-js-stable/object/keys');
|
|
@@ -40,9 +40,9 @@ require('@babel/runtime-corejs3/core-js-stable/instance/bind');
|
|
|
40
40
|
require('@babel/runtime-corejs3/core-js-stable/instance/reduce');
|
|
41
41
|
require('@babel/runtime-corejs3/core-js-stable/object/assign');
|
|
42
42
|
require('fs');
|
|
43
|
-
require('./create-postcss-config-
|
|
43
|
+
require('./create-postcss-config-56b74a34.cjs.prod.js');
|
|
44
44
|
require('@babel/runtime-corejs3/helpers/slicedToArray');
|
|
45
|
-
require('./package-
|
|
45
|
+
require('./package-b9298ce3.cjs.prod.js');
|
|
46
46
|
require('./has-jsx-runtime-c3202df5.cjs.prod.js');
|
|
47
47
|
require('./optimizations-fb93514f.cjs.prod.js');
|
|
48
48
|
require('@babel/runtime-corejs3/core-js-stable/object/entries');
|
|
@@ -8,7 +8,7 @@ import formatWebpackMessages from 'react-dev-utils/formatWebpackMessages';
|
|
|
8
8
|
import printBuildError from 'react-dev-utils/printBuildError';
|
|
9
9
|
import webpack from 'webpack';
|
|
10
10
|
import { packageLocation } from '@commercetools-frontend/assets';
|
|
11
|
-
import { c as createWebpackConfigForProduction } from './create-webpack-config-for-production-
|
|
11
|
+
import { c as createWebpackConfigForProduction } from './create-webpack-config-for-production-21ea561f.esm.js';
|
|
12
12
|
import { p as paths } from './paths-39f22b8b.esm.js';
|
|
13
13
|
import { d as doesFileExist } from './does-file-exist-32618334.esm.js';
|
|
14
14
|
import '@babel/runtime-corejs3/core-js-stable/object/keys';
|
|
@@ -38,9 +38,9 @@ import '@babel/runtime-corejs3/core-js-stable/instance/bind';
|
|
|
38
38
|
import '@babel/runtime-corejs3/core-js-stable/instance/reduce';
|
|
39
39
|
import '@babel/runtime-corejs3/core-js-stable/object/assign';
|
|
40
40
|
import 'fs';
|
|
41
|
-
import './create-postcss-config-
|
|
41
|
+
import './create-postcss-config-95f9bf62.esm.js';
|
|
42
42
|
import '@babel/runtime-corejs3/helpers/slicedToArray';
|
|
43
|
-
import './package-
|
|
43
|
+
import './package-9e6910b8.esm.js';
|
|
44
44
|
import './has-jsx-runtime-e3ecb09b.esm.js';
|
|
45
45
|
import './optimizations-bf991634.esm.js';
|
|
46
46
|
import '@babel/runtime-corejs3/core-js-stable/object/entries';
|
|
@@ -10,7 +10,7 @@ var formatWebpackMessages = require('react-dev-utils/formatWebpackMessages');
|
|
|
10
10
|
var printBuildError = require('react-dev-utils/printBuildError');
|
|
11
11
|
var webpack = require('webpack');
|
|
12
12
|
var assets = require('@commercetools-frontend/assets');
|
|
13
|
-
var createWebpackConfigForProduction = require('./create-webpack-config-for-production-
|
|
13
|
+
var createWebpackConfigForProduction = require('./create-webpack-config-for-production-e5ed8805.cjs.dev.js');
|
|
14
14
|
var paths = require('./paths-b76fc753.cjs.dev.js');
|
|
15
15
|
var doesFileExist = require('./does-file-exist-eb86baca.cjs.dev.js');
|
|
16
16
|
require('@babel/runtime-corejs3/core-js-stable/object/keys');
|
|
@@ -40,9 +40,9 @@ require('@babel/runtime-corejs3/core-js-stable/instance/bind');
|
|
|
40
40
|
require('@babel/runtime-corejs3/core-js-stable/instance/reduce');
|
|
41
41
|
require('@babel/runtime-corejs3/core-js-stable/object/assign');
|
|
42
42
|
require('fs');
|
|
43
|
-
require('./create-postcss-config-
|
|
43
|
+
require('./create-postcss-config-78879a12.cjs.dev.js');
|
|
44
44
|
require('@babel/runtime-corejs3/helpers/slicedToArray');
|
|
45
|
-
require('./package-
|
|
45
|
+
require('./package-0eebca1b.cjs.dev.js');
|
|
46
46
|
require('./has-jsx-runtime-aa5d21ee.cjs.dev.js');
|
|
47
47
|
require('./optimizations-7789145e.cjs.dev.js');
|
|
48
48
|
require('@babel/runtime-corejs3/core-js-stable/object/entries');
|
|
@@ -3,10 +3,10 @@
|
|
|
3
3
|
var _parseInt = require('@babel/runtime-corejs3/core-js-stable/parse-int');
|
|
4
4
|
var _JSON$stringify = require('@babel/runtime-corejs3/core-js-stable/json/stringify');
|
|
5
5
|
var _filterInstanceProperty = require('@babel/runtime-corejs3/core-js-stable/instance/filter');
|
|
6
|
-
var path = require('path');
|
|
6
|
+
var path$1 = require('path');
|
|
7
7
|
var pluginGraphql = require('@rollup/plugin-graphql');
|
|
8
8
|
var pluginReact = require('@vitejs/plugin-react');
|
|
9
|
-
var fs = require('fs-extra');
|
|
9
|
+
var fs$1 = require('fs-extra');
|
|
10
10
|
var rollupPluginVisualizer = require('rollup-plugin-visualizer');
|
|
11
11
|
var vite = require('vite');
|
|
12
12
|
var viteBundleAnalyzer = require('vite-bundle-analyzer');
|
|
@@ -17,6 +17,9 @@ var paths = require('./paths-b76fc753.cjs.dev.js');
|
|
|
17
17
|
var cliLib = require('@formatjs/cli-lib');
|
|
18
18
|
var pluginutils = require('@rollup/pluginutils');
|
|
19
19
|
var i18nMessageComplilation = require('./i18n-message-complilation-7311cb29.cjs.dev.js');
|
|
20
|
+
var fs = require('node:fs');
|
|
21
|
+
var path = require('node:path');
|
|
22
|
+
var glob = require('glob');
|
|
20
23
|
var vitePluginSvgr = require('./vite-plugin-svgr-7d06f400.cjs.dev.js');
|
|
21
24
|
require('@babel/runtime-corejs3/helpers/defineProperty');
|
|
22
25
|
require('@babel/runtime-corejs3/helpers/slicedToArray');
|
|
@@ -34,38 +37,21 @@ require('chalk');
|
|
|
34
37
|
require('@babel/runtime-corejs3/core-js-stable/instance/find');
|
|
35
38
|
require('fs');
|
|
36
39
|
require('./does-file-exist-eb86baca.cjs.dev.js');
|
|
37
|
-
require('node:fs');
|
|
38
40
|
require('@babel/runtime-corejs3/core-js-stable/object/values');
|
|
39
41
|
require('crypto');
|
|
40
42
|
require('@babel/runtime-corejs3/core-js/instance/match-all');
|
|
41
43
|
|
|
42
44
|
function _interopDefault (e) { return e && e.__esModule ? e : { 'default': e }; }
|
|
43
45
|
|
|
44
|
-
function _interopNamespace(e) {
|
|
45
|
-
if (e && e.__esModule) return e;
|
|
46
|
-
var n = Object.create(null);
|
|
47
|
-
if (e) {
|
|
48
|
-
Object.keys(e).forEach(function (k) {
|
|
49
|
-
if (k !== 'default') {
|
|
50
|
-
var d = Object.getOwnPropertyDescriptor(e, k);
|
|
51
|
-
Object.defineProperty(n, k, d.get ? d : {
|
|
52
|
-
enumerable: true,
|
|
53
|
-
get: function () { return e[k]; }
|
|
54
|
-
});
|
|
55
|
-
}
|
|
56
|
-
});
|
|
57
|
-
}
|
|
58
|
-
n["default"] = e;
|
|
59
|
-
return Object.freeze(n);
|
|
60
|
-
}
|
|
61
|
-
|
|
62
46
|
var _parseInt__default = /*#__PURE__*/_interopDefault(_parseInt);
|
|
63
47
|
var _JSON$stringify__default = /*#__PURE__*/_interopDefault(_JSON$stringify);
|
|
64
48
|
var _filterInstanceProperty__default = /*#__PURE__*/_interopDefault(_filterInstanceProperty);
|
|
65
|
-
var path__default = /*#__PURE__*/_interopDefault(path);
|
|
49
|
+
var path__default$1 = /*#__PURE__*/_interopDefault(path$1);
|
|
66
50
|
var pluginGraphql__default = /*#__PURE__*/_interopDefault(pluginGraphql);
|
|
67
51
|
var pluginReact__default = /*#__PURE__*/_interopDefault(pluginReact);
|
|
52
|
+
var fs__default$1 = /*#__PURE__*/_interopDefault(fs$1);
|
|
68
53
|
var fs__default = /*#__PURE__*/_interopDefault(fs);
|
|
54
|
+
var path__default = /*#__PURE__*/_interopDefault(path);
|
|
69
55
|
|
|
70
56
|
// Type guard to help with filtering arrays for nullish elements.
|
|
71
57
|
function nonNullable(value) {
|
|
@@ -121,25 +107,62 @@ function vitePluginI18nMessageCompilation() {
|
|
|
121
107
|
};
|
|
122
108
|
}
|
|
123
109
|
|
|
110
|
+
/**
|
|
111
|
+
* A simple Vite plugin to clean up files matching glob patterns after build.
|
|
112
|
+
* Replaces `vite-plugin-post-cleanup` to avoid the `inflight` vulnerability
|
|
113
|
+
* in its transitive dependencies.
|
|
114
|
+
*/
|
|
115
|
+
function pluginPostCleanup(options) {
|
|
116
|
+
return {
|
|
117
|
+
name: 'vite-plugin-post-cleanup',
|
|
118
|
+
apply: 'build',
|
|
119
|
+
closeBundle() {
|
|
120
|
+
const outputDir = options.outputDir,
|
|
121
|
+
patterns = options.patterns,
|
|
122
|
+
verbose = options.verbose;
|
|
123
|
+
let totalFilesDeleted = 0;
|
|
124
|
+
for (const pattern of patterns) {
|
|
125
|
+
const files = glob.globSync(pattern, {
|
|
126
|
+
cwd: outputDir
|
|
127
|
+
});
|
|
128
|
+
for (const file of files) {
|
|
129
|
+
const filePath = path__default["default"].join(outputDir, file);
|
|
130
|
+
try {
|
|
131
|
+
fs__default["default"].unlinkSync(filePath);
|
|
132
|
+
totalFilesDeleted++;
|
|
133
|
+
if (verbose) {
|
|
134
|
+
console.log(`[post-cleanup] Deleted: ${file}`);
|
|
135
|
+
}
|
|
136
|
+
} catch (error) {
|
|
137
|
+
console.warn(`[post-cleanup] Failed to delete ${file}:`, error);
|
|
138
|
+
}
|
|
139
|
+
}
|
|
140
|
+
}
|
|
141
|
+
if (verbose && patterns.length > 0 && totalFilesDeleted === 0) {
|
|
142
|
+
console.log('[post-cleanup] No files matched the patterns');
|
|
143
|
+
}
|
|
144
|
+
}
|
|
145
|
+
};
|
|
146
|
+
}
|
|
147
|
+
|
|
124
148
|
async function run() {
|
|
125
149
|
var _context;
|
|
126
|
-
const CleanBuild = (await Promise.resolve().then(function () { return /*#__PURE__*/_interopNamespace(require('vite-plugin-clean-build')); })).default;
|
|
127
150
|
const DEFAULT_PORT = _parseInt__default["default"](String(process.env.HTTP_PORT), 10) || 3001;
|
|
128
151
|
|
|
129
152
|
// Ensure the `/public` folder exists.
|
|
130
|
-
fs__default["default"].mkdirSync(paths.paths.appBuild, {
|
|
153
|
+
fs__default$1["default"].mkdirSync(paths.paths.appBuild, {
|
|
131
154
|
recursive: true
|
|
132
155
|
});
|
|
133
156
|
|
|
134
157
|
// Generate `index.html` (template).
|
|
135
|
-
const appEntryPoint = path__default["default"].relative(paths.paths.appRoot, paths.paths.entryPoint);
|
|
158
|
+
const appEntryPoint = path__default$1["default"].relative(paths.paths.appRoot, paths.paths.entryPoint);
|
|
136
159
|
const html = mcHtmlTemplate.generateTemplate({
|
|
137
160
|
// Define the module entry point (path relative from the `/public` folder).
|
|
138
161
|
// NOTE: that this is different from the development configuration.
|
|
139
162
|
scriptImports: [`<script type="module" src="/${appEntryPoint}" defer></script>`]
|
|
140
163
|
});
|
|
141
164
|
// Write `index.html` (template) into the `/public` folder.
|
|
142
|
-
fs__default["default"].writeFileSync(paths.paths.appIndexHtml, html, {
|
|
165
|
+
fs__default$1["default"].writeFileSync(paths.paths.appIndexHtml, html, {
|
|
143
166
|
encoding: 'utf8'
|
|
144
167
|
});
|
|
145
168
|
const appDependencies = require(paths.paths.appPackageJson).dependencies;
|
|
@@ -201,12 +224,11 @@ async function run() {
|
|
|
201
224
|
// Enable pre-parse default `formatjs` messages into AST.
|
|
202
225
|
// TODO: make it a CLI option when Vite support becomes stable.
|
|
203
226
|
process.env.ENABLE_I18N_AST === 'true'
|
|
204
|
-
}] : undefined]).call(_context, nonNullable)
|
|
227
|
+
}] : undefined, process.env.ENABLE_BABEL_REACT_COMPILER === 'true' ? 'babel-plugin-react-compiler' : undefined]).call(_context, nonNullable)
|
|
205
228
|
}
|
|
206
229
|
}),
|
|
207
|
-
//
|
|
208
|
-
|
|
209
|
-
CleanBuild({
|
|
230
|
+
// Clean up large SVG assets that are not used after the build.
|
|
231
|
+
pluginPostCleanup({
|
|
210
232
|
outputDir: paths.paths.appBuild,
|
|
211
233
|
patterns: ['*.react-*.svg'],
|
|
212
234
|
verbose: true // logs the files that are removed
|
|
@@ -220,17 +242,17 @@ async function run() {
|
|
|
220
242
|
});
|
|
221
243
|
|
|
222
244
|
// Rename `/public/public/index.html` to `/public/index.html.template`
|
|
223
|
-
fs__default["default"].renameSync(
|
|
245
|
+
fs__default$1["default"].renameSync(
|
|
224
246
|
// Because of our custom entry point path (`/public/index.html`),
|
|
225
247
|
// Vite will write the `index.html` to `/public/public/index.html`.
|
|
226
248
|
// We need to move this file to the `/public` folder and rename it
|
|
227
249
|
// to `index.html.template` (as expected by the `compile-html` command).
|
|
228
|
-
path__default["default"].join(paths.paths.appBuild, 'public/index.html'), paths.paths.appIndexHtmlTemplate);
|
|
250
|
+
path__default$1["default"].join(paths.paths.appBuild, 'public/index.html'), paths.paths.appIndexHtmlTemplate);
|
|
229
251
|
// Clean up nested folder
|
|
230
|
-
fs__default["default"].rmdirSync(path__default["default"].join(paths.paths.appBuild, 'public'));
|
|
252
|
+
fs__default$1["default"].rmdirSync(path__default$1["default"].join(paths.paths.appBuild, 'public'));
|
|
231
253
|
|
|
232
254
|
// Copy public assets
|
|
233
|
-
fs__default["default"].copySync(path__default["default"].join(assets.packageLocation, 'html-page'), paths.paths.appBuild, {
|
|
255
|
+
fs__default$1["default"].copySync(path__default$1["default"].join(assets.packageLocation, 'html-page'), paths.paths.appBuild, {
|
|
234
256
|
dereference: true
|
|
235
257
|
});
|
|
236
258
|
}
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import _parseInt from '@babel/runtime-corejs3/core-js-stable/parse-int';
|
|
2
2
|
import _JSON$stringify from '@babel/runtime-corejs3/core-js-stable/json/stringify';
|
|
3
3
|
import _filterInstanceProperty from '@babel/runtime-corejs3/core-js-stable/instance/filter';
|
|
4
|
-
import path from 'path';
|
|
4
|
+
import path$1 from 'path';
|
|
5
5
|
import pluginGraphql from '@rollup/plugin-graphql';
|
|
6
6
|
import pluginReact from '@vitejs/plugin-react';
|
|
7
|
-
import fs from 'fs-extra';
|
|
7
|
+
import fs$1 from 'fs-extra';
|
|
8
8
|
import { visualizer } from 'rollup-plugin-visualizer';
|
|
9
9
|
import { build } from 'vite';
|
|
10
10
|
import { analyzer } from 'vite-bundle-analyzer';
|
|
@@ -15,6 +15,9 @@ import { p as paths } from './paths-39f22b8b.esm.js';
|
|
|
15
15
|
import { compile } from '@formatjs/cli-lib';
|
|
16
16
|
import { createFilter } from '@rollup/pluginutils';
|
|
17
17
|
import { g as getI18nMessageFormat, h as handleMessageCompilationError } from './i18n-message-complilation-21d3b0aa.esm.js';
|
|
18
|
+
import fs from 'node:fs';
|
|
19
|
+
import path from 'node:path';
|
|
20
|
+
import { globSync } from 'glob';
|
|
18
21
|
import { v as vitePluginSvgr } from './vite-plugin-svgr-de6ee7da.esm.js';
|
|
19
22
|
import '@babel/runtime-corejs3/helpers/defineProperty';
|
|
20
23
|
import '@babel/runtime-corejs3/helpers/slicedToArray';
|
|
@@ -32,7 +35,6 @@ import 'chalk';
|
|
|
32
35
|
import '@babel/runtime-corejs3/core-js-stable/instance/find';
|
|
33
36
|
import 'fs';
|
|
34
37
|
import './does-file-exist-32618334.esm.js';
|
|
35
|
-
import 'node:fs';
|
|
36
38
|
import '@babel/runtime-corejs3/core-js-stable/object/values';
|
|
37
39
|
import 'crypto';
|
|
38
40
|
import '@babel/runtime-corejs3/core-js/instance/match-all';
|
|
@@ -91,25 +93,62 @@ function vitePluginI18nMessageCompilation() {
|
|
|
91
93
|
};
|
|
92
94
|
}
|
|
93
95
|
|
|
96
|
+
/**
|
|
97
|
+
* A simple Vite plugin to clean up files matching glob patterns after build.
|
|
98
|
+
* Replaces `vite-plugin-post-cleanup` to avoid the `inflight` vulnerability
|
|
99
|
+
* in its transitive dependencies.
|
|
100
|
+
*/
|
|
101
|
+
function pluginPostCleanup(options) {
|
|
102
|
+
return {
|
|
103
|
+
name: 'vite-plugin-post-cleanup',
|
|
104
|
+
apply: 'build',
|
|
105
|
+
closeBundle() {
|
|
106
|
+
const outputDir = options.outputDir,
|
|
107
|
+
patterns = options.patterns,
|
|
108
|
+
verbose = options.verbose;
|
|
109
|
+
let totalFilesDeleted = 0;
|
|
110
|
+
for (const pattern of patterns) {
|
|
111
|
+
const files = globSync(pattern, {
|
|
112
|
+
cwd: outputDir
|
|
113
|
+
});
|
|
114
|
+
for (const file of files) {
|
|
115
|
+
const filePath = path.join(outputDir, file);
|
|
116
|
+
try {
|
|
117
|
+
fs.unlinkSync(filePath);
|
|
118
|
+
totalFilesDeleted++;
|
|
119
|
+
if (verbose) {
|
|
120
|
+
console.log(`[post-cleanup] Deleted: ${file}`);
|
|
121
|
+
}
|
|
122
|
+
} catch (error) {
|
|
123
|
+
console.warn(`[post-cleanup] Failed to delete ${file}:`, error);
|
|
124
|
+
}
|
|
125
|
+
}
|
|
126
|
+
}
|
|
127
|
+
if (verbose && patterns.length > 0 && totalFilesDeleted === 0) {
|
|
128
|
+
console.log('[post-cleanup] No files matched the patterns');
|
|
129
|
+
}
|
|
130
|
+
}
|
|
131
|
+
};
|
|
132
|
+
}
|
|
133
|
+
|
|
94
134
|
async function run() {
|
|
95
135
|
var _context;
|
|
96
|
-
const CleanBuild = (await import('vite-plugin-clean-build')).default;
|
|
97
136
|
const DEFAULT_PORT = _parseInt(String(process.env.HTTP_PORT), 10) || 3001;
|
|
98
137
|
|
|
99
138
|
// Ensure the `/public` folder exists.
|
|
100
|
-
fs.mkdirSync(paths.appBuild, {
|
|
139
|
+
fs$1.mkdirSync(paths.appBuild, {
|
|
101
140
|
recursive: true
|
|
102
141
|
});
|
|
103
142
|
|
|
104
143
|
// Generate `index.html` (template).
|
|
105
|
-
const appEntryPoint = path.relative(paths.appRoot, paths.entryPoint);
|
|
144
|
+
const appEntryPoint = path$1.relative(paths.appRoot, paths.entryPoint);
|
|
106
145
|
const html = generateTemplate({
|
|
107
146
|
// Define the module entry point (path relative from the `/public` folder).
|
|
108
147
|
// NOTE: that this is different from the development configuration.
|
|
109
148
|
scriptImports: [`<script type="module" src="/${appEntryPoint}" defer></script>`]
|
|
110
149
|
});
|
|
111
150
|
// Write `index.html` (template) into the `/public` folder.
|
|
112
|
-
fs.writeFileSync(paths.appIndexHtml, html, {
|
|
151
|
+
fs$1.writeFileSync(paths.appIndexHtml, html, {
|
|
113
152
|
encoding: 'utf8'
|
|
114
153
|
});
|
|
115
154
|
const appDependencies = require(paths.appPackageJson).dependencies;
|
|
@@ -171,12 +210,11 @@ async function run() {
|
|
|
171
210
|
// Enable pre-parse default `formatjs` messages into AST.
|
|
172
211
|
// TODO: make it a CLI option when Vite support becomes stable.
|
|
173
212
|
process.env.ENABLE_I18N_AST === 'true'
|
|
174
|
-
}] : undefined]).call(_context, nonNullable)
|
|
213
|
+
}] : undefined, process.env.ENABLE_BABEL_REACT_COMPILER === 'true' ? 'babel-plugin-react-compiler' : undefined]).call(_context, nonNullable)
|
|
175
214
|
}
|
|
176
215
|
}),
|
|
177
|
-
//
|
|
178
|
-
|
|
179
|
-
CleanBuild({
|
|
216
|
+
// Clean up large SVG assets that are not used after the build.
|
|
217
|
+
pluginPostCleanup({
|
|
180
218
|
outputDir: paths.appBuild,
|
|
181
219
|
patterns: ['*.react-*.svg'],
|
|
182
220
|
verbose: true // logs the files that are removed
|
|
@@ -190,17 +228,17 @@ async function run() {
|
|
|
190
228
|
});
|
|
191
229
|
|
|
192
230
|
// Rename `/public/public/index.html` to `/public/index.html.template`
|
|
193
|
-
fs.renameSync(
|
|
231
|
+
fs$1.renameSync(
|
|
194
232
|
// Because of our custom entry point path (`/public/index.html`),
|
|
195
233
|
// Vite will write the `index.html` to `/public/public/index.html`.
|
|
196
234
|
// We need to move this file to the `/public` folder and rename it
|
|
197
235
|
// to `index.html.template` (as expected by the `compile-html` command).
|
|
198
|
-
path.join(paths.appBuild, 'public/index.html'), paths.appIndexHtmlTemplate);
|
|
236
|
+
path$1.join(paths.appBuild, 'public/index.html'), paths.appIndexHtmlTemplate);
|
|
199
237
|
// Clean up nested folder
|
|
200
|
-
fs.rmdirSync(path.join(paths.appBuild, 'public'));
|
|
238
|
+
fs$1.rmdirSync(path$1.join(paths.appBuild, 'public'));
|
|
201
239
|
|
|
202
240
|
// Copy public assets
|
|
203
|
-
fs.copySync(path.join(packageLocation, 'html-page'), paths.appBuild, {
|
|
241
|
+
fs$1.copySync(path$1.join(packageLocation, 'html-page'), paths.appBuild, {
|
|
204
242
|
dereference: true
|
|
205
243
|
});
|
|
206
244
|
}
|