@nx-extend/vercel 1.3.4 → 1.4.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/CHANGELOG.md +10 -0
- package/package.json +4 -3
- package/src/executors/build/build.impl.d.ts +5 -2
- package/src/executors/build/build.impl.js +18 -16
- package/src/executors/build/build.impl.js.map +1 -1
- package/src/executors/build/build.impl.ts +23 -18
- package/src/executors/build/schema.json +20 -3
- package/src/executors/build/utils/get-output-directory.d.ts +1 -0
- package/src/executors/build/utils/get-output-directory.js +11 -0
- package/src/executors/build/utils/get-output-directory.js.map +1 -0
- package/src/executors/deploy/deploy.impl.d.ts +2 -2
- package/src/executors/deploy/deploy.impl.js +32 -15
- package/src/executors/deploy/deploy.impl.js.map +1 -1
- package/src/executors/deploy/deploy.impl.ts +28 -9
- package/src/generators/add/add.impl.d.ts +6 -1
- package/src/generators/add/add.impl.js +7 -3
- package/src/generators/add/add.impl.js.map +1 -1
- package/src/generators/add/add.impl.ts +14 -6
package/CHANGELOG.md
CHANGED
|
@@ -1,4 +1,14 @@
|
|
|
1
1
|
|
|
2
|
+
# [1.4.0](https://github.com/TriPSs/nx-extend/compare/vercel@1.3.4...vercel@1.4.0) (2022-12-08)
|
|
3
|
+
|
|
4
|
+
|
|
5
|
+
### Features
|
|
6
|
+
|
|
7
|
+
* **vercel:** Add URL to GitHub summary ([eeb93a3](https://github.com/TriPSs/nx-extend/commit/eeb93a3de30a07ea7e3e4340b1ecd0efd63db0a8))
|
|
8
|
+
* **vercel:** Added support for different frameworks then NextJS ([da2550b](https://github.com/TriPSs/nx-extend/commit/da2550b186321baedf5d5a137d84d594f1313c36))
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
|
|
2
12
|
## [1.3.4](https://github.com/TriPSs/nx-extend/compare/vercel@1.3.3...vercel@1.3.4) (2022-11-17)
|
|
3
13
|
|
|
4
14
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@nx-extend/vercel",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.4.0",
|
|
4
4
|
"keywords": [
|
|
5
5
|
"nx",
|
|
6
6
|
"vercel"
|
|
@@ -19,8 +19,9 @@
|
|
|
19
19
|
"generators": "./generators.json",
|
|
20
20
|
"types": "./src/index.d.ts",
|
|
21
21
|
"dependencies": {
|
|
22
|
-
"@nx-extend/core": "1.
|
|
23
|
-
"shelljs": "0.8.5"
|
|
22
|
+
"@nx-extend/core": "1.4.0",
|
|
23
|
+
"shelljs": "0.8.5",
|
|
24
|
+
"process": "0.11.10"
|
|
24
25
|
},
|
|
25
26
|
"peerDependencies": {}
|
|
26
27
|
}
|
|
@@ -1,11 +1,14 @@
|
|
|
1
1
|
import type { ExecutorContext } from '@nrwl/devkit';
|
|
2
|
-
export interface
|
|
2
|
+
export interface BuildOptions {
|
|
3
3
|
projectId: string;
|
|
4
4
|
orgId: string;
|
|
5
5
|
debug?: boolean;
|
|
6
6
|
envVars?: Record<string, string>;
|
|
7
|
+
buildTarget?: string;
|
|
8
|
+
framework?: string;
|
|
9
|
+
nodeVersion?: '16.x';
|
|
7
10
|
}
|
|
8
|
-
export declare function buildExecutor(options:
|
|
11
|
+
export declare function buildExecutor(options: BuildOptions, context: ExecutorContext): Promise<{
|
|
9
12
|
success: boolean;
|
|
10
13
|
}>;
|
|
11
14
|
export default buildExecutor;
|
|
@@ -6,20 +6,23 @@ const core_1 = require("@nx-extend/core");
|
|
|
6
6
|
const path_1 = require("path");
|
|
7
7
|
const add_env_variables_to_file_1 = require("../../utils/add-env-variables-to-file");
|
|
8
8
|
const get_env_vars_1 = require("../../utils/get-env-vars");
|
|
9
|
+
const get_output_directory_1 = require("./utils/get-output-directory");
|
|
9
10
|
function buildExecutor(options, context) {
|
|
10
|
-
var _a, _b, _c, _d
|
|
11
|
+
var _a, _b, _c, _d;
|
|
11
12
|
const { targets } = context.workspace.projects[context.projectName];
|
|
13
|
+
const framework = options.framework || 'nextjs';
|
|
14
|
+
const buildTarget = options.buildTarget || (framework === 'nextjs' ? 'build-next' : 'build');
|
|
12
15
|
if (!options.orgId) {
|
|
13
16
|
throw new Error(`"orgId" option is required!`);
|
|
14
17
|
}
|
|
15
18
|
if (!options.projectId) {
|
|
16
19
|
throw new Error(`"projectId" option is required!`);
|
|
17
20
|
}
|
|
18
|
-
if (!targets[
|
|
19
|
-
throw new Error(`"${context.projectName}" is missing the
|
|
21
|
+
if (!targets[buildTarget]) {
|
|
22
|
+
throw new Error(`"${context.projectName}" is missing the "${buildTarget}" target!`);
|
|
20
23
|
}
|
|
21
|
-
if (!((_b = (_a = targets[
|
|
22
|
-
throw new Error(
|
|
24
|
+
if (!((_b = (_a = targets[buildTarget]) === null || _a === void 0 ? void 0 : _a.options) === null || _b === void 0 ? void 0 : _b.outputPath)) {
|
|
25
|
+
throw new Error(`"${buildTarget}" target has no "outputPath" configured!`);
|
|
23
26
|
}
|
|
24
27
|
// First make sure the .vercel/project.json exists
|
|
25
28
|
(0, devkit_1.writeJsonFile)('./.vercel/project.json', {
|
|
@@ -27,19 +30,18 @@ function buildExecutor(options, context) {
|
|
|
27
30
|
orgId: options.orgId,
|
|
28
31
|
settings: {}
|
|
29
32
|
});
|
|
33
|
+
const vercelEnironment = context.configurationName === 'production'
|
|
34
|
+
? 'production'
|
|
35
|
+
: 'preview';
|
|
30
36
|
// Pull latest
|
|
31
37
|
(0, core_1.execCommand)((0, core_1.buildCommand)([
|
|
32
38
|
'npx vercel pull --yes',
|
|
33
|
-
|
|
34
|
-
context.configurationName !== 'production' && '--environment=preview',
|
|
39
|
+
`--environment=${vercelEnironment}`,
|
|
35
40
|
options.debug && '--debug'
|
|
36
41
|
]));
|
|
37
42
|
const vercelDirectory = '.vercel';
|
|
38
43
|
const vercelProjectJson = `./${vercelDirectory}/project.json`;
|
|
39
|
-
const outputDirectory = (_d = (_c = targets[
|
|
40
|
-
const vercelEnironment = context.configurationName === 'production'
|
|
41
|
-
? 'production'
|
|
42
|
-
: 'preview';
|
|
44
|
+
const outputDirectory = (_d = (_c = targets[buildTarget]) === null || _c === void 0 ? void 0 : _c.options) === null || _d === void 0 ? void 0 : _d.outputPath;
|
|
43
45
|
const vercelEnvFile = `.env.${vercelEnironment}.local`;
|
|
44
46
|
const vercelEnvFileLocation = (0, path_1.join)(context.root, vercelDirectory);
|
|
45
47
|
const envVars = (0, get_env_vars_1.getEnvVars)(options.envVars, true);
|
|
@@ -52,19 +54,19 @@ function buildExecutor(options, context) {
|
|
|
52
54
|
orgId: options.orgId,
|
|
53
55
|
settings: {
|
|
54
56
|
createdAt: new Date().getTime(),
|
|
55
|
-
framework
|
|
57
|
+
framework,
|
|
56
58
|
devCommand: null,
|
|
57
59
|
installCommand: 'echo \'\'',
|
|
58
|
-
buildCommand: `nx
|
|
59
|
-
outputDirectory:
|
|
60
|
+
buildCommand: `nx run ${context.projectName}:${buildTarget}:${context.configurationName}`,
|
|
61
|
+
outputDirectory: (0, get_output_directory_1.getOutputDirectory)(options.framework, outputDirectory),
|
|
60
62
|
rootDirectory: null,
|
|
61
63
|
directoryListing: false,
|
|
62
|
-
nodeVersion: '16.x'
|
|
64
|
+
nodeVersion: options.nodeVersion || '16.x'
|
|
63
65
|
}
|
|
64
66
|
});
|
|
65
67
|
const { success } = (0, core_1.execCommand)((0, core_1.buildCommand)([
|
|
66
68
|
'npx vercel build',
|
|
67
|
-
`--output ${
|
|
69
|
+
`--output ${targets[buildTarget].options.outputPath}/.vercel/output`,
|
|
68
70
|
context.configurationName === 'production' && '--prod',
|
|
69
71
|
options.debug && '--debug'
|
|
70
72
|
]));
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"build.impl.js","sourceRoot":"","sources":["../../../../../../packages/vercel/src/executors/build/build.impl.ts"],"names":[],"mappings":";;;AAAA,yCAA0D;AAC1D,0CAAqE;AACrE,+BAA2B;AAI3B,qFAA6E;AAC7E,2DAAqD;
|
|
1
|
+
{"version":3,"file":"build.impl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nB,gBAAgB,EAAE,KAAK;YACvB,WAAW,EAAE,OAAO,CAAC,WAAW,IAAI,MAAM;SAC3C;KACF,CAAC,CAAA;IAEF,MAAM,EAAE,OAAO,EAAE,GAAG,IAAA,kBAAW,EAAC,IAAA,mBAAY,EAAC;QAC3C,kBAAkB;QAClB,YAAY,OAAO,CAAC,WAAW,CAAC,CAAC,OAAO,CAAC,UAAU,iBAAiB;QACpE,OAAO,CAAC,iBAAiB,KAAK,YAAY,IAAI,QAAQ;QAEtD,OAAO,CAAC,KAAK,IAAI,SAAS;KAC3B,CAAC,CAAC,CAAA;IAEH,IAAI,OAAO,EAAE;QACX,kDAAkD;QAClD,IAAA,sBAAa,EAAC,IAAA,WAAI,EAAC,eAAe,EAAE,eAAe,EAAE,cAAc,CAAC,EAAE,IAAA,qBAAY,EAAC,iBAAiB,CAAC,CAAC,CAAA;QACtG,+BAA+B;QAC/B,IAAA,eAAQ,EAAC,qBAAqB,EAAE,IAAA,WAAI,EAAC,eAAe,EAAE,eAAe,CAAC,EAAE,aAAa,CAAC,CAAA;QACtF,8BAA8B;QAC9B,IAAA,eAAQ,EAAC,OAAO,CAAC,IAAI,EAAE,IAAA,WAAI,EAAC,eAAe,EAAE,eAAe,CAAC,EAAE,eAAe,CAAC,CAAA;KAChF;IAED,OAAO,OAAO,CAAC,OAAO,CAAC,EAAE,OAAO,EAAE,CAAC,CAAA;AACrC,CAAC;AA1FD,sCA0FC;AAED,kBAAe,aAAa,CAAA"}
|
|
@@ -6,19 +6,25 @@ import type { ExecutorContext } from '@nrwl/devkit'
|
|
|
6
6
|
|
|
7
7
|
import { addEnvVariablesToFile } from '../../utils/add-env-variables-to-file'
|
|
8
8
|
import { getEnvVars } from '../../utils/get-env-vars'
|
|
9
|
+
import { getOutputDirectory } from './utils/get-output-directory'
|
|
9
10
|
|
|
10
|
-
export interface
|
|
11
|
+
export interface BuildOptions {
|
|
11
12
|
projectId: string
|
|
12
13
|
orgId: string
|
|
13
14
|
debug?: boolean
|
|
14
15
|
envVars?: Record<string, string>
|
|
16
|
+
buildTarget?: string
|
|
17
|
+
framework?: string
|
|
18
|
+
nodeVersion?: '16.x'
|
|
15
19
|
}
|
|
16
20
|
|
|
17
21
|
export function buildExecutor(
|
|
18
|
-
options:
|
|
22
|
+
options: BuildOptions,
|
|
19
23
|
context: ExecutorContext
|
|
20
24
|
): Promise<{ success: boolean }> {
|
|
21
25
|
const { targets } = context.workspace.projects[context.projectName]
|
|
26
|
+
const framework = options.framework || 'nextjs'
|
|
27
|
+
const buildTarget = options.buildTarget || (framework === 'nextjs' ? 'build-next' : 'build')
|
|
22
28
|
|
|
23
29
|
if (!options.orgId) {
|
|
24
30
|
throw new Error(`"orgId" option is required!`)
|
|
@@ -28,12 +34,12 @@ export function buildExecutor(
|
|
|
28
34
|
throw new Error(`"projectId" option is required!`)
|
|
29
35
|
}
|
|
30
36
|
|
|
31
|
-
if (!targets[
|
|
32
|
-
throw new Error(`"${context.projectName}" is missing the
|
|
37
|
+
if (!targets[buildTarget]) {
|
|
38
|
+
throw new Error(`"${context.projectName}" is missing the "${buildTarget}" target!`)
|
|
33
39
|
}
|
|
34
40
|
|
|
35
|
-
if (!targets[
|
|
36
|
-
throw new Error(
|
|
41
|
+
if (!targets[buildTarget]?.options?.outputPath) {
|
|
42
|
+
throw new Error(`"${buildTarget}" target has no "outputPath" configured!`)
|
|
37
43
|
}
|
|
38
44
|
|
|
39
45
|
// First make sure the .vercel/project.json exists
|
|
@@ -43,22 +49,21 @@ export function buildExecutor(
|
|
|
43
49
|
settings: {}
|
|
44
50
|
})
|
|
45
51
|
|
|
52
|
+
const vercelEnironment = context.configurationName === 'production'
|
|
53
|
+
? 'production'
|
|
54
|
+
: 'preview'
|
|
55
|
+
|
|
46
56
|
// Pull latest
|
|
47
57
|
execCommand(buildCommand([
|
|
48
58
|
'npx vercel pull --yes',
|
|
49
|
-
|
|
50
|
-
context.configurationName !== 'production' && '--environment=preview',
|
|
59
|
+
`--environment=${vercelEnironment}`,
|
|
51
60
|
|
|
52
61
|
options.debug && '--debug'
|
|
53
62
|
]))
|
|
54
63
|
|
|
55
64
|
const vercelDirectory = '.vercel'
|
|
56
65
|
const vercelProjectJson = `./${vercelDirectory}/project.json`
|
|
57
|
-
const outputDirectory = targets[
|
|
58
|
-
|
|
59
|
-
const vercelEnironment = context.configurationName === 'production'
|
|
60
|
-
? 'production'
|
|
61
|
-
: 'preview'
|
|
66
|
+
const outputDirectory = targets[buildTarget]?.options?.outputPath
|
|
62
67
|
|
|
63
68
|
const vercelEnvFile = `.env.${vercelEnironment}.local`
|
|
64
69
|
const vercelEnvFileLocation = join(context.root, vercelDirectory)
|
|
@@ -74,20 +79,20 @@ export function buildExecutor(
|
|
|
74
79
|
orgId: options.orgId,
|
|
75
80
|
settings: {
|
|
76
81
|
createdAt: new Date().getTime(),
|
|
77
|
-
framework
|
|
82
|
+
framework,
|
|
78
83
|
devCommand: null,
|
|
79
84
|
installCommand: 'echo \'\'',
|
|
80
|
-
buildCommand: `nx
|
|
81
|
-
outputDirectory:
|
|
85
|
+
buildCommand: `nx run ${context.projectName}:${buildTarget}:${context.configurationName}`,
|
|
86
|
+
outputDirectory: getOutputDirectory(options.framework, outputDirectory),
|
|
82
87
|
rootDirectory: null,
|
|
83
88
|
directoryListing: false,
|
|
84
|
-
nodeVersion: '16.x'
|
|
89
|
+
nodeVersion: options.nodeVersion || '16.x'
|
|
85
90
|
}
|
|
86
91
|
})
|
|
87
92
|
|
|
88
93
|
const { success } = execCommand(buildCommand([
|
|
89
94
|
'npx vercel build',
|
|
90
|
-
`--output ${targets[
|
|
95
|
+
`--output ${targets[buildTarget].options.outputPath}/.vercel/output`,
|
|
91
96
|
context.configurationName === 'production' && '--prod',
|
|
92
97
|
|
|
93
98
|
options.debug && '--debug'
|
|
@@ -4,8 +4,8 @@
|
|
|
4
4
|
"$schema": "http://json-schema.org/schema",
|
|
5
5
|
"type": "object",
|
|
6
6
|
"cli": "nx",
|
|
7
|
-
"title": "
|
|
8
|
-
"description": "
|
|
7
|
+
"title": "Build executor",
|
|
8
|
+
"description": "Buid for Vercel",
|
|
9
9
|
"properties": {
|
|
10
10
|
"projectId": {
|
|
11
11
|
"type": "string",
|
|
@@ -14,6 +14,23 @@
|
|
|
14
14
|
"orgId": {
|
|
15
15
|
"type": "string",
|
|
16
16
|
"description": "Origination ID in Vercel"
|
|
17
|
+
},
|
|
18
|
+
"framework": {
|
|
19
|
+
"type": "string",
|
|
20
|
+
"description": "What framework to use for the build",
|
|
21
|
+
"enum": [
|
|
22
|
+
"nextjs",
|
|
23
|
+
"nuxtjs",
|
|
24
|
+
"create-react-app",
|
|
25
|
+
"docusaurus",
|
|
26
|
+
"docusaurus-2",
|
|
27
|
+
"vue",
|
|
28
|
+
"other"
|
|
29
|
+
]
|
|
17
30
|
}
|
|
18
|
-
}
|
|
31
|
+
},
|
|
32
|
+
"required": [
|
|
33
|
+
"projectId",
|
|
34
|
+
"orgId"
|
|
35
|
+
]
|
|
19
36
|
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const getOutputDirectory: (framework: string, outputPath: string) => string;
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.getOutputDirectory = void 0;
|
|
4
|
+
const getOutputDirectory = (framework, outputPath) => {
|
|
5
|
+
if (framework === 'nextjs') {
|
|
6
|
+
return `${outputPath}/.next`;
|
|
7
|
+
}
|
|
8
|
+
return outputPath;
|
|
9
|
+
};
|
|
10
|
+
exports.getOutputDirectory = getOutputDirectory;
|
|
11
|
+
//# sourceMappingURL=get-output-directory.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"get-output-directory.js","sourceRoot":"","sources":["../../../../../../../packages/vercel/src/executors/build/utils/get-output-directory.ts"],"names":[],"mappings":";;;AAAO,MAAM,kBAAkB,GAAG,CAAC,SAAgB,EAAE,UAAiB,EAAU,EAAE;IAChF,IAAI,SAAS,KAAK,QAAQ,EAAE;QAC1B,OAAO,GAAG,UAAU,QAAQ,CAAA;KAC7B;IAED,OAAO,UAAU,CAAA;AACnB,CAAC,CAAA;AANY,QAAA,kBAAkB,sBAM9B"}
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import type { ExecutorContext } from '@nrwl/devkit';
|
|
2
|
-
export interface
|
|
2
|
+
export interface DeployOptions {
|
|
3
3
|
debug?: boolean;
|
|
4
4
|
}
|
|
5
|
-
export declare function deployExecutor(options:
|
|
5
|
+
export declare function deployExecutor(options: DeployOptions, context: ExecutorContext): Promise<{
|
|
6
6
|
success: boolean;
|
|
7
7
|
}>;
|
|
8
8
|
export default deployExecutor;
|
|
@@ -1,25 +1,42 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.deployExecutor = void 0;
|
|
4
|
+
const tslib_1 = require("tslib");
|
|
5
|
+
const githubCore = require("@actions/core");
|
|
4
6
|
const core_1 = require("@nx-extend/core");
|
|
5
7
|
const fs_1 = require("fs");
|
|
6
8
|
const path_1 = require("path");
|
|
9
|
+
const process = require("process");
|
|
7
10
|
function deployExecutor(options, context) {
|
|
8
|
-
var _a, _b;
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
11
|
+
var _a, _b, _c, _d;
|
|
12
|
+
return tslib_1.__awaiter(this, void 0, void 0, function* () {
|
|
13
|
+
const { targets } = context.workspace.projects[context.projectName];
|
|
14
|
+
const vercelBuildTarget = Object.keys(targets).find((target) => targets[target].executor === '@nx-extend/vercel:build');
|
|
15
|
+
const buildTarget = ((_b = (_a = targets[vercelBuildTarget]) === null || _a === void 0 ? void 0 : _a.options) === null || _b === void 0 ? void 0 : _b.buildTarget) || 'build-next';
|
|
16
|
+
if (!((_d = (_c = targets[buildTarget]) === null || _c === void 0 ? void 0 : _c.options) === null || _d === void 0 ? void 0 : _d.outputPath)) {
|
|
17
|
+
throw new Error(`"${buildTarget}" target has no "outputPath" configured!`);
|
|
18
|
+
}
|
|
19
|
+
if (!(0, fs_1.existsSync)((0, path_1.join)(targets[buildTarget].options.outputPath, '.vercel/project.json'))) {
|
|
20
|
+
throw new Error('No ".vercel/project.json" found in dist folder! ');
|
|
21
|
+
}
|
|
22
|
+
const { success, output } = (0, core_1.execCommand)((0, core_1.buildCommand)([
|
|
23
|
+
'npx vercel deploy --prebuilt',
|
|
24
|
+
context.configurationName === 'production' && '--prod',
|
|
25
|
+
options.debug && '--debug'
|
|
26
|
+
]), {
|
|
27
|
+
cwd: targets[buildTarget].options.outputPath
|
|
28
|
+
});
|
|
29
|
+
// When running in GitHub CI add the URL of the deployment as summary
|
|
30
|
+
if (process.env.CI && process.env.GITHUB_ACTIONS) {
|
|
31
|
+
const parts = output.split('\n');
|
|
32
|
+
const url = parts.find((part) => part.trim().startsWith('https://') && part.trim().endsWith('.vercel.app'));
|
|
33
|
+
if (url) {
|
|
34
|
+
githubCore.summary
|
|
35
|
+
.addLink('Vercel URL', url.trim());
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
return { success };
|
|
39
|
+
});
|
|
23
40
|
}
|
|
24
41
|
exports.deployExecutor = deployExecutor;
|
|
25
42
|
exports.default = deployExecutor;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"deploy.impl.js","sourceRoot":"","sources":["../../../../../../packages/vercel/src/executors/deploy/deploy.impl.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"deploy.impl.js","sourceRoot":"","sources":["../../../../../../packages/vercel/src/executors/deploy/deploy.impl.ts"],"names":[],"mappings":";;;;AAAA,4CAA2C;AAC3C,0CAA2D;AAC3D,2BAA+B;AAC/B,+BAA2B;AAC3B,mCAAkC;AAQlC,SA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,IAAI,CAAC,CAAA;YAEhC,MAAM,GAAG,GAAG,KAAK,CAAC,IAAI,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,IAAI,CAAC,IAAI,EAAE,CAAC,UAAU,CAAC,UAAU,CAAC,IAAI,IAAI,CAAC,IAAI,EAAE,CAAC,QAAQ,CAAC,aAAa,CAAC,CAAC,CAAA;YAE3G,IAAI,GAAG,EAAE;gBACP,UAAU,CAAC,OAAO;qBACf,OAAO,CAAC,YAAY,EAAE,GAAG,CAAC,IAAI,EAAE,CAAC,CAAA;aACrC;SACF;QAED,OAAO,EAAE,OAAO,EAAE,CAAA;;CACnB;AAvCD,wCAuCC;AAED,kBAAe,cAAc,CAAA"}
|
|
@@ -1,35 +1,54 @@
|
|
|
1
|
+
import * as githubCore from '@actions/core'
|
|
1
2
|
import { buildCommand, execCommand } from '@nx-extend/core'
|
|
2
3
|
import { existsSync } from 'fs'
|
|
3
4
|
import { join } from 'path'
|
|
5
|
+
import * as process from 'process'
|
|
4
6
|
|
|
5
7
|
import type { ExecutorContext } from '@nrwl/devkit'
|
|
6
8
|
|
|
7
|
-
export interface
|
|
9
|
+
export interface DeployOptions {
|
|
8
10
|
debug?: boolean
|
|
9
11
|
}
|
|
10
12
|
|
|
11
|
-
export function deployExecutor(
|
|
12
|
-
options:
|
|
13
|
+
export async function deployExecutor(
|
|
14
|
+
options: DeployOptions,
|
|
13
15
|
context: ExecutorContext
|
|
14
16
|
): Promise<{ success: boolean }> {
|
|
15
17
|
const { targets } = context.workspace.projects[context.projectName]
|
|
16
18
|
|
|
17
|
-
|
|
18
|
-
|
|
19
|
+
const vercelBuildTarget = Object.keys(targets).find((target) => targets[target].executor === '@nx-extend/vercel:build')
|
|
20
|
+
const buildTarget = targets[vercelBuildTarget]?.options?.buildTarget || 'build-next'
|
|
21
|
+
|
|
22
|
+
if (!targets[buildTarget]?.options?.outputPath) {
|
|
23
|
+
throw new Error(`"${buildTarget}" target has no "outputPath" configured!`)
|
|
19
24
|
}
|
|
20
25
|
|
|
21
|
-
if (!existsSync(join(targets[
|
|
26
|
+
if (!existsSync(join(targets[buildTarget].options.outputPath, '.vercel/project.json'))) {
|
|
22
27
|
throw new Error('No ".vercel/project.json" found in dist folder! ')
|
|
23
28
|
}
|
|
24
29
|
|
|
25
|
-
|
|
30
|
+
const { success, output } = execCommand(buildCommand([
|
|
26
31
|
'npx vercel deploy --prebuilt',
|
|
27
32
|
context.configurationName === 'production' && '--prod',
|
|
28
33
|
|
|
29
34
|
options.debug && '--debug'
|
|
30
35
|
]), {
|
|
31
|
-
cwd: targets[
|
|
32
|
-
})
|
|
36
|
+
cwd: targets[buildTarget].options.outputPath
|
|
37
|
+
})
|
|
38
|
+
|
|
39
|
+
// When running in GitHub CI add the URL of the deployment as summary
|
|
40
|
+
if (process.env.CI && process.env.GITHUB_ACTIONS) {
|
|
41
|
+
const parts = output.split('\n')
|
|
42
|
+
|
|
43
|
+
const url = parts.find((part) => part.trim().startsWith('https://') && part.trim().endsWith('.vercel.app'))
|
|
44
|
+
|
|
45
|
+
if (url) {
|
|
46
|
+
githubCore.summary
|
|
47
|
+
.addLink('Vercel URL', url.trim())
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
return { success }
|
|
33
52
|
}
|
|
34
53
|
|
|
35
54
|
export default deployExecutor
|
|
@@ -1,2 +1,7 @@
|
|
|
1
1
|
import { Tree } from '@nrwl/devkit';
|
|
2
|
-
export
|
|
2
|
+
export interface AddOptions {
|
|
3
|
+
name: string;
|
|
4
|
+
origination?: string;
|
|
5
|
+
createProject?: boolean;
|
|
6
|
+
}
|
|
7
|
+
export default function AddVercel(host: Tree, options: AddOptions): Promise<void>;
|
|
@@ -1,10 +1,14 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
const tslib_1 = require("tslib");
|
|
4
|
-
|
|
4
|
+
const core_1 = require("@nx-extend/core");
|
|
5
|
+
function AddVercel(host, options) {
|
|
5
6
|
return tslib_1.__awaiter(this, void 0, void 0, function* () {
|
|
6
|
-
|
|
7
|
+
(0, core_1.execCommand)('echo "TODO"');
|
|
8
|
+
// execCommand(buildCommand([
|
|
9
|
+
// 'npx vercel projects add <project name>',
|
|
10
|
+
// ]))
|
|
7
11
|
});
|
|
8
12
|
}
|
|
9
|
-
exports.default =
|
|
13
|
+
exports.default = AddVercel;
|
|
10
14
|
//# sourceMappingURL=add.impl.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"add.impl.js","sourceRoot":"","sources":["../../../../../../packages/vercel/src/generators/add/add.impl.ts"],"names":[],"mappings":";;;
|
|
1
|
+
{"version":3,"file":"add.impl.js","sourceRoot":"","sources":["../../../../../../packages/vercel/src/generators/add/add.impl.ts"],"names":[],"mappings":";;;AACA,0CAA2D;AAQ3D,SAA8B,SAAS,CACrC,IAAU,EACV,OAAmB;;QAEnB,IAAA,kBAAW,EAAC,aAAa,CAAC,CAAA;QAC1B,6BAA6B;QAC7B,8CAA8C;QAC9C,MAAM;IACR,CAAC;CAAA;AARD,4BAQC"}
|
|
@@ -1,10 +1,18 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
} from '@nrwl/devkit'
|
|
1
|
+
import { Tree } from '@nrwl/devkit'
|
|
2
|
+
import { buildCommand, execCommand } from '@nx-extend/core'
|
|
4
3
|
|
|
5
|
-
export
|
|
4
|
+
export interface AddOptions {
|
|
5
|
+
name: string
|
|
6
|
+
origination?: string
|
|
7
|
+
createProject?: boolean
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
export default async function AddVercel(
|
|
6
11
|
host: Tree,
|
|
7
|
-
options:
|
|
12
|
+
options: AddOptions
|
|
8
13
|
) {
|
|
9
|
-
|
|
14
|
+
execCommand('echo "TODO"')
|
|
15
|
+
// execCommand(buildCommand([
|
|
16
|
+
// 'npx vercel projects add <project name>',
|
|
17
|
+
// ]))
|
|
10
18
|
}
|