@nizza/devkit 0.1.3-beta.1 → 0.1.3-beta.2
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/dist/cjs/executors/shared/utils.cjs +3 -3
- package/dist/cjs/executors/verify-changesets/index.cjs +39 -0
- package/dist/cjs/executors/verify-changesets/schema.json +8 -0
- package/dist/cjs/index.cjs +6 -4
- package/dist/cjs/vitejs/config-builder/configs/base.cjs +1 -1
- package/dist/esm/executors/shared/utils.mjs +3 -3
- package/dist/esm/executors/verify-changesets/index.mjs +37 -0
- package/dist/esm/executors/verify-changesets/schema.json +8 -0
- package/dist/esm/index.mjs +1 -0
- package/dist/esm/vitejs/config-builder/configs/base.mjs +1 -1
- package/executors.json +5 -0
- package/package.json +1 -1
- package/dist/index.d.ts +0 -369
|
@@ -52,10 +52,10 @@ async function runCommand(command, cwd) {
|
|
|
52
52
|
cwd
|
|
53
53
|
}
|
|
54
54
|
});
|
|
55
|
-
devkit.logger.info(stdout);
|
|
55
|
+
stdout && devkit.logger.info(stdout);
|
|
56
56
|
if (stderr) {
|
|
57
|
-
devkit.logger.
|
|
58
|
-
devkit.logger.
|
|
57
|
+
devkit.logger.warn('Error Output:');
|
|
58
|
+
devkit.logger.info(stderr);
|
|
59
59
|
}
|
|
60
60
|
} catch (error) {
|
|
61
61
|
devkit.logger.error(`Unexpected error running command:`);
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var chalk = require('chalk');
|
|
4
|
+
var fs = require('fs');
|
|
5
|
+
var path = require('path');
|
|
6
|
+
require('../../shared/logger.cjs');
|
|
7
|
+
var utils$1 = require('../../shared/utils.cjs');
|
|
8
|
+
var utils = require('../shared/utils.cjs');
|
|
9
|
+
|
|
10
|
+
const { readFile, readdir } = fs.promises;
|
|
11
|
+
/**
|
|
12
|
+
* Executor function to verify if the current library has a corresponding changeset.
|
|
13
|
+
*
|
|
14
|
+
* @param {ExecutorContext} ctx - The executor context.
|
|
15
|
+
* @returns {Promise<ExecutorResponse>} The result object with a success or error status.
|
|
16
|
+
*/ async function runExecutor(_opts, ctx) {
|
|
17
|
+
try {
|
|
18
|
+
const { root: projectRoot } = utils.getProjectConfig(ctx);
|
|
19
|
+
const packageJson = utils$1.getPkgJson(projectRoot);
|
|
20
|
+
const { name: packageName } = packageJson;
|
|
21
|
+
const changesetPath = path.join(ctx.root, '.changeset');
|
|
22
|
+
const preJsonPath = path.join(changesetPath, 'pre.json');
|
|
23
|
+
const changesetData = JSON.parse(await readFile(preJsonPath, 'utf8'));
|
|
24
|
+
const ignoredChangesets = new Set(changesetData.changesets.map((name)=>name + '.md'));
|
|
25
|
+
const changesetFiles = (await readdir(changesetPath)).filter((file)=>file.endsWith('.md') && !ignoredChangesets.has(file));
|
|
26
|
+
const packageRegex = new RegExp(`['"]${packageName}['"]:`, 'm');
|
|
27
|
+
const checks = changesetFiles.map((file)=>readFile(path.join(changesetPath, file), 'utf8').then((content)=>packageRegex.test(content)));
|
|
28
|
+
const results = await Promise.all(checks);
|
|
29
|
+
if (!results.includes(true)) {
|
|
30
|
+
const errorMessage = chalk.red(`🔴 No changeset entry found for `) + chalk.cyan(packageName) + '\n' + chalk.yellow('📝 Remember to create a changeset for publishable npm libraries. Use the command ') + chalk.green("'pnpm cs'.") + '\n' + 'For more details, check out: ' + chalk.underline('https://www.notion.so/vtexhandbook/Flujo-de-trabajo-con-changeset-para-publicaci-n-en-npm-3ee6525ecff849fa8acc18273b15deac?pvs=4');
|
|
31
|
+
return utils.err(undefined, errorMessage);
|
|
32
|
+
}
|
|
33
|
+
return utils.ok(`🟢 Changeset verification successful for ${packageName}`);
|
|
34
|
+
} catch (error) {
|
|
35
|
+
return utils.err(error, `❌ Error verifying changeset for the library: ${error.message}`);
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
module.exports = runExecutor;
|
package/dist/cjs/index.cjs
CHANGED
|
@@ -4,14 +4,15 @@ var index = require('./executors/deploy/index.cjs');
|
|
|
4
4
|
var index$1 = require('./executors/environments/index.cjs');
|
|
5
5
|
var index$2 = require('./executors/publish/index.cjs');
|
|
6
6
|
var index$3 = require('./executors/update-executors-file/index.cjs');
|
|
7
|
-
var index$4 = require('./executors/
|
|
7
|
+
var index$4 = require('./executors/verify-changesets/index.cjs');
|
|
8
|
+
var index$5 = require('./executors/vtex-link/index.cjs');
|
|
8
9
|
var main = require('./vitejs/config-builder/main.cjs');
|
|
9
10
|
var types = require('./vitejs/config-builder/shared/types.cjs');
|
|
10
11
|
var helpers = require('./vitejs/config-builder/shared/utils/helpers.cjs');
|
|
11
12
|
var projectConfig = require('./vitejs/config-builder/shared/utils/projectConfig.cjs');
|
|
12
13
|
var viteCommand = require('./vitejs/config-builder/shared/utils/viteCommand.cjs');
|
|
13
14
|
var main$1 = require('./vitejs/plugins/third-party-css-inject/main.cjs');
|
|
14
|
-
var index$
|
|
15
|
+
var index$6 = require('./vitejs/plugins/shadow-dom-inject-css/index.cjs');
|
|
15
16
|
|
|
16
17
|
|
|
17
18
|
|
|
@@ -19,7 +20,8 @@ exports.deployExecutor = index;
|
|
|
19
20
|
exports.environmentsExecutor = index$1;
|
|
20
21
|
exports.publishExecutor = index$2;
|
|
21
22
|
exports.updateExecutorsFileExecutor = index$3;
|
|
22
|
-
exports.
|
|
23
|
+
exports.verifyChangesetsExecutor = index$4;
|
|
24
|
+
exports.vtexLinkExecutor = index$5;
|
|
23
25
|
exports.createConfigBuilder = main.createConfigBuilder;
|
|
24
26
|
Object.defineProperty(exports, "Flag", {
|
|
25
27
|
enumerable: true,
|
|
@@ -53,4 +55,4 @@ exports.mergeConfigs = projectConfig.mergeConfigs;
|
|
|
53
55
|
exports.getViteCmdFlags = viteCommand.getViteCmdFlags;
|
|
54
56
|
exports.getViteCommand = viteCommand.getViteCommand;
|
|
55
57
|
exports.thirdPartyCssInjectPlugin = main$1.thirdPartyCssInjectPlugin;
|
|
56
|
-
exports.injectCssIntoShadowDom = index$
|
|
58
|
+
exports.injectCssIntoShadowDom = index$6.injectCssIntoShadowDom;
|
|
@@ -18,7 +18,7 @@ const getBaseConfig = (ctx)=>{
|
|
|
18
18
|
const { resolveEnvs, path: path$1 } = projectConfig;
|
|
19
19
|
const { stage, target, flags: cmdOverrides } = viteCmd;
|
|
20
20
|
const NODE_ENV = target === types.Target.BUILD ? types.ViteMode.PROD : types.ViteMode.DEV;
|
|
21
|
-
const sourcemap = cmdOverrides?.[types.Flag.SOURCEMAP] ??
|
|
21
|
+
const sourcemap = cmdOverrides?.[types.Flag.SOURCEMAP] ?? true;
|
|
22
22
|
const envPrefix = `${commonConfig.envPrefix.toUpperCase()}_`;
|
|
23
23
|
const omittedStages = resolveEnvs.local ? [
|
|
24
24
|
types.Stage.DEV
|
|
@@ -50,10 +50,10 @@ async function runCommand(command, cwd) {
|
|
|
50
50
|
cwd
|
|
51
51
|
}
|
|
52
52
|
});
|
|
53
|
-
logger.info(stdout);
|
|
53
|
+
stdout && logger.info(stdout);
|
|
54
54
|
if (stderr) {
|
|
55
|
-
logger.
|
|
56
|
-
logger.
|
|
55
|
+
logger.warn('Error Output:');
|
|
56
|
+
logger.info(stderr);
|
|
57
57
|
}
|
|
58
58
|
} catch (error) {
|
|
59
59
|
logger.error(`Unexpected error running command:`);
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import chalk from 'chalk';
|
|
2
|
+
import { promises } from 'fs';
|
|
3
|
+
import { join } from 'path';
|
|
4
|
+
import '../../shared/logger.mjs';
|
|
5
|
+
import { getPkgJson } from '../../shared/utils.mjs';
|
|
6
|
+
import { getProjectConfig, err, ok } from '../shared/utils.mjs';
|
|
7
|
+
|
|
8
|
+
const { readFile, readdir } = promises;
|
|
9
|
+
/**
|
|
10
|
+
* Executor function to verify if the current library has a corresponding changeset.
|
|
11
|
+
*
|
|
12
|
+
* @param {ExecutorContext} ctx - The executor context.
|
|
13
|
+
* @returns {Promise<ExecutorResponse>} The result object with a success or error status.
|
|
14
|
+
*/ async function runExecutor(_opts, ctx) {
|
|
15
|
+
try {
|
|
16
|
+
const { root: projectRoot } = getProjectConfig(ctx);
|
|
17
|
+
const packageJson = getPkgJson(projectRoot);
|
|
18
|
+
const { name: packageName } = packageJson;
|
|
19
|
+
const changesetPath = join(ctx.root, '.changeset');
|
|
20
|
+
const preJsonPath = join(changesetPath, 'pre.json');
|
|
21
|
+
const changesetData = JSON.parse(await readFile(preJsonPath, 'utf8'));
|
|
22
|
+
const ignoredChangesets = new Set(changesetData.changesets.map((name)=>name + '.md'));
|
|
23
|
+
const changesetFiles = (await readdir(changesetPath)).filter((file)=>file.endsWith('.md') && !ignoredChangesets.has(file));
|
|
24
|
+
const packageRegex = new RegExp(`['"]${packageName}['"]:`, 'm');
|
|
25
|
+
const checks = changesetFiles.map((file)=>readFile(join(changesetPath, file), 'utf8').then((content)=>packageRegex.test(content)));
|
|
26
|
+
const results = await Promise.all(checks);
|
|
27
|
+
if (!results.includes(true)) {
|
|
28
|
+
const errorMessage = chalk.red(`🔴 No changeset entry found for `) + chalk.cyan(packageName) + '\n' + chalk.yellow('📝 Remember to create a changeset for publishable npm libraries. Use the command ') + chalk.green("'pnpm cs'.") + '\n' + 'For more details, check out: ' + chalk.underline('https://www.notion.so/vtexhandbook/Flujo-de-trabajo-con-changeset-para-publicaci-n-en-npm-3ee6525ecff849fa8acc18273b15deac?pvs=4');
|
|
29
|
+
return err(undefined, errorMessage);
|
|
30
|
+
}
|
|
31
|
+
return ok(`🟢 Changeset verification successful for ${packageName}`);
|
|
32
|
+
} catch (error) {
|
|
33
|
+
return err(error, `❌ Error verifying changeset for the library: ${error.message}`);
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
export { runExecutor as default };
|
package/dist/esm/index.mjs
CHANGED
|
@@ -2,6 +2,7 @@ export { default as deployExecutor } from './executors/deploy/index.mjs';
|
|
|
2
2
|
export { default as environmentsExecutor } from './executors/environments/index.mjs';
|
|
3
3
|
export { default as publishExecutor } from './executors/publish/index.mjs';
|
|
4
4
|
export { default as updateExecutorsFileExecutor } from './executors/update-executors-file/index.mjs';
|
|
5
|
+
export { default as verifyChangesetsExecutor } from './executors/verify-changesets/index.mjs';
|
|
5
6
|
export { default as vtexLinkExecutor } from './executors/vtex-link/index.mjs';
|
|
6
7
|
export { createConfigBuilder } from './vitejs/config-builder/main.mjs';
|
|
7
8
|
export { Flag, ProjectType, Stage, Target, ViteMode } from './vitejs/config-builder/shared/types.mjs';
|
|
@@ -16,7 +16,7 @@ const getBaseConfig = (ctx)=>{
|
|
|
16
16
|
const { resolveEnvs, path } = projectConfig;
|
|
17
17
|
const { stage, target, flags: cmdOverrides } = viteCmd;
|
|
18
18
|
const NODE_ENV = target === Target.BUILD ? ViteMode.PROD : ViteMode.DEV;
|
|
19
|
-
const sourcemap = cmdOverrides?.[Flag.SOURCEMAP] ??
|
|
19
|
+
const sourcemap = cmdOverrides?.[Flag.SOURCEMAP] ?? true;
|
|
20
20
|
const envPrefix = `${commonConfig.envPrefix.toUpperCase()}_`;
|
|
21
21
|
const omittedStages = resolveEnvs.local ? [
|
|
22
22
|
Stage.DEV
|
package/executors.json
CHANGED
|
@@ -24,6 +24,11 @@
|
|
|
24
24
|
"implementation": "./dist/cjs/executors/deploy/index.cjs",
|
|
25
25
|
"schema": "./dist/cjs/executors/deploy/schema.json",
|
|
26
26
|
"description": "Deploys project assets to an AWS S3 bucket and invalidates CloudFront distribution cache"
|
|
27
|
+
},
|
|
28
|
+
"verify-changesets": {
|
|
29
|
+
"implementation": "./dist/cjs/executors/verify-changesets/index.cjs",
|
|
30
|
+
"schema": "./dist/cjs/executors/verify-changesets/schema.json",
|
|
31
|
+
"description": "Verify if the current library has a corresponding changeset"
|
|
27
32
|
}
|
|
28
33
|
}
|
|
29
34
|
}
|
package/package.json
CHANGED
package/dist/index.d.ts
DELETED
|
@@ -1,369 +0,0 @@
|
|
|
1
|
-
// Generated by dts-bundle-generator v7.2.0
|
|
2
|
-
|
|
3
|
-
import { ExecutorContext } from '@nx/devkit';
|
|
4
|
-
import { PreRenderedChunk } from 'rollup';
|
|
5
|
-
import { ConfigEnv, LibraryOptions, Plugin, PluginOption, UserConfig, ViteDevServer } from 'vite';
|
|
6
|
-
|
|
7
|
-
export type ExecutorResponse = {
|
|
8
|
-
success: boolean;
|
|
9
|
-
};
|
|
10
|
-
export interface ExecutorOptions {
|
|
11
|
-
s3BucketPath: string;
|
|
12
|
-
cloudFrontDistributionId: string;
|
|
13
|
-
cloudFrontInvalidationPaths: string[];
|
|
14
|
-
buildTarget: string;
|
|
15
|
-
customPath?: string;
|
|
16
|
-
skipBuild?: boolean;
|
|
17
|
-
}
|
|
18
|
-
export function deployExecutor(opts: ExecutorOptions, ctx: ExecutorContext): Promise<ExecutorResponse>;
|
|
19
|
-
export interface ExecutorOptions {
|
|
20
|
-
}
|
|
21
|
-
declare function runExecutor(_opts: ExecutorOptions, ctx: ExecutorContext): Promise<ExecutorResponse>;
|
|
22
|
-
export interface ExecutorOptions {
|
|
23
|
-
tag: string;
|
|
24
|
-
dryRun?: boolean;
|
|
25
|
-
}
|
|
26
|
-
declare function runExecutor(opts: ExecutorOptions, ctx: ExecutorContext): Promise<ExecutorResponse>;
|
|
27
|
-
export interface ExecutorOptions {
|
|
28
|
-
}
|
|
29
|
-
declare function runExecutor(_opts: ExecutorOptions, ctx: ExecutorContext): Promise<ExecutorResponse>;
|
|
30
|
-
export interface ExecutorOptions {
|
|
31
|
-
packageOrg: string;
|
|
32
|
-
rollback?: boolean;
|
|
33
|
-
skipLink?: boolean;
|
|
34
|
-
}
|
|
35
|
-
declare function runExecutor(opts: ExecutorOptions, ctx: ExecutorContext): Promise<ExecutorResponse>;
|
|
36
|
-
declare enum LogLevel {
|
|
37
|
-
ERROR = 0,
|
|
38
|
-
WARN = 1,
|
|
39
|
-
INFO = 2,
|
|
40
|
-
DEBUG = 3
|
|
41
|
-
}
|
|
42
|
-
export declare enum ViteMode {
|
|
43
|
-
PROD = "production",
|
|
44
|
-
DEV = "development"
|
|
45
|
-
}
|
|
46
|
-
/**
|
|
47
|
-
* Project stages, it coincides with the target configurations of the project.json of NX.
|
|
48
|
-
* @readonly
|
|
49
|
-
* @enum {string}
|
|
50
|
-
*/
|
|
51
|
-
export declare enum Stage {
|
|
52
|
-
PROD = "prod",
|
|
53
|
-
DEV = "dev",
|
|
54
|
-
STAGING = "staging",
|
|
55
|
-
LOCAL = "local"
|
|
56
|
-
}
|
|
57
|
-
export declare enum ProjectType {
|
|
58
|
-
APP = "app",
|
|
59
|
-
LIB = "lib",
|
|
60
|
-
SCRIPT = "script"
|
|
61
|
-
}
|
|
62
|
-
export declare enum Flag {
|
|
63
|
-
SOURCEMAP = "source-maps",
|
|
64
|
-
ANALYZE = "analyze",
|
|
65
|
-
VERBOSE = "verbose",
|
|
66
|
-
VERBOSE_ALIAS = "v",
|
|
67
|
-
HTTPS = "https"
|
|
68
|
-
}
|
|
69
|
-
export declare enum Target {
|
|
70
|
-
BUILD = "build",
|
|
71
|
-
PREVIEW = "preview",
|
|
72
|
-
SERVE = "serve"
|
|
73
|
-
}
|
|
74
|
-
/**
|
|
75
|
-
* Vite Environment.
|
|
76
|
-
*
|
|
77
|
-
* @property {ViteMode} mode - Vite mode.
|
|
78
|
-
*/
|
|
79
|
-
export type ViteEnv = ConfigEnv & {
|
|
80
|
-
mode: ViteMode;
|
|
81
|
-
};
|
|
82
|
-
/**
|
|
83
|
-
* Externalizing libraries.
|
|
84
|
-
*
|
|
85
|
-
* @property {boolean} default - React externalizes and other common dependencies,
|
|
86
|
-
* this only applies to libraries.
|
|
87
|
-
* @property {boolean} glob - Glob expression or list of glob expressions to exclude
|
|
88
|
-
* dependencies from the package.json.
|
|
89
|
-
*/
|
|
90
|
-
export type ExternalizeLibs = {
|
|
91
|
-
default: boolean;
|
|
92
|
-
glob: string | string[];
|
|
93
|
-
};
|
|
94
|
-
export type ResolveEnvs = {
|
|
95
|
-
default: boolean;
|
|
96
|
-
local: boolean;
|
|
97
|
-
};
|
|
98
|
-
/**
|
|
99
|
-
* Project configuration.
|
|
100
|
-
*
|
|
101
|
-
* @property {ProjectType} type - Type of the project.
|
|
102
|
-
* @property {string} path - Path of the project.
|
|
103
|
-
* @property {string} entry - Path of the file entry point.
|
|
104
|
-
* @property {string} name - Name of the project, it is also used to define the name of the library.
|
|
105
|
-
* @property {string} port - Server port.
|
|
106
|
-
* @property {boolean} debug - Print data purification data.
|
|
107
|
-
* @property {boolean} dts - Control if the .d.ts files are generated, by default it is True.
|
|
108
|
-
* @property {Partial<ResolveEnvs>} resolveEnvs - Flag for resolving environment.
|
|
109
|
-
* @property {boolean} shadowDom - If component is render into shadow dom.
|
|
110
|
-
* @property {Partial<ExternalizeLibs>} externalizeLibs - Configuration for externalizing libraries.
|
|
111
|
-
* @property {LibraryOptions['fileName']} fileName - Output file name for library.
|
|
112
|
-
* @property {string} fileName - Prefix for chunk file name.
|
|
113
|
-
* @property {ViteEnv} viteEnv - Vite environment configuration.
|
|
114
|
-
* @property {UserConfig} overrides - Overrides for vite configuration.
|
|
115
|
-
*/
|
|
116
|
-
export interface ProjectConfig {
|
|
117
|
-
type: ProjectType;
|
|
118
|
-
path: string;
|
|
119
|
-
entry?: string;
|
|
120
|
-
name?: string;
|
|
121
|
-
port?: number;
|
|
122
|
-
logLevel?: LogLevel;
|
|
123
|
-
dts?: boolean;
|
|
124
|
-
resolveEnvs?: Partial<ResolveEnvs>;
|
|
125
|
-
shadowDom?: boolean;
|
|
126
|
-
externalizeLibs?: Partial<ExternalizeLibs>;
|
|
127
|
-
fileName?: LibraryOptions["fileName"];
|
|
128
|
-
chunkPrefix?: string;
|
|
129
|
-
viteEnv: ViteEnv;
|
|
130
|
-
overrides?: UserConfig;
|
|
131
|
-
}
|
|
132
|
-
export interface ProjectConfigInitialized extends ProjectConfig {
|
|
133
|
-
name: string;
|
|
134
|
-
fileName: string;
|
|
135
|
-
chunkPrefix: string;
|
|
136
|
-
logLevel: LogLevel;
|
|
137
|
-
overrides: UserConfig;
|
|
138
|
-
shadowDom: boolean;
|
|
139
|
-
resolveEnvs: ResolveEnvs;
|
|
140
|
-
externalizeLibs: ExternalizeLibs;
|
|
141
|
-
}
|
|
142
|
-
/**
|
|
143
|
-
* Vite command details.
|
|
144
|
-
* @interface
|
|
145
|
-
* @property {Stage} stage - Stage of the project.
|
|
146
|
-
* @property {string} target - Command name.
|
|
147
|
-
* @property {Record<string, any>} flags - Flags for customize command.
|
|
148
|
-
*/
|
|
149
|
-
export interface ViteCommand {
|
|
150
|
-
stage: Stage;
|
|
151
|
-
target: string;
|
|
152
|
-
flags: Record<string, any>;
|
|
153
|
-
}
|
|
154
|
-
/**
|
|
155
|
-
* Common project configuration.
|
|
156
|
-
*
|
|
157
|
-
* @property {string} envPrefix - Prefix in lowercase for environment variables and output files.
|
|
158
|
-
* @property {boolean} externalizeLibGlob - Glob expression or list of glob expressions to exclude
|
|
159
|
-
* dependencies from the package.json.
|
|
160
|
-
*/
|
|
161
|
-
export interface CommonProjectConfig {
|
|
162
|
-
envPrefix: string;
|
|
163
|
-
externalizeLibGlob?: string | string[];
|
|
164
|
-
}
|
|
165
|
-
/**
|
|
166
|
-
* Config builder context.
|
|
167
|
-
*
|
|
168
|
-
* @property {CommonProjectConfig} commonConfig - Common configuration for the project.
|
|
169
|
-
* @property {ProjectConfigInitialized} projectConfig - Initialized project configuration.
|
|
170
|
-
* @property {ViteCommandDetail} viteCmd - Vite command details.
|
|
171
|
-
*/
|
|
172
|
-
export interface Context {
|
|
173
|
-
commonConfig: CommonProjectConfig;
|
|
174
|
-
projectConfig: ProjectConfigInitialized;
|
|
175
|
-
viteCmd: ViteCommand;
|
|
176
|
-
localPkgJson: Record<string, any>;
|
|
177
|
-
}
|
|
178
|
-
/**
|
|
179
|
-
* Interface for plugin configuration.
|
|
180
|
-
*/
|
|
181
|
-
export interface PluginConfig {
|
|
182
|
-
/**
|
|
183
|
-
* Generates plugin(s) based on the provided configuration.
|
|
184
|
-
* @param {Context} ctx - The main configuration object.
|
|
185
|
-
* @returns {any[]} An array of plugins.
|
|
186
|
-
*/
|
|
187
|
-
generate: (ctx: Context) => any[];
|
|
188
|
-
/**
|
|
189
|
-
* Condition to determine if the plugin(s) should be included.
|
|
190
|
-
* @param {Context} ctx - The main configuration object.
|
|
191
|
-
* @returns {boolean} True if the plugin(s) should be included; false otherwise.
|
|
192
|
-
*/
|
|
193
|
-
condition?: (ctx: Context) => boolean;
|
|
194
|
-
}
|
|
195
|
-
/**
|
|
196
|
-
* Deeply merges two objects, combining their properties.
|
|
197
|
-
*
|
|
198
|
-
* @param {Record<string, any>} v1 - The first object.
|
|
199
|
-
* @param {Record<string, any>} v2 - The second object.
|
|
200
|
-
* @returns {Record<string, any>} - The merged object.
|
|
201
|
-
*
|
|
202
|
-
* @example
|
|
203
|
-
* const obj1 = { a: 1, b: { c: 2 } };
|
|
204
|
-
* const obj2 = { b: { d: 3 } };
|
|
205
|
-
* const merged = deepMerge(obj1, obj2); // Outputs: { a: 1, b: { c: 2, d: 3 } }
|
|
206
|
-
*/
|
|
207
|
-
export declare function deepMerge(v1: Record<string, any>, v2: Record<string, any>): Record<string, any>;
|
|
208
|
-
/**
|
|
209
|
-
* Generates a name for js files.
|
|
210
|
-
*
|
|
211
|
-
* @param {string} [prefix] - An optional prefix for the chunk name.
|
|
212
|
-
* @returns - A function that takes an item and generates a chunk name.
|
|
213
|
-
*
|
|
214
|
-
* @example
|
|
215
|
-
* const generateChunkName = chunkName('prefix');
|
|
216
|
-
* const name = generateChunkName({ name: 'example' }); // Outputs: "prefix-example-Aj3_Dk7_2j.js"
|
|
217
|
-
*/
|
|
218
|
-
export declare const chunkName: (prefix?: string) => (x: PreRenderedChunk) => string;
|
|
219
|
-
/**
|
|
220
|
-
* Returns the given object if the condition is true, otherwise returns null.
|
|
221
|
-
*
|
|
222
|
-
* @param {any} condition - The condition to evaluate.
|
|
223
|
-
* @param {Record<string, any>} obj - The object to return if the condition is true.
|
|
224
|
-
* @returns {Record<string, any> | null} - The object or null based on the condition.
|
|
225
|
-
*
|
|
226
|
-
* @example
|
|
227
|
-
* const obj = { a: 1 };
|
|
228
|
-
* const result = when(true, obj); // Outputs: { a: 1 }
|
|
229
|
-
* const result2 = when(false, obj); // Outputs: {}
|
|
230
|
-
*/
|
|
231
|
-
export declare const when: (condition: any, obj: Record<string, any>) => Record<string, any>;
|
|
232
|
-
/**
|
|
233
|
-
* Filters and generates plugin configurations based on conditions and the provided context.
|
|
234
|
-
*
|
|
235
|
-
* @param {Context} ctx - The main configuration object.
|
|
236
|
-
* @returns {any[]} - An array of generated plugin configurations.
|
|
237
|
-
*/
|
|
238
|
-
export declare const getPlugins: (ctx: Context, ...pluginConfigs: PluginConfig[]) => PluginOption[];
|
|
239
|
-
/**
|
|
240
|
-
* Gets the paths to the tsconfig files for all relevant projects.
|
|
241
|
-
*
|
|
242
|
-
* @returns {string[]} - An array containing paths to tsconfig files for both app and lib projects.
|
|
243
|
-
*
|
|
244
|
-
* @example
|
|
245
|
-
* const projects = {
|
|
246
|
-
* 'my-app': {
|
|
247
|
-
* type: 'app',
|
|
248
|
-
* data: { root: 'apps/my-app' }
|
|
249
|
-
* },
|
|
250
|
-
* 'my-lib': {
|
|
251
|
-
* type: 'lib',
|
|
252
|
-
* data: { root: 'libs/my-lib' }
|
|
253
|
-
* }
|
|
254
|
-
* };
|
|
255
|
-
*
|
|
256
|
-
* const tsConfigPaths = getTsConfigPaths(projects);
|
|
257
|
-
* console.log(tsConfigPaths);
|
|
258
|
-
* // Output:
|
|
259
|
-
* // ['apps/my-app/tsconfig.app.json', 'libs/my-lib/tsconfig.lib.json']
|
|
260
|
-
*/
|
|
261
|
-
export declare const getNxTsConfigPaths: () => string[];
|
|
262
|
-
/**
|
|
263
|
-
* Initializes the project configuration with default values.
|
|
264
|
-
*
|
|
265
|
-
* @example
|
|
266
|
-
* const config = { type: ProjectType.APP, path: '/path/to/project', viteEnv: { mode: ViteMode.DEV } };
|
|
267
|
-
* const initializedConfig = initializeConfig(config);
|
|
268
|
-
*/
|
|
269
|
-
export declare const initializeConfig: (ccfg: CommonProjectConfig, pcfg: ProjectConfig, localPkgJson: Record<string, any>) => {
|
|
270
|
-
viteCmd: ViteCommand;
|
|
271
|
-
cfg: ProjectConfigInitialized;
|
|
272
|
-
};
|
|
273
|
-
/**
|
|
274
|
-
* Handles merging configurations and logs any errors.
|
|
275
|
-
*
|
|
276
|
-
* @param {UserConfig} defaultConfig - The default configuration.
|
|
277
|
-
* @param {UserConfig} overrides - The overrides configuration.
|
|
278
|
-
* @returns {UserConfig} - The merged configuration.
|
|
279
|
-
*/
|
|
280
|
-
export declare const mergeConfigs: (defaultConfig: UserConfig, overrides: UserConfig) => UserConfig;
|
|
281
|
-
/**
|
|
282
|
-
* Resolves glob patterns to actual package names found in package.json dependencies.
|
|
283
|
-
* This function is used to determine which packages should be treated as external
|
|
284
|
-
* in a Rollup or Vite build configuration.
|
|
285
|
-
*
|
|
286
|
-
* @param {string} path - The base path where package.json is located.
|
|
287
|
-
* @param {string | string[]} globs - A glob pattern or an array of glob patterns to match dependencies against.
|
|
288
|
-
* @returns {string[]} An array of package names that match the given glob patterns.
|
|
289
|
-
*
|
|
290
|
-
* @example
|
|
291
|
-
* // Example of using `getExternalDependencies` to find all dependencies starting with "my-lib" and "lodash"
|
|
292
|
-
* const projectPath = '/path/to/project';
|
|
293
|
-
* const globs = ['my-lib*', 'lodash'];
|
|
294
|
-
* const externalDependencies = getExternalDependencies(projectPath, globs);
|
|
295
|
-
* console.log(externalDependencies);
|
|
296
|
-
* // Output might be: ['my-lib/utils', 'my-lib/core', 'lodash']
|
|
297
|
-
*/
|
|
298
|
-
export declare const getExternalDependencies: (path: string, globs?: string | string[]) => string[];
|
|
299
|
-
/**
|
|
300
|
-
* Generates a string of initials based on the input string,
|
|
301
|
-
* following certain rules:
|
|
302
|
-
* 1. A word is considered as a sequence of characters
|
|
303
|
-
* separated by hyphens.
|
|
304
|
-
* 2. If the string contains '@', any characters before
|
|
305
|
-
* and including the next '/' are ignored.
|
|
306
|
-
* 3. The first character of each word is taken to form
|
|
307
|
-
* the initials.
|
|
308
|
-
*
|
|
309
|
-
* @param {string} input - The input string from which to generate the initials.
|
|
310
|
-
* @returns {string} The initials formed by taking the first character
|
|
311
|
-
* of each word, after applying the specified rules.
|
|
312
|
-
*
|
|
313
|
-
* @example
|
|
314
|
-
* getInitials("player-script"); // returns "ps"
|
|
315
|
-
* getInitials("ssv-admin"); // returns "sa"
|
|
316
|
-
* getInitials("@nizza/customize-live"); // returns "cl"
|
|
317
|
-
*/
|
|
318
|
-
export declare function getInitials(input: string): string;
|
|
319
|
-
/**
|
|
320
|
-
* Retrieves the Vite command details.
|
|
321
|
-
*
|
|
322
|
-
* @param {ViteMode} mode - The Vite mode.
|
|
323
|
-
* @returns {ViteCommand} - The command details.
|
|
324
|
-
*
|
|
325
|
-
* @example
|
|
326
|
-
* const command = getViteCommand(ViteMode.PROD);
|
|
327
|
-
* // Outputs: { stage: Stage.PROD, target: 'build', flags: {} }
|
|
328
|
-
*/
|
|
329
|
-
export declare function getViteCommand(mode: ViteMode): ViteCommand;
|
|
330
|
-
/**
|
|
331
|
-
* Parses the command string to extract flags.
|
|
332
|
-
*
|
|
333
|
-
* @param {string | undefined} commandString - The command string.
|
|
334
|
-
* @returns {Record<string, string>} - The flags extracted from the command string.
|
|
335
|
-
*
|
|
336
|
-
* @example
|
|
337
|
-
* const flags = getViteCmdFlags('nx run core:build --source-maps');
|
|
338
|
-
* // Outputs: { 'source-maps: 'true' }
|
|
339
|
-
*/
|
|
340
|
-
export declare function getViteCmdFlags(commandString: string | undefined): Record<string, string>;
|
|
341
|
-
/**
|
|
342
|
-
* Builds the configuration based on common and project-specific configurations.
|
|
343
|
-
*
|
|
344
|
-
* @param {CommonProjectConfig} commonConfig - The common configuration.
|
|
345
|
-
* @returns - Returns a function that accepts a project configuration and returns the Vite configuration.
|
|
346
|
-
*/
|
|
347
|
-
export declare const createConfigBuilder: (commonConfig: CommonProjectConfig) => (projectConfig: ProjectConfig) => UserConfig;
|
|
348
|
-
export interface Execute {
|
|
349
|
-
function: (data?: string) => void;
|
|
350
|
-
listen: string;
|
|
351
|
-
observer: string;
|
|
352
|
-
}
|
|
353
|
-
export interface ThirdPartyCssInjectPlugin {
|
|
354
|
-
topExecutionPriority?: boolean;
|
|
355
|
-
execute?: Execute[];
|
|
356
|
-
}
|
|
357
|
-
/**
|
|
358
|
-
* Inject the CSS compiled with JS.
|
|
359
|
-
*
|
|
360
|
-
* @return {Plugin}
|
|
361
|
-
*/
|
|
362
|
-
export declare function thirdPartyCssInjectPlugin({ topExecutionPriority, execute }?: ThirdPartyCssInjectPlugin | undefined): Plugin;
|
|
363
|
-
export declare function injectCssIntoShadowDom(): {
|
|
364
|
-
name: string;
|
|
365
|
-
configureServer(_server: ViteDevServer): void;
|
|
366
|
-
transform(src: string, id: string): void;
|
|
367
|
-
};
|
|
368
|
-
|
|
369
|
-
export {};
|