@commercetools-frontend/mc-scripts 21.7.0 → 21.9.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/LICENSE +1 -1
- package/README.md +1 -42
- package/application-runtime/dist/commercetools-frontend-mc-scripts-application-runtime.cjs.d.ts +1 -0
- package/application-runtime/dist/commercetools-frontend-mc-scripts-application-runtime.cjs.dev.js +7 -0
- package/application-runtime/dist/commercetools-frontend-mc-scripts-application-runtime.cjs.js +7 -0
- package/{build/config/application-runtime.js → application-runtime/dist/commercetools-frontend-mc-scripts-application-runtime.cjs.prod.js} +2 -2
- package/application-runtime/dist/commercetools-frontend-mc-scripts-application-runtime.esm.js +5 -0
- package/application-runtime/package.json +4 -0
- package/bin/cli.js +1 -1
- package/cli/dist/commercetools-frontend-mc-scripts-cli.cjs.d.ts +1 -0
- package/cli/dist/commercetools-frontend-mc-scripts-cli.cjs.dev.js +361 -0
- package/cli/dist/commercetools-frontend-mc-scripts-cli.cjs.js +7 -0
- package/cli/dist/commercetools-frontend-mc-scripts-cli.cjs.prod.js +361 -0
- package/cli/dist/commercetools-frontend-mc-scripts-cli.esm.js +345 -0
- package/cli/package.json +4 -0
- package/config/create-webpack-config-for-development.js +7 -1
- package/config/create-webpack-config-for-production.js +7 -1
- package/config/vendors-to-transpile.js +5 -1
- package/dist/build-5357ad26.cjs.prod.js +224 -0
- package/dist/build-9b6d7eee.cjs.dev.js +224 -0
- package/dist/build-c483e87f.esm.js +209 -0
- package/dist/build-vite-3b82522e.cjs.dev.js +151 -0
- package/dist/build-vite-93abdc95.esm.js +139 -0
- package/dist/build-vite-b7cd993a.cjs.prod.js +151 -0
- package/dist/commercetools-frontend-mc-scripts.cjs.d.ts +1 -0
- package/dist/commercetools-frontend-mc-scripts.cjs.dev.js +30 -0
- package/dist/commercetools-frontend-mc-scripts.cjs.js +7 -0
- package/dist/commercetools-frontend-mc-scripts.cjs.prod.js +30 -0
- package/dist/commercetools-frontend-mc-scripts.esm.js +22 -0
- package/dist/compile-html-4361a0b3.esm.js +77 -0
- package/dist/compile-html-d6331c35.cjs.prod.js +87 -0
- package/dist/compile-html-d9e731aa.cjs.dev.js +87 -0
- package/dist/config-sync-6b31d972.esm.js +840 -0
- package/dist/config-sync-a478bc0f.cjs.dev.js +864 -0
- package/dist/config-sync-f07734e4.cjs.prod.js +859 -0
- package/{build/config/create-postcss-config.js → dist/create-postcss-config-04243dea.esm.js} +27 -25
- package/dist/create-postcss-config-760e2dc5.cjs.dev.js +90 -0
- package/dist/create-postcss-config-ddc3abee.cjs.prod.js +90 -0
- package/dist/create-webpack-config-for-development-76fdab59.cjs.prod.js +419 -0
- package/{build/config/create-webpack-config-for-development.js → dist/create-webpack-config-for-development-d93ae4b2.esm.js} +94 -57
- package/dist/create-webpack-config-for-development-dfd1c174.cjs.dev.js +419 -0
- package/{build/config/create-webpack-config-for-production.js → dist/create-webpack-config-for-production-9290479a.esm.js} +120 -54
- package/dist/create-webpack-config-for-production-bc8c1f37.cjs.dev.js +469 -0
- package/dist/create-webpack-config-for-production-d652ad1a.cjs.prod.js +469 -0
- package/dist/declarations/src/application-runtime.d.ts +1 -0
- package/dist/declarations/src/cli.d.ts +4 -0
- package/dist/declarations/src/commands/build-vite.d.ts +2 -0
- package/dist/declarations/src/commands/build.d.ts +2 -0
- package/dist/declarations/src/commands/compile-html.d.ts +3 -0
- package/dist/declarations/src/commands/config-sync.d.ts +3 -0
- package/dist/declarations/src/commands/login.d.ts +2 -0
- package/dist/declarations/src/commands/serve.d.ts +2 -0
- package/dist/declarations/src/commands/start-vite.d.ts +2 -0
- package/dist/declarations/src/commands/start.d.ts +2 -0
- package/dist/declarations/src/config/create-postcss-config.d.ts +4 -0
- package/dist/declarations/src/config/create-webpack-config-for-development.d.ts +10 -0
- package/dist/declarations/src/config/create-webpack-config-for-production.d.ts +10 -0
- package/dist/declarations/src/config/has-jsx-runtime.d.ts +2 -0
- package/dist/declarations/src/config/moment-locales.d.ts +2 -0
- package/dist/declarations/src/config/paths.d.ts +12 -0
- package/dist/declarations/src/config/vendors-to-transpile.d.ts +2 -0
- package/dist/declarations/src/config/webpack-dev-server.config.d.ts +6 -0
- package/dist/declarations/src/deprecated-entry-points.d.ts +7 -0
- package/dist/declarations/src/generated/core.d.ts +710 -0
- package/dist/declarations/src/generated/settings.d.ts +2485 -0
- package/dist/declarations/src/index.d.ts +3 -0
- package/dist/declarations/src/postcss.d.ts +1 -0
- package/dist/declarations/src/types.d.ts +82 -0
- package/dist/declarations/src/utils/auth.d.ts +6 -0
- package/dist/declarations/src/utils/credentials-storage.d.ts +11 -0
- package/dist/declarations/src/utils/get-config-diff.d.ts +3 -0
- package/dist/declarations/src/utils/graphql-requests.d.ts +80 -0
- package/dist/declarations/src/utils/user-agent.d.ts +2 -0
- package/dist/declarations/src/version.d.ts +2 -0
- package/dist/declarations/src/vite-plugins/vite-plugin-custom-application.d.ts +4 -0
- package/dist/declarations/src/vite-plugins/vite-plugin-dynamic-base-assets-globals.d.ts +3 -0
- package/dist/declarations/src/vite-plugins/vite-plugin-svgr.d.ts +3 -0
- package/dist/declarations/src/webpack-plugins/final-stats-writer-plugin.d.ts +12 -0
- package/dist/declarations/src/webpack-plugins/local-html-webpack-plugin.d.ts +5 -0
- package/dist/declarations/src/webpack.d.ts +2 -0
- package/dist/has-jsx-runtime-0b03b72e.cjs.prod.js +17 -0
- package/dist/has-jsx-runtime-3d4bb633.cjs.dev.js +17 -0
- package/{build/config/has-jsx-runtime.js → dist/has-jsx-runtime-8314226e.esm.js} +1 -3
- package/dist/login-7b7ae27e.esm.js +155 -0
- package/dist/login-b13f26e7.cjs.dev.js +165 -0
- package/dist/login-c11fb977.cjs.prod.js +165 -0
- package/dist/package-4b4fcf02.cjs.prod.js +139 -0
- package/dist/package-4c3e3fb7.cjs.dev.js +139 -0
- package/dist/package-8e6305bd.esm.js +137 -0
- package/dist/paths-16823f56.cjs.dev.js +55 -0
- package/dist/paths-76b66e74.cjs.prod.js +55 -0
- package/dist/paths-ed23d5a1.esm.js +46 -0
- package/dist/serve-12de323b.cjs.dev.js +70 -0
- package/dist/serve-784f4fcd.cjs.prod.js +70 -0
- package/dist/serve-d6b437b1.esm.js +62 -0
- package/dist/start-1b7dad90.cjs.prod.js +209 -0
- package/dist/start-45ca01f2.cjs.dev.js +209 -0
- package/dist/start-600d06a3.esm.js +194 -0
- package/dist/start-vite-22de08dc.cjs.dev.js +151 -0
- package/dist/start-vite-dc046cba.esm.js +138 -0
- package/dist/start-vite-fe13330b.cjs.prod.js +151 -0
- package/dist/user-agent-5f8ec93d.cjs.prod.js +106 -0
- package/dist/user-agent-ca628320.esm.js +94 -0
- package/dist/user-agent-ee57c98a.cjs.dev.js +106 -0
- package/dist/vendors-to-transpile-367e0ba8.cjs.prod.js +5 -0
- package/dist/vendors-to-transpile-68e03526.esm.js +3 -0
- package/dist/vendors-to-transpile-b51af5d3.cjs.dev.js +5 -0
- package/dist/vite-plugin-svgr-4205f2b5.cjs.dev.js +110 -0
- package/dist/vite-plugin-svgr-eb8524fa.esm.js +85 -0
- package/dist/vite-plugin-svgr-f3bbedbe.cjs.prod.js +110 -0
- package/package.json +56 -50
- package/postcss/dist/commercetools-frontend-mc-scripts-postcss.cjs.d.ts +1 -0
- package/postcss/dist/commercetools-frontend-mc-scripts-postcss.cjs.dev.js +14 -0
- package/postcss/dist/commercetools-frontend-mc-scripts-postcss.cjs.js +7 -0
- package/postcss/dist/commercetools-frontend-mc-scripts-postcss.cjs.prod.js +14 -0
- package/postcss/dist/commercetools-frontend-mc-scripts-postcss.esm.js +6 -0
- package/postcss/package.json +4 -0
- package/webpack/dist/commercetools-frontend-mc-scripts-webpack.cjs.d.ts +1 -0
- package/webpack/dist/commercetools-frontend-mc-scripts-webpack.cjs.dev.js +51 -0
- package/webpack/dist/commercetools-frontend-mc-scripts-webpack.cjs.js +7 -0
- package/webpack/dist/commercetools-frontend-mc-scripts-webpack.cjs.prod.js +51 -0
- package/webpack/dist/commercetools-frontend-mc-scripts-webpack.esm.js +42 -0
- package/webpack/package.json +4 -0
- package/build/bin/cli.js +0 -264
- package/build/commands/build-vite.js +0 -91
- package/build/commands/build.js +0 -140
- package/build/commands/compile-html.js +0 -53
- package/build/commands/config-sync.js +0 -176
- package/build/commands/login.js +0 -60
- package/build/commands/serve.js +0 -37
- package/build/commands/start-vite.js +0 -138
- package/build/commands/start.js +0 -108
- package/build/config/paths.js +0 -38
- package/build/config/vendors-to-transpile.js +0 -3
- package/build/config/webpack-dev-server.config.js +0 -69
- package/build/index.js +0 -16
- package/build/utils/auth.js +0 -34
- package/build/utils/auth.spec.js +0 -61
- package/build/utils/create-custom-application.settings.graphql +0 -8
- package/build/utils/credentials-storage.js +0 -72
- package/build/utils/credentials-storage.spec.js +0 -69
- package/build/utils/fetch-custom-application.settings.graphql +0 -36
- package/build/utils/fetch-user-organizations.core.graphql +0 -9
- package/build/utils/get-config-diff.js +0 -308
- package/build/utils/get-config-diff.spec.js +0 -285
- package/build/utils/graphql-requests.js +0 -105
- package/build/utils/graphql-requests.spec.js +0 -159
- package/build/utils/require-graphql.js +0 -15
- package/build/utils/update-custom-application.settings.graphql +0 -13
- package/build/utils/user-agent.js +0 -15
- package/build/webpack-plugins/final-stats-writer-plugin.js +0 -50
- package/build/webpack-plugins/local-html-webpack-plugin.js +0 -38
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { default as createPostcssConfig } from './config/create-postcss-config';
|
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
export declare type TCliGlobalOptions = {
|
|
2
|
+
'--'?: string[];
|
|
3
|
+
env?: string[];
|
|
4
|
+
};
|
|
5
|
+
export declare type TCliCommandBuildOptions = {
|
|
6
|
+
buildOnly: boolean;
|
|
7
|
+
};
|
|
8
|
+
export declare type TCliCommandCompileHtmlOptions = {
|
|
9
|
+
transformer?: string;
|
|
10
|
+
printSecurityHeaders: boolean;
|
|
11
|
+
};
|
|
12
|
+
export declare type TCliCommandConfigSyncOptions = {
|
|
13
|
+
dryRun: boolean;
|
|
14
|
+
};
|
|
15
|
+
export declare type TMcCliAuthToken = {
|
|
16
|
+
token: string;
|
|
17
|
+
expiresAt: number;
|
|
18
|
+
};
|
|
19
|
+
export declare type TMcCliCredentialsStorage = Record<string, TMcCliAuthToken>;
|
|
20
|
+
/**
|
|
21
|
+
* Configuration options to extend the default configuration
|
|
22
|
+
*/
|
|
23
|
+
export declare type TPostcssConfigOptions = {
|
|
24
|
+
/**
|
|
25
|
+
* A list of paths where to look for files used by the `@import` statements.
|
|
26
|
+
*/
|
|
27
|
+
postcssImportPaths?: string[];
|
|
28
|
+
/**
|
|
29
|
+
* A list of paths where to look for files with custom media queries.
|
|
30
|
+
*/
|
|
31
|
+
postcssCustomMediaPaths?: string[];
|
|
32
|
+
/**
|
|
33
|
+
* A list of paths where to look for files with custom properties.
|
|
34
|
+
*/
|
|
35
|
+
postcssCustomPropertiesPaths?: string[];
|
|
36
|
+
};
|
|
37
|
+
export declare type TWebpackConfigMode = 'development' | 'production';
|
|
38
|
+
export declare type TWebpackConfigToggleFlagsForDevelopment = {
|
|
39
|
+
/**
|
|
40
|
+
* Allow to disable index.html generation in case it's not necessary (e.g. for Storybook)
|
|
41
|
+
*/
|
|
42
|
+
generateIndexHtml?: boolean;
|
|
43
|
+
/**
|
|
44
|
+
* Some environemnts do not require `core-js` and can hence disable
|
|
45
|
+
* it explicitely. This will disable `core-js` for `preset-env` and the
|
|
46
|
+
* `plugin-transform-runtime`.
|
|
47
|
+
*/
|
|
48
|
+
disableCoreJs?: boolean;
|
|
49
|
+
};
|
|
50
|
+
export declare type TWebpackConfigToggleFlagsForProduction = TWebpackConfigToggleFlagsForDevelopment & {
|
|
51
|
+
/**
|
|
52
|
+
* Allow to disable CSS extraction in case it's not necessary (e.g. for Storybook)
|
|
53
|
+
*/
|
|
54
|
+
enableExtractCss?: boolean;
|
|
55
|
+
/**
|
|
56
|
+
* Some plugins spawn workers to speed up the build. However this can cause trouble on
|
|
57
|
+
* certain machines local and CI. This flag set to limit or disable any parallelism.
|
|
58
|
+
* Options:
|
|
59
|
+
* `true` to default to the machines number of CPUs
|
|
60
|
+
* `false` to disable any paralelism
|
|
61
|
+
* `int` for a specific number of CPUs
|
|
62
|
+
*/
|
|
63
|
+
parallelism: true;
|
|
64
|
+
};
|
|
65
|
+
export declare type TWebpackConfigOptions<ConfigMode extends TWebpackConfigMode> = {
|
|
66
|
+
/**
|
|
67
|
+
* The absolute path to the application entry point file.
|
|
68
|
+
*/
|
|
69
|
+
entryPoint?: string;
|
|
70
|
+
/**
|
|
71
|
+
* A list of folders where Webpack should look for source files.
|
|
72
|
+
*/
|
|
73
|
+
sourceFolders?: string[];
|
|
74
|
+
/**
|
|
75
|
+
* Options related to Postcss plugins. See `createPostcssConfig` function.
|
|
76
|
+
*/
|
|
77
|
+
postcssOptions?: TPostcssConfigOptions;
|
|
78
|
+
/**
|
|
79
|
+
* Options to enable/disable certain functionalities of the Webpack config.
|
|
80
|
+
*/
|
|
81
|
+
toggleFlags?: ConfigMode extends 'development' ? TWebpackConfigToggleFlagsForDevelopment : ConfigMode extends 'production' ? TWebpackConfigToggleFlagsForProduction : never;
|
|
82
|
+
};
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import type { TMcCliAuthToken, TMcCliCredentialsStorage } from '../types';
|
|
2
|
+
declare class CredentialsStorage {
|
|
3
|
+
static location: string;
|
|
4
|
+
constructor();
|
|
5
|
+
_writeCredentials(credentials?: TMcCliCredentialsStorage): void;
|
|
6
|
+
_loadCredentials(): TMcCliCredentialsStorage;
|
|
7
|
+
getToken(environmentKey: string): string | null;
|
|
8
|
+
setToken(environmentKey: string, credentials: TMcCliAuthToken): void;
|
|
9
|
+
isSessionValid(environmentKey: string): boolean;
|
|
10
|
+
}
|
|
11
|
+
export default CredentialsStorage;
|
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
import type { TCustomApplicationDraftDataInput } from '../generated/settings';
|
|
2
|
+
declare type TFetchCustomApplicationOptions = {
|
|
3
|
+
mcApiUrl: string;
|
|
4
|
+
token: string;
|
|
5
|
+
entryPointUriPath: string;
|
|
6
|
+
};
|
|
7
|
+
declare type TUpdateCustomApplicationOptions = {
|
|
8
|
+
mcApiUrl: string;
|
|
9
|
+
token: string;
|
|
10
|
+
applicationId: string;
|
|
11
|
+
organizationId: string;
|
|
12
|
+
data: TCustomApplicationDraftDataInput;
|
|
13
|
+
};
|
|
14
|
+
declare type TCreateCustomApplicationOptions = {
|
|
15
|
+
mcApiUrl: string;
|
|
16
|
+
token: string;
|
|
17
|
+
organizationId: string;
|
|
18
|
+
data: TCustomApplicationDraftDataInput;
|
|
19
|
+
};
|
|
20
|
+
declare type TFetchUserOrganizationsOptions = {
|
|
21
|
+
mcApiUrl: string;
|
|
22
|
+
token: string;
|
|
23
|
+
};
|
|
24
|
+
declare const fetchCustomApplication: ({ mcApiUrl, token, entryPointUriPath, }: TFetchCustomApplicationOptions) => Promise<{
|
|
25
|
+
__typename?: "OrganizationExtensionForCustomApplication" | undefined;
|
|
26
|
+
organizationId: string;
|
|
27
|
+
application: {
|
|
28
|
+
__typename?: "RestrictedCustomApplicationForOrganization" | undefined;
|
|
29
|
+
id: string;
|
|
30
|
+
entryPointUriPath: string;
|
|
31
|
+
name: string;
|
|
32
|
+
description?: string | null | undefined;
|
|
33
|
+
url: string;
|
|
34
|
+
icon: string;
|
|
35
|
+
permissions: {
|
|
36
|
+
__typename?: "CustomApplicationPermission" | undefined;
|
|
37
|
+
name: string;
|
|
38
|
+
oAuthScopes: string[];
|
|
39
|
+
}[];
|
|
40
|
+
mainMenuLink: {
|
|
41
|
+
__typename?: "CustomApplicationMenuLink" | undefined;
|
|
42
|
+
defaultLabel: string;
|
|
43
|
+
permissions: string[];
|
|
44
|
+
labelAllLocales: {
|
|
45
|
+
__typename?: "LocalizedField" | undefined;
|
|
46
|
+
locale: string;
|
|
47
|
+
value: string;
|
|
48
|
+
}[];
|
|
49
|
+
};
|
|
50
|
+
submenuLinks: {
|
|
51
|
+
__typename?: "CustomApplicationSubmenuLink" | undefined;
|
|
52
|
+
uriPath: string;
|
|
53
|
+
defaultLabel: string;
|
|
54
|
+
permissions: string[];
|
|
55
|
+
labelAllLocales: {
|
|
56
|
+
__typename?: "LocalizedField" | undefined;
|
|
57
|
+
locale: string;
|
|
58
|
+
value: string;
|
|
59
|
+
}[];
|
|
60
|
+
}[];
|
|
61
|
+
};
|
|
62
|
+
} | null | undefined>;
|
|
63
|
+
declare const updateCustomApplication: ({ mcApiUrl, token, applicationId, organizationId, data, }: TUpdateCustomApplicationOptions) => Promise<{
|
|
64
|
+
__typename?: "RestrictedCustomApplicationForOrganization" | undefined;
|
|
65
|
+
id: string;
|
|
66
|
+
} | null | undefined>;
|
|
67
|
+
declare const createCustomApplication: ({ mcApiUrl, token, organizationId, data, }: TCreateCustomApplicationOptions) => Promise<{
|
|
68
|
+
__typename?: "RestrictedCustomApplicationForOrganization" | undefined;
|
|
69
|
+
id: string;
|
|
70
|
+
} | null | undefined>;
|
|
71
|
+
declare const fetchUserOrganizations: ({ mcApiUrl, token, }: TFetchUserOrganizationsOptions) => Promise<{
|
|
72
|
+
__typename?: "OrganizationQueryResult" | undefined;
|
|
73
|
+
total: any;
|
|
74
|
+
results: {
|
|
75
|
+
__typename?: "Organization" | undefined;
|
|
76
|
+
id: string;
|
|
77
|
+
name: string;
|
|
78
|
+
}[];
|
|
79
|
+
}>;
|
|
80
|
+
export { fetchCustomApplication, updateCustomApplication, createCustomApplication, fetchUserOrganizations, };
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import type { Plugin } from 'vite';
|
|
2
|
+
import type { ApplicationRuntimeConfig } from '@commercetools-frontend/application-config';
|
|
3
|
+
declare const vitePluginCustomApplication: (applicationConfig: ApplicationRuntimeConfig) => Plugin;
|
|
4
|
+
export default vitePluginCustomApplication;
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import type { Compiler, Stats } from 'webpack';
|
|
2
|
+
declare type TFinalStatsWriterPluginOptions = {
|
|
3
|
+
outputPath: string;
|
|
4
|
+
includeFields: string[];
|
|
5
|
+
};
|
|
6
|
+
declare class FinalStatsWriterPlugin {
|
|
7
|
+
config: TFinalStatsWriterPluginOptions;
|
|
8
|
+
constructor(config: TFinalStatsWriterPluginOptions);
|
|
9
|
+
apply(compiler: Compiler): void;
|
|
10
|
+
writeStats(stats: Stats): void;
|
|
11
|
+
}
|
|
12
|
+
export default FinalStatsWriterPlugin;
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
function hasJsxRuntime() {
|
|
4
|
+
if (process.env.ENABLE_NEW_JSX_TRANSFORM !== 'true') {
|
|
5
|
+
return false;
|
|
6
|
+
}
|
|
7
|
+
|
|
8
|
+
try {
|
|
9
|
+
require.resolve('react/jsx-runtime');
|
|
10
|
+
|
|
11
|
+
return true;
|
|
12
|
+
} catch (e) {
|
|
13
|
+
return false;
|
|
14
|
+
}
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
exports.hasJsxRuntime = hasJsxRuntime;
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
function hasJsxRuntime() {
|
|
4
|
+
if (process.env.ENABLE_NEW_JSX_TRANSFORM !== 'true') {
|
|
5
|
+
return false;
|
|
6
|
+
}
|
|
7
|
+
|
|
8
|
+
try {
|
|
9
|
+
require.resolve('react/jsx-runtime');
|
|
10
|
+
|
|
11
|
+
return true;
|
|
12
|
+
} catch (e) {
|
|
13
|
+
return false;
|
|
14
|
+
}
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
exports.hasJsxRuntime = hasJsxRuntime;
|
|
@@ -0,0 +1,155 @@
|
|
|
1
|
+
import _asyncToGenerator from '@babel/runtime-corejs3/helpers/esm/asyncToGenerator';
|
|
2
|
+
import _regeneratorRuntime from '@babel/runtime-corejs3/regenerator';
|
|
3
|
+
import prompts from 'prompts';
|
|
4
|
+
import chalk from 'chalk';
|
|
5
|
+
import { processConfig } from '@commercetools-frontend/application-config';
|
|
6
|
+
import { u as userAgent, C as CredentialsStorage } from './user-agent-ca628320.esm.js';
|
|
7
|
+
import _JSON$stringify from '@babel/runtime-corejs3/core-js-stable/json/stringify';
|
|
8
|
+
import fetch from 'node-fetch';
|
|
9
|
+
import '@babel/runtime-corejs3/helpers/classCallCheck';
|
|
10
|
+
import '@babel/runtime-corejs3/helpers/createClass';
|
|
11
|
+
import '@babel/runtime-corejs3/core-js-stable/date/now';
|
|
12
|
+
import 'fs';
|
|
13
|
+
import 'path';
|
|
14
|
+
import 'os';
|
|
15
|
+
import '@commercetools/http-user-agent';
|
|
16
|
+
import './package-8e6305bd.esm.js';
|
|
17
|
+
|
|
18
|
+
var getAuthToken = /*#__PURE__*/function () {
|
|
19
|
+
var _ref = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee(mcApiUrl, payload) {
|
|
20
|
+
var response, text, parsed, errorMessage, authToken;
|
|
21
|
+
return _regeneratorRuntime.wrap(function _callee$(_context) {
|
|
22
|
+
while (1) {
|
|
23
|
+
switch (_context.prev = _context.next) {
|
|
24
|
+
case 0:
|
|
25
|
+
_context.next = 2;
|
|
26
|
+
return fetch("".concat(mcApiUrl, "/tokens/cli"), {
|
|
27
|
+
method: 'POST',
|
|
28
|
+
headers: {
|
|
29
|
+
Accept: 'application/json',
|
|
30
|
+
'Content-Type': 'application/json',
|
|
31
|
+
'x-user-agent': userAgent
|
|
32
|
+
},
|
|
33
|
+
body: _JSON$stringify(payload)
|
|
34
|
+
});
|
|
35
|
+
|
|
36
|
+
case 2:
|
|
37
|
+
response = _context.sent;
|
|
38
|
+
|
|
39
|
+
if (response.ok) {
|
|
40
|
+
_context.next = 10;
|
|
41
|
+
break;
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
_context.next = 6;
|
|
45
|
+
return response.text();
|
|
46
|
+
|
|
47
|
+
case 6:
|
|
48
|
+
text = _context.sent;
|
|
49
|
+
|
|
50
|
+
try {
|
|
51
|
+
parsed = JSON.parse(text);
|
|
52
|
+
} catch (error) {}
|
|
53
|
+
|
|
54
|
+
errorMessage = parsed ? parsed.message : text;
|
|
55
|
+
throw new Error(errorMessage);
|
|
56
|
+
|
|
57
|
+
case 10:
|
|
58
|
+
_context.next = 12;
|
|
59
|
+
return response.json();
|
|
60
|
+
|
|
61
|
+
case 12:
|
|
62
|
+
authToken = _context.sent;
|
|
63
|
+
return _context.abrupt("return", authToken);
|
|
64
|
+
|
|
65
|
+
case 14:
|
|
66
|
+
case "end":
|
|
67
|
+
return _context.stop();
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
}, _callee);
|
|
71
|
+
}));
|
|
72
|
+
|
|
73
|
+
return function getAuthToken(_x, _x2) {
|
|
74
|
+
return _ref.apply(this, arguments);
|
|
75
|
+
};
|
|
76
|
+
}();
|
|
77
|
+
|
|
78
|
+
var credentialsStorage = new CredentialsStorage();
|
|
79
|
+
|
|
80
|
+
function run() {
|
|
81
|
+
return _run.apply(this, arguments);
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
function _run() {
|
|
85
|
+
_run = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee() {
|
|
86
|
+
var applicationConfig, mcApiUrl, _yield$prompts, email, _yield$prompts2, password, credentials;
|
|
87
|
+
|
|
88
|
+
return _regeneratorRuntime.wrap(function _callee$(_context) {
|
|
89
|
+
while (1) {
|
|
90
|
+
switch (_context.prev = _context.next) {
|
|
91
|
+
case 0:
|
|
92
|
+
applicationConfig = processConfig();
|
|
93
|
+
mcApiUrl = applicationConfig.env.mcApiUrl;
|
|
94
|
+
|
|
95
|
+
if (!credentialsStorage.isSessionValid(mcApiUrl)) {
|
|
96
|
+
_context.next = 5;
|
|
97
|
+
break;
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
console.log("You already have a valid session for the ".concat(mcApiUrl, " environment.\n"));
|
|
101
|
+
return _context.abrupt("return");
|
|
102
|
+
|
|
103
|
+
case 5:
|
|
104
|
+
console.log(chalk.gray("Enter the login credentials for the ".concat(mcApiUrl, " environment.\n")));
|
|
105
|
+
_context.next = 8;
|
|
106
|
+
return prompts({
|
|
107
|
+
type: 'text',
|
|
108
|
+
name: 'email',
|
|
109
|
+
message: 'Email'
|
|
110
|
+
});
|
|
111
|
+
|
|
112
|
+
case 8:
|
|
113
|
+
_yield$prompts = _context.sent;
|
|
114
|
+
email = _yield$prompts.email;
|
|
115
|
+
_context.next = 12;
|
|
116
|
+
return prompts({
|
|
117
|
+
type: 'invisible',
|
|
118
|
+
name: 'password',
|
|
119
|
+
message: 'Password (hidden)'
|
|
120
|
+
});
|
|
121
|
+
|
|
122
|
+
case 12:
|
|
123
|
+
_yield$prompts2 = _context.sent;
|
|
124
|
+
password = _yield$prompts2.password;
|
|
125
|
+
|
|
126
|
+
if (!(!email || !password)) {
|
|
127
|
+
_context.next = 16;
|
|
128
|
+
break;
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
throw new Error("Missing email or password values. Aborting.");
|
|
132
|
+
|
|
133
|
+
case 16:
|
|
134
|
+
_context.next = 18;
|
|
135
|
+
return getAuthToken(mcApiUrl, {
|
|
136
|
+
email: email,
|
|
137
|
+
password: password
|
|
138
|
+
});
|
|
139
|
+
|
|
140
|
+
case 18:
|
|
141
|
+
credentials = _context.sent;
|
|
142
|
+
credentialsStorage.setToken(mcApiUrl, credentials);
|
|
143
|
+
console.log(chalk.green("Login successful.\n"));
|
|
144
|
+
|
|
145
|
+
case 21:
|
|
146
|
+
case "end":
|
|
147
|
+
return _context.stop();
|
|
148
|
+
}
|
|
149
|
+
}
|
|
150
|
+
}, _callee);
|
|
151
|
+
}));
|
|
152
|
+
return _run.apply(this, arguments);
|
|
153
|
+
}
|
|
154
|
+
|
|
155
|
+
export { run as default };
|
|
@@ -0,0 +1,165 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var _asyncToGenerator = require('@babel/runtime-corejs3/helpers/asyncToGenerator');
|
|
4
|
+
var _regeneratorRuntime = require('@babel/runtime-corejs3/regenerator');
|
|
5
|
+
var prompts = require('prompts');
|
|
6
|
+
var chalk = require('chalk');
|
|
7
|
+
var applicationConfig = require('@commercetools-frontend/application-config');
|
|
8
|
+
var userAgent = require('./user-agent-ee57c98a.cjs.dev.js');
|
|
9
|
+
var _JSON$stringify = require('@babel/runtime-corejs3/core-js-stable/json/stringify');
|
|
10
|
+
var fetch = require('node-fetch');
|
|
11
|
+
require('@babel/runtime-corejs3/helpers/classCallCheck');
|
|
12
|
+
require('@babel/runtime-corejs3/helpers/createClass');
|
|
13
|
+
require('@babel/runtime-corejs3/core-js-stable/date/now');
|
|
14
|
+
require('fs');
|
|
15
|
+
require('path');
|
|
16
|
+
require('os');
|
|
17
|
+
require('@commercetools/http-user-agent');
|
|
18
|
+
require('./package-4c3e3fb7.cjs.dev.js');
|
|
19
|
+
|
|
20
|
+
function _interopDefault (e) { return e && e.__esModule ? e : { 'default': e }; }
|
|
21
|
+
|
|
22
|
+
var _regeneratorRuntime__default = /*#__PURE__*/_interopDefault(_regeneratorRuntime);
|
|
23
|
+
var prompts__default = /*#__PURE__*/_interopDefault(prompts);
|
|
24
|
+
var chalk__default = /*#__PURE__*/_interopDefault(chalk);
|
|
25
|
+
var _JSON$stringify__default = /*#__PURE__*/_interopDefault(_JSON$stringify);
|
|
26
|
+
var fetch__default = /*#__PURE__*/_interopDefault(fetch);
|
|
27
|
+
|
|
28
|
+
var getAuthToken = /*#__PURE__*/function () {
|
|
29
|
+
var _ref = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime__default["default"].mark(function _callee(mcApiUrl, payload) {
|
|
30
|
+
var response, text, parsed, errorMessage, authToken;
|
|
31
|
+
return _regeneratorRuntime__default["default"].wrap(function _callee$(_context) {
|
|
32
|
+
while (1) {
|
|
33
|
+
switch (_context.prev = _context.next) {
|
|
34
|
+
case 0:
|
|
35
|
+
_context.next = 2;
|
|
36
|
+
return fetch__default["default"]("".concat(mcApiUrl, "/tokens/cli"), {
|
|
37
|
+
method: 'POST',
|
|
38
|
+
headers: {
|
|
39
|
+
Accept: 'application/json',
|
|
40
|
+
'Content-Type': 'application/json',
|
|
41
|
+
'x-user-agent': userAgent.userAgent
|
|
42
|
+
},
|
|
43
|
+
body: _JSON$stringify__default["default"](payload)
|
|
44
|
+
});
|
|
45
|
+
|
|
46
|
+
case 2:
|
|
47
|
+
response = _context.sent;
|
|
48
|
+
|
|
49
|
+
if (response.ok) {
|
|
50
|
+
_context.next = 10;
|
|
51
|
+
break;
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
_context.next = 6;
|
|
55
|
+
return response.text();
|
|
56
|
+
|
|
57
|
+
case 6:
|
|
58
|
+
text = _context.sent;
|
|
59
|
+
|
|
60
|
+
try {
|
|
61
|
+
parsed = JSON.parse(text);
|
|
62
|
+
} catch (error) {}
|
|
63
|
+
|
|
64
|
+
errorMessage = parsed ? parsed.message : text;
|
|
65
|
+
throw new Error(errorMessage);
|
|
66
|
+
|
|
67
|
+
case 10:
|
|
68
|
+
_context.next = 12;
|
|
69
|
+
return response.json();
|
|
70
|
+
|
|
71
|
+
case 12:
|
|
72
|
+
authToken = _context.sent;
|
|
73
|
+
return _context.abrupt("return", authToken);
|
|
74
|
+
|
|
75
|
+
case 14:
|
|
76
|
+
case "end":
|
|
77
|
+
return _context.stop();
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
}, _callee);
|
|
81
|
+
}));
|
|
82
|
+
|
|
83
|
+
return function getAuthToken(_x, _x2) {
|
|
84
|
+
return _ref.apply(this, arguments);
|
|
85
|
+
};
|
|
86
|
+
}();
|
|
87
|
+
|
|
88
|
+
var credentialsStorage = new userAgent.CredentialsStorage();
|
|
89
|
+
|
|
90
|
+
function run() {
|
|
91
|
+
return _run.apply(this, arguments);
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
function _run() {
|
|
95
|
+
_run = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime__default["default"].mark(function _callee() {
|
|
96
|
+
var applicationConfig$1, mcApiUrl, _yield$prompts, email, _yield$prompts2, password, credentials;
|
|
97
|
+
|
|
98
|
+
return _regeneratorRuntime__default["default"].wrap(function _callee$(_context) {
|
|
99
|
+
while (1) {
|
|
100
|
+
switch (_context.prev = _context.next) {
|
|
101
|
+
case 0:
|
|
102
|
+
applicationConfig$1 = applicationConfig.processConfig();
|
|
103
|
+
mcApiUrl = applicationConfig$1.env.mcApiUrl;
|
|
104
|
+
|
|
105
|
+
if (!credentialsStorage.isSessionValid(mcApiUrl)) {
|
|
106
|
+
_context.next = 5;
|
|
107
|
+
break;
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
console.log("You already have a valid session for the ".concat(mcApiUrl, " environment.\n"));
|
|
111
|
+
return _context.abrupt("return");
|
|
112
|
+
|
|
113
|
+
case 5:
|
|
114
|
+
console.log(chalk__default["default"].gray("Enter the login credentials for the ".concat(mcApiUrl, " environment.\n")));
|
|
115
|
+
_context.next = 8;
|
|
116
|
+
return prompts__default["default"]({
|
|
117
|
+
type: 'text',
|
|
118
|
+
name: 'email',
|
|
119
|
+
message: 'Email'
|
|
120
|
+
});
|
|
121
|
+
|
|
122
|
+
case 8:
|
|
123
|
+
_yield$prompts = _context.sent;
|
|
124
|
+
email = _yield$prompts.email;
|
|
125
|
+
_context.next = 12;
|
|
126
|
+
return prompts__default["default"]({
|
|
127
|
+
type: 'invisible',
|
|
128
|
+
name: 'password',
|
|
129
|
+
message: 'Password (hidden)'
|
|
130
|
+
});
|
|
131
|
+
|
|
132
|
+
case 12:
|
|
133
|
+
_yield$prompts2 = _context.sent;
|
|
134
|
+
password = _yield$prompts2.password;
|
|
135
|
+
|
|
136
|
+
if (!(!email || !password)) {
|
|
137
|
+
_context.next = 16;
|
|
138
|
+
break;
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
throw new Error("Missing email or password values. Aborting.");
|
|
142
|
+
|
|
143
|
+
case 16:
|
|
144
|
+
_context.next = 18;
|
|
145
|
+
return getAuthToken(mcApiUrl, {
|
|
146
|
+
email: email,
|
|
147
|
+
password: password
|
|
148
|
+
});
|
|
149
|
+
|
|
150
|
+
case 18:
|
|
151
|
+
credentials = _context.sent;
|
|
152
|
+
credentialsStorage.setToken(mcApiUrl, credentials);
|
|
153
|
+
console.log(chalk__default["default"].green("Login successful.\n"));
|
|
154
|
+
|
|
155
|
+
case 21:
|
|
156
|
+
case "end":
|
|
157
|
+
return _context.stop();
|
|
158
|
+
}
|
|
159
|
+
}
|
|
160
|
+
}, _callee);
|
|
161
|
+
}));
|
|
162
|
+
return _run.apply(this, arguments);
|
|
163
|
+
}
|
|
164
|
+
|
|
165
|
+
exports["default"] = run;
|