@nx-extend/vercel 4.2.1 → 5.0.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 +14 -0
- package/package.json +2 -1
- package/src/executors/build/build.impl.d.ts +1 -2
- package/src/executors/build/build.impl.js +20 -18
- package/src/executors/build/build.impl.js.map +1 -1
- package/src/executors/build/build.impl.ts +25 -29
- package/src/executors/deploy/deploy.impl.d.ts +1 -1
- package/src/executors/deploy/deploy.impl.js +22 -10
- package/src/executors/deploy/deploy.impl.js.map +1 -1
- package/src/executors/deploy/deploy.impl.ts +35 -25
- package/src/utils/get-output-directory-from-build-target.d.ts +2 -0
- package/src/utils/get-output-directory-from-build-target.js +16 -0
- package/src/utils/get-output-directory-from-build-target.js.map +1 -0
- package/src/utils/is-github-ci.d.ts +0 -1
- package/src/utils/is-github-ci.js +0 -5
- package/src/utils/is-github-ci.js.map +0 -1
package/CHANGELOG.md
CHANGED
|
@@ -2,6 +2,20 @@
|
|
|
2
2
|
|
|
3
3
|
This file was generated using [@jscutlery/semver](https://github.com/jscutlery/semver).
|
|
4
4
|
|
|
5
|
+
# [5.0.0](https://github.com/TriPSs/nx-extend/compare/vercel@4.2.1...vercel@5.0.0) (2023-07-28)
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
### Features
|
|
9
|
+
|
|
10
|
+
* **vercel:** Improve `buildTarget` logic ([36b903f](https://github.com/TriPSs/nx-extend/commit/36b903f0fc41559ad516ab1a7d091b332cb714de))
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
### BREAKING CHANGES
|
|
14
|
+
|
|
15
|
+
* **vercel:** The logic update could break your build / deploy, add `buildTarget` option now with the project name and optional config
|
|
16
|
+
|
|
17
|
+
|
|
18
|
+
|
|
5
19
|
## [4.2.1](https://github.com/TriPSs/nx-extend/compare/vercel@4.2.0...vercel@4.2.1) (2023-07-27)
|
|
6
20
|
|
|
7
21
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@nx-extend/vercel",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "5.0.0",
|
|
4
4
|
"keywords": [
|
|
5
5
|
"nx",
|
|
6
6
|
"vercel"
|
|
@@ -20,6 +20,7 @@
|
|
|
20
20
|
"dependencies": {
|
|
21
21
|
"@actions/core": "^1.10.0",
|
|
22
22
|
"@nx/devkit": "16.3.2",
|
|
23
|
+
"@nx/workspace": "16.3.2",
|
|
23
24
|
"shelljs": "^0.8.5",
|
|
24
25
|
"@nx-extend/core": "4.3.0",
|
|
25
26
|
"tslib": "2.5.3"
|
|
@@ -2,11 +2,10 @@ import type { ExecutorContext } from '@nx/devkit';
|
|
|
2
2
|
export interface BuildOptions {
|
|
3
3
|
projectId: string;
|
|
4
4
|
orgId: string;
|
|
5
|
-
debug?: boolean;
|
|
6
5
|
envVars?: Record<string, string>;
|
|
7
6
|
buildTarget?: string;
|
|
8
|
-
buildConfig?: string;
|
|
9
7
|
framework?: string;
|
|
8
|
+
outputPath?: string;
|
|
10
9
|
nodeVersion?: '16.x';
|
|
11
10
|
}
|
|
12
11
|
export declare function buildExecutor(options: BuildOptions, context: ExecutorContext): Promise<{
|
|
@@ -2,34 +2,37 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.buildExecutor = void 0;
|
|
4
4
|
const devkit_1 = require("@nx/devkit");
|
|
5
|
+
const parse_target_string_1 = require("@nx/devkit/src/executors/parse-target-string");
|
|
6
|
+
const project_graph_1 = require("@nx/workspace/src/core/project-graph");
|
|
5
7
|
const core_1 = require("@nx-extend/core");
|
|
6
8
|
const fs_1 = require("fs");
|
|
7
9
|
const path_1 = require("path");
|
|
8
10
|
const add_env_variables_to_file_1 = require("../../utils/add-env-variables-to-file");
|
|
9
11
|
const enrich_vercel_env_file_1 = require("../../utils/enrich-vercel-env-file");
|
|
10
12
|
const get_env_vars_1 = require("../../utils/get-env-vars");
|
|
13
|
+
const get_output_directory_from_build_target_1 = require("../../utils/get-output-directory-from-build-target");
|
|
11
14
|
const vercel_token_1 = require("../../utils/vercel-token");
|
|
12
15
|
const get_output_directory_1 = require("./utils/get-output-directory");
|
|
13
16
|
function buildExecutor(options, context) {
|
|
14
|
-
var _a, _b, _c, _d, _e;
|
|
15
|
-
const { targets } = context.workspace.projects[context.projectName];
|
|
16
17
|
const framework = options.framework || 'nextjs';
|
|
17
|
-
|
|
18
|
+
let buildTarget = options.buildTarget || (framework === 'nextjs' ? 'build-next' : 'build');
|
|
19
|
+
if (!buildTarget.includes(':')) {
|
|
20
|
+
buildTarget = `${context.projectName}:${buildTarget}`;
|
|
21
|
+
}
|
|
22
|
+
const targetString = (0, devkit_1.parseTargetString)(buildTarget, (0, project_graph_1.readCachedProjectGraph)());
|
|
18
23
|
if (!options.orgId) {
|
|
19
24
|
throw new Error(`"orgId" option is required!`);
|
|
20
25
|
}
|
|
21
26
|
if (!options.projectId) {
|
|
22
27
|
throw new Error(`"projectId" option is required!`);
|
|
23
28
|
}
|
|
24
|
-
if (!
|
|
25
|
-
throw new Error(`
|
|
29
|
+
if (!targetString) {
|
|
30
|
+
throw new Error(`Invalid build target "${buildTarget}"!`);
|
|
26
31
|
}
|
|
27
|
-
|
|
32
|
+
const outputDirectory = options.outputPath || (0, get_output_directory_from_build_target_1.getOutputDirectoryFromBuildTarget)(context, buildTarget);
|
|
33
|
+
if (!outputDirectory) {
|
|
28
34
|
throw new Error(`"${buildTarget}" target has no "outputPath" configured!`);
|
|
29
35
|
}
|
|
30
|
-
if (options.buildConfig && !((_c = targets[buildTarget]) === null || _c === void 0 ? void 0 : _c.configurations[options.buildConfig])) {
|
|
31
|
-
throw new Error(`"${buildTarget}" target has no configuration "${options.buildConfig}"!`);
|
|
32
|
-
}
|
|
33
36
|
const vercelDirectory = '.vercel';
|
|
34
37
|
const vercelDirectoryLocation = (0, path_1.join)(context.root, vercelDirectory);
|
|
35
38
|
if ((0, fs_1.existsSync)(vercelDirectoryLocation)) {
|
|
@@ -43,20 +46,19 @@ function buildExecutor(options, context) {
|
|
|
43
46
|
orgId: options.orgId,
|
|
44
47
|
settings: {}
|
|
45
48
|
});
|
|
46
|
-
const
|
|
49
|
+
const vercelEnvironment = context.configurationName === 'production' ? 'production' : 'preview';
|
|
47
50
|
// Pull latest
|
|
48
51
|
const { success: pullSuccess } = (0, core_1.execCommand)((0, core_1.buildCommand)([
|
|
49
52
|
'npx vercel pull --yes',
|
|
50
|
-
`--environment=${
|
|
53
|
+
`--environment=${vercelEnvironment}`,
|
|
51
54
|
vercel_token_1.vercelToken && `--token=${vercel_token_1.vercelToken}`,
|
|
52
|
-
|
|
55
|
+
core_1.USE_VERBOSE_LOGGING && '--debug'
|
|
53
56
|
]));
|
|
54
57
|
if (!pullSuccess) {
|
|
55
58
|
throw new Error(`Was unable to pull!`);
|
|
56
59
|
}
|
|
57
60
|
const vercelProjectJson = `./${vercelDirectory}/project.json`;
|
|
58
|
-
const
|
|
59
|
-
const vercelEnvFile = `.env.${vercelEnironment}.local`;
|
|
61
|
+
const vercelEnvFile = `.env.${vercelEnvironment}.local`;
|
|
60
62
|
const vercelEnvFileLocation = (0, path_1.join)(context.root, vercelDirectory);
|
|
61
63
|
const envVars = (0, get_env_vars_1.getEnvVars)(options.envVars, true);
|
|
62
64
|
if (envVars.length > 0) {
|
|
@@ -71,8 +73,8 @@ function buildExecutor(options, context) {
|
|
|
71
73
|
createdAt: new Date().getTime(),
|
|
72
74
|
framework,
|
|
73
75
|
devCommand: null,
|
|
74
|
-
installCommand:
|
|
75
|
-
buildCommand: `nx run ${
|
|
76
|
+
installCommand: 'echo ""',
|
|
77
|
+
buildCommand: `nx run ${(0, parse_target_string_1.targetToTargetString)(targetString)}`,
|
|
76
78
|
outputDirectory: (0, get_output_directory_1.getOutputDirectory)(framework, outputDirectory),
|
|
77
79
|
rootDirectory: null,
|
|
78
80
|
directoryListing: false,
|
|
@@ -81,10 +83,10 @@ function buildExecutor(options, context) {
|
|
|
81
83
|
});
|
|
82
84
|
const { success } = (0, core_1.execCommand)((0, core_1.buildCommand)([
|
|
83
85
|
'npx vercel build',
|
|
84
|
-
`--output ${
|
|
86
|
+
`--output ${outputDirectory}/.vercel/output`,
|
|
85
87
|
context.configurationName === 'production' && '--prod',
|
|
86
88
|
vercel_token_1.vercelToken && `--token=${vercel_token_1.vercelToken}`,
|
|
87
|
-
|
|
89
|
+
core_1.USE_VERBOSE_LOGGING && '--debug'
|
|
88
90
|
]));
|
|
89
91
|
if (success) {
|
|
90
92
|
// Write the project.json to the .vercel directory
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"build.impl.js","sourceRoot":"","sources":["../../../../../../packages/vercel/src/executors/build/build.impl.ts"],"names":[],"mappings":";;;AAAA,
|
|
1
|
+
{"version":3,"file":"build.impl.js","sourceRoot":"","sources":["../../../../../../packages/vercel/src/executors/build/build.impl.ts"],"names":[],"mappings":";;;AAAA,uCAA2E;AAC3E,sFAAmF;AACnF,wEAA6E;AAC7E,0CAA0F;AAC1F,2BAAuC;AACvC,+BAA2B;AAI3B,qFAA6E;AAC7E,+EAAwE;AACxE,2DAAqD;AACrD,+GAAsG;AACtG,2DAAsD;AACtD,uEAAiE;AAYjE,SAAgB,aAAa,CAC3B,OAAqB,EACrB,OAAwB;IAExB,MAAM,SAAS,GAAG,OAAO,CAAC,SAAS,IAAI,QAAQ,CAAA;IAC/C,IAAI,WAAW,GAAG,OAAO,CAAC,WAAW,IAAI,CAAC,SAAS,KAAK,QAAQ,CAAC,CAAC,CAAC,YAAY,CAAC,CAAC,CAAC,OAAO,CAAC,CAAA;IAE1F,IAAI,CAAC,WAAW,CAAC,QAAQ,CAAC,GAAG,CAAC,EAAE;QAC9B,WAAW,GAAG,GAAG,OAAO,CAAC,WAAW,IAAI,WAAW,EAAE,CAAA;KACtD;IAED,MAAM,YAAY,GAAG,IAAA,0BAAiB,EAAC,WAAW,EAAE,IAAA,sCAAsB,GAAE,CAAC,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C;QAC3C,kBAAkB;QAClB,YAAY,eAAe,iBAAiB;QAC5C,OAAO,CAAC,iBAAiB,KAAK,YAAY,IAAI,QAAQ;QACtD,0BAAW,IAAI,WAAW,0BAAW,EAAE;QAEvC,0BAAmB,IAAI,SAAS;KACjC,CAAC,CAAC,CAAA;IAEH,IAAI,OAAO,EAAE;QACX,kDAAkD;QAClD,IAAA,sBAAa,EACX,IAAA,WAAI,EAAC,eAAe,EAAE,eAAe,EAAE,cAAc,CAAC,EACtD,IAAA,qBAAY,EAAC,iBAAiB,CAAC,CAChC,CAAA;QACD,+BAA+B;QAC/B,IAAA,eAAQ,EACN,qBAAqB,EACrB,IAAA,WAAI,EAAC,eAAe,EAAE,eAAe,CAAC,EACtC,aAAa,CACd,CAAA;QACD,8BAA8B;QAC9B,IAAA,eAAQ,EACN,OAAO,CAAC,IAAI,EACZ,IAAA,WAAI,EAAC,eAAe,EAAE,eAAe,CAAC,EACtC,eAAe,CAChB,CAAA;KACF;IAED,OAAO,OAAO,CAAC,OAAO,CAAC,EAAE,OAAO,EAAE,CAAC,CAAA;AACrC,CAAC;AAvHD,sCAuHC;AAED,kBAAe,aAAa,CAAA"}
|
|
@@ -1,5 +1,7 @@
|
|
|
1
|
-
import { readJsonFile, writeJsonFile } from '@nx/devkit'
|
|
2
|
-
import {
|
|
1
|
+
import { parseTargetString, readJsonFile, writeJsonFile } from '@nx/devkit'
|
|
2
|
+
import { targetToTargetString } from '@nx/devkit/src/executors/parse-target-string'
|
|
3
|
+
import { readCachedProjectGraph } from '@nx/workspace/src/core/project-graph'
|
|
4
|
+
import { buildCommand, copyFile, execCommand, USE_VERBOSE_LOGGING } from '@nx-extend/core'
|
|
3
5
|
import { existsSync, rmSync } from 'fs'
|
|
4
6
|
import { join } from 'path'
|
|
5
7
|
|
|
@@ -8,17 +10,17 @@ import type { ExecutorContext } from '@nx/devkit'
|
|
|
8
10
|
import { addEnvVariablesToFile } from '../../utils/add-env-variables-to-file'
|
|
9
11
|
import { enrichVercelEnvFile } from '../../utils/enrich-vercel-env-file'
|
|
10
12
|
import { getEnvVars } from '../../utils/get-env-vars'
|
|
13
|
+
import { getOutputDirectoryFromBuildTarget } from '../../utils/get-output-directory-from-build-target'
|
|
11
14
|
import { vercelToken } from '../../utils/vercel-token'
|
|
12
15
|
import { getOutputDirectory } from './utils/get-output-directory'
|
|
13
16
|
|
|
14
17
|
export interface BuildOptions {
|
|
15
18
|
projectId: string
|
|
16
19
|
orgId: string
|
|
17
|
-
debug?: boolean
|
|
18
20
|
envVars?: Record<string, string>
|
|
19
21
|
buildTarget?: string
|
|
20
|
-
buildConfig?: string
|
|
21
22
|
framework?: string
|
|
23
|
+
outputPath?: string
|
|
22
24
|
nodeVersion?: '16.x'
|
|
23
25
|
}
|
|
24
26
|
|
|
@@ -26,9 +28,14 @@ export function buildExecutor(
|
|
|
26
28
|
options: BuildOptions,
|
|
27
29
|
context: ExecutorContext
|
|
28
30
|
): Promise<{ success: boolean }> {
|
|
29
|
-
const { targets } = context.workspace.projects[context.projectName]
|
|
30
31
|
const framework = options.framework || 'nextjs'
|
|
31
|
-
|
|
32
|
+
let buildTarget = options.buildTarget || (framework === 'nextjs' ? 'build-next' : 'build')
|
|
33
|
+
|
|
34
|
+
if (!buildTarget.includes(':')) {
|
|
35
|
+
buildTarget = `${context.projectName}:${buildTarget}`
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
const targetString = parseTargetString(buildTarget, readCachedProjectGraph())
|
|
32
39
|
|
|
33
40
|
if (!options.orgId) {
|
|
34
41
|
throw new Error(`"orgId" option is required!`)
|
|
@@ -38,22 +45,15 @@ export function buildExecutor(
|
|
|
38
45
|
throw new Error(`"projectId" option is required!`)
|
|
39
46
|
}
|
|
40
47
|
|
|
41
|
-
if (!
|
|
42
|
-
throw new Error(
|
|
43
|
-
`"${context.projectName}" is missing the "${buildTarget}" target!`
|
|
44
|
-
)
|
|
48
|
+
if (!targetString) {
|
|
49
|
+
throw new Error(`Invalid build target "${buildTarget}"!`)
|
|
45
50
|
}
|
|
46
51
|
|
|
47
|
-
|
|
52
|
+
const outputDirectory = options.outputPath || getOutputDirectoryFromBuildTarget(context, buildTarget)
|
|
53
|
+
if (!outputDirectory) {
|
|
48
54
|
throw new Error(`"${buildTarget}" target has no "outputPath" configured!`)
|
|
49
55
|
}
|
|
50
56
|
|
|
51
|
-
if (options.buildConfig && !targets[buildTarget]?.configurations[options.buildConfig]) {
|
|
52
|
-
throw new Error(
|
|
53
|
-
`"${buildTarget}" target has no configuration "${options.buildConfig}"!`
|
|
54
|
-
)
|
|
55
|
-
}
|
|
56
|
-
|
|
57
57
|
const vercelDirectory = '.vercel'
|
|
58
58
|
const vercelDirectoryLocation = join(context.root, vercelDirectory)
|
|
59
59
|
|
|
@@ -70,15 +70,15 @@ export function buildExecutor(
|
|
|
70
70
|
settings: {}
|
|
71
71
|
})
|
|
72
72
|
|
|
73
|
-
const
|
|
73
|
+
const vercelEnvironment = context.configurationName === 'production' ? 'production' : 'preview'
|
|
74
74
|
|
|
75
75
|
// Pull latest
|
|
76
76
|
const { success: pullSuccess } = execCommand(buildCommand([
|
|
77
77
|
'npx vercel pull --yes',
|
|
78
|
-
`--environment=${
|
|
78
|
+
`--environment=${vercelEnvironment}`,
|
|
79
79
|
vercelToken && `--token=${vercelToken}`,
|
|
80
80
|
|
|
81
|
-
|
|
81
|
+
USE_VERBOSE_LOGGING && '--debug'
|
|
82
82
|
]))
|
|
83
83
|
|
|
84
84
|
if (!pullSuccess) {
|
|
@@ -86,9 +86,7 @@ export function buildExecutor(
|
|
|
86
86
|
}
|
|
87
87
|
|
|
88
88
|
const vercelProjectJson = `./${vercelDirectory}/project.json`
|
|
89
|
-
const
|
|
90
|
-
|
|
91
|
-
const vercelEnvFile = `.env.${vercelEnironment}.local`
|
|
89
|
+
const vercelEnvFile = `.env.${vercelEnvironment}.local`
|
|
92
90
|
const vercelEnvFileLocation = join(context.root, vercelDirectory)
|
|
93
91
|
|
|
94
92
|
const envVars = getEnvVars(options.envVars, true)
|
|
@@ -106,10 +104,8 @@ export function buildExecutor(
|
|
|
106
104
|
createdAt: new Date().getTime(),
|
|
107
105
|
framework,
|
|
108
106
|
devCommand: null,
|
|
109
|
-
installCommand:
|
|
110
|
-
buildCommand: `nx run ${
|
|
111
|
-
options.buildConfig || context.configurationName
|
|
112
|
-
}`,
|
|
107
|
+
installCommand: 'echo ""',
|
|
108
|
+
buildCommand: `nx run ${targetToTargetString(targetString)}`,
|
|
113
109
|
outputDirectory: getOutputDirectory(framework, outputDirectory),
|
|
114
110
|
rootDirectory: null,
|
|
115
111
|
directoryListing: false,
|
|
@@ -119,11 +115,11 @@ export function buildExecutor(
|
|
|
119
115
|
|
|
120
116
|
const { success } = execCommand(buildCommand([
|
|
121
117
|
'npx vercel build',
|
|
122
|
-
`--output ${
|
|
118
|
+
`--output ${outputDirectory}/.vercel/output`,
|
|
123
119
|
context.configurationName === 'production' && '--prod',
|
|
124
120
|
vercelToken && `--token=${vercelToken}`,
|
|
125
121
|
|
|
126
|
-
|
|
122
|
+
USE_VERBOSE_LOGGING && '--debug'
|
|
127
123
|
]))
|
|
128
124
|
|
|
129
125
|
if (success) {
|
|
@@ -6,18 +6,30 @@ const githubCore = require("@actions/core");
|
|
|
6
6
|
const core_1 = require("@nx-extend/core");
|
|
7
7
|
const fs_1 = require("fs");
|
|
8
8
|
const path_1 = require("path");
|
|
9
|
-
const
|
|
9
|
+
const get_output_directory_from_build_target_1 = require("../../utils/get-output-directory-from-build-target");
|
|
10
10
|
const vercel_token_1 = require("../../utils/vercel-token");
|
|
11
11
|
function deployExecutor(options, context) {
|
|
12
|
-
var _a, _b
|
|
12
|
+
var _a, _b;
|
|
13
13
|
return tslib_1.__awaiter(this, void 0, void 0, function* () {
|
|
14
14
|
const { targets } = context.workspace.projects[context.projectName];
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
throw new Error(`"${buildTarget}" target has no "outputPath" configured!`);
|
|
15
|
+
let outputDirectory = '';
|
|
16
|
+
if (options.buildTarget) {
|
|
17
|
+
outputDirectory = (0, get_output_directory_from_build_target_1.getOutputDirectoryFromBuildTarget)(context, options.buildTarget);
|
|
19
18
|
}
|
|
20
|
-
|
|
19
|
+
else {
|
|
20
|
+
const projectVercelBuildTarget = Object.keys(targets).find((target) => (targets[target].executor === '@nx-extend/vercel:build'));
|
|
21
|
+
if (projectVercelBuildTarget) {
|
|
22
|
+
let projectBuildTarget = ((_b = (_a = targets[projectVercelBuildTarget]) === null || _a === void 0 ? void 0 : _a.options) === null || _b === void 0 ? void 0 : _b.buildTarget) || 'build-next';
|
|
23
|
+
if (!projectBuildTarget.includes(':')) {
|
|
24
|
+
projectBuildTarget = `${context.projectName}:${projectBuildTarget}`;
|
|
25
|
+
}
|
|
26
|
+
outputDirectory = (0, get_output_directory_from_build_target_1.getOutputDirectoryFromBuildTarget)(context, projectBuildTarget);
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
if (!outputDirectory) {
|
|
30
|
+
throw new Error(`Could not find the builds output path!`);
|
|
31
|
+
}
|
|
32
|
+
if (!(0, fs_1.existsSync)((0, path_1.join)(outputDirectory, '.vercel/project.json'))) {
|
|
21
33
|
throw new Error('No ".vercel/project.json" found in dist folder! ');
|
|
22
34
|
}
|
|
23
35
|
const { success, output } = (0, core_1.execCommand)((0, core_1.buildCommand)([
|
|
@@ -25,12 +37,12 @@ function deployExecutor(options, context) {
|
|
|
25
37
|
context.configurationName === 'production' && '--prod',
|
|
26
38
|
vercel_token_1.vercelToken && `--token=${vercel_token_1.vercelToken}`,
|
|
27
39
|
options.regions && `--regions=${options.regions}`,
|
|
28
|
-
|
|
40
|
+
core_1.USE_VERBOSE_LOGGING && '--debug'
|
|
29
41
|
]), {
|
|
30
|
-
cwd:
|
|
42
|
+
cwd: outputDirectory
|
|
31
43
|
});
|
|
32
44
|
// When running in GitHub CI add the URL of the deployment as summary
|
|
33
|
-
if (
|
|
45
|
+
if ((0, core_1.isCI)()) {
|
|
34
46
|
// Add comment instead of summary (Look at https://github.com/mshick/add-pr-comment)
|
|
35
47
|
const parts = output.split('\n');
|
|
36
48
|
const url = parts.find((part) => part.trim().startsWith('https://') &&
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"deploy.impl.js","sourceRoot":"","sources":["../../../../../../packages/vercel/src/executors/deploy/deploy.impl.ts"],"names":[],"mappings":";;;;AAAA,4CAA2C;
|
|
1
|
+
{"version":3,"file":"deploy.impl.js","sourceRoot":"","sources":["../../../../../../packages/vercel/src/executors/deploy/deploy.impl.ts"],"names":[],"mappings":";;;;AAAA,4CAA2C;AAC3C,0CAAsF;AACtF,2BAA+B;AAC/B,+BAA2B;AAI3B,+GAAsG;AACtG,2DAAsD;AAOtD,SAAsB,cAAc,CAClC,OAAsB,EACtB,OAAwB;;;QAExB,MAAM,EAAE,OAAO,EAAE,GAAG,OAAO,CAAC,SAAS,CAAC,QAAQ,CAAC,OAAO,CAAC,WAAW,CAAC,CAAA;QAEnE,IAAI,eAAe,GAAG,EAAE,CAAA;QAExB,IAAI,OAAO,CAAC,WAAW,EAAE;YACvB,eAAe,GAAG,IAAA,0EAAiC,EAAC,OAAO,EAAE,OAAO,CAAC,WAAW,CAAC,CAAA;SAClF;aAAM;YACL,MAAM,wBAAwB,GAAG,MAAM,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC,IAAI,CAAC,CAAC,MAAM,EAAE,EAAE,CAAC,CACrE,OAAO,CAAC,MAAM,CAAC,CAAC,QAAQ,KAAK,yBAAyB,CACvD,CAAC,CAAA;YAEF,IAAI,wBAAwB,EAAE;gBAC5B,IAAI,kBAAkB,GAAG,CAAA,MAAA,MAAA,OAAO,CAAC,wBAAwB,CAAC,0CAAE,OAAO,0CAAE,WAAW,KAAI,YAAY,CAAA;gBAChG,IAAI,CAAC,kBAAkB,CAAC,QAAQ,CAAC,GAAG,CAAC,EAAE;oBACrC,kBAAkB,GAAG,GAAG,OAAO,CAAC,WAAW,IAAI,kBAAkB,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ED,OAAO,EAAE,OAAO,EAAE,CAAA;;CACnB;AAjED,wCAiEC;AAED,kBAAe,cAAc,CAAA"}
|
|
@@ -1,16 +1,15 @@
|
|
|
1
1
|
import * as githubCore from '@actions/core'
|
|
2
|
-
import {
|
|
3
|
-
import { buildCommand, execCommand } from '@nx-extend/core'
|
|
2
|
+
import { buildCommand, execCommand, isCI, USE_VERBOSE_LOGGING } from '@nx-extend/core'
|
|
4
3
|
import { existsSync } from 'fs'
|
|
5
4
|
import { join } from 'path'
|
|
6
5
|
|
|
7
6
|
import type { ExecutorContext } from '@nx/devkit'
|
|
8
7
|
|
|
9
|
-
import {
|
|
8
|
+
import { getOutputDirectoryFromBuildTarget } from '../../utils/get-output-directory-from-build-target'
|
|
10
9
|
import { vercelToken } from '../../utils/vercel-token'
|
|
11
10
|
|
|
12
11
|
export interface DeployOptions {
|
|
13
|
-
|
|
12
|
+
buildTarget?: string
|
|
14
13
|
regions?: string
|
|
15
14
|
}
|
|
16
15
|
|
|
@@ -20,35 +19,46 @@ export async function deployExecutor(
|
|
|
20
19
|
): Promise<{ success: boolean }> {
|
|
21
20
|
const { targets } = context.workspace.projects[context.projectName]
|
|
22
21
|
|
|
23
|
-
|
|
24
|
-
(target) => targets[target].executor === '@nx-extend/vercel:build'
|
|
25
|
-
)
|
|
26
|
-
const buildTarget = targets[vercelBuildTarget]?.options?.buildTarget || 'build-next'
|
|
22
|
+
let outputDirectory = ''
|
|
27
23
|
|
|
28
|
-
if (
|
|
29
|
-
|
|
24
|
+
if (options.buildTarget) {
|
|
25
|
+
outputDirectory = getOutputDirectoryFromBuildTarget(context, options.buildTarget)
|
|
26
|
+
} else {
|
|
27
|
+
const projectVercelBuildTarget = Object.keys(targets).find((target) => (
|
|
28
|
+
targets[target].executor === '@nx-extend/vercel:build'
|
|
29
|
+
))
|
|
30
|
+
|
|
31
|
+
if (projectVercelBuildTarget) {
|
|
32
|
+
let projectBuildTarget = targets[projectVercelBuildTarget]?.options?.buildTarget || 'build-next'
|
|
33
|
+
if (!projectBuildTarget.includes(':')) {
|
|
34
|
+
projectBuildTarget = `${context.projectName}:${projectBuildTarget}`
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
outputDirectory = getOutputDirectoryFromBuildTarget(context, projectBuildTarget)
|
|
38
|
+
}
|
|
30
39
|
}
|
|
31
40
|
|
|
32
|
-
if (!
|
|
41
|
+
if (!outputDirectory) {
|
|
42
|
+
throw new Error(`Could not find the builds output path!`)
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
if (!existsSync(join(outputDirectory, '.vercel/project.json'))) {
|
|
33
46
|
throw new Error('No ".vercel/project.json" found in dist folder! ')
|
|
34
47
|
}
|
|
35
48
|
|
|
36
|
-
const { success, output } = execCommand(
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
cwd: targets[buildTarget].options.outputPath
|
|
47
|
-
}
|
|
48
|
-
)
|
|
49
|
+
const { success, output } = execCommand(buildCommand([
|
|
50
|
+
'npx vercel deploy --prebuilt',
|
|
51
|
+
context.configurationName === 'production' && '--prod',
|
|
52
|
+
vercelToken && `--token=${vercelToken}`,
|
|
53
|
+
options.regions && `--regions=${options.regions}`,
|
|
54
|
+
|
|
55
|
+
USE_VERBOSE_LOGGING && '--debug'
|
|
56
|
+
]), {
|
|
57
|
+
cwd: outputDirectory
|
|
58
|
+
})
|
|
49
59
|
|
|
50
60
|
// When running in GitHub CI add the URL of the deployment as summary
|
|
51
|
-
if (
|
|
61
|
+
if (isCI()) {
|
|
52
62
|
// Add comment instead of summary (Look at https://github.com/mshick/add-pr-comment)
|
|
53
63
|
const parts = output.split('\n')
|
|
54
64
|
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.getOutputDirectoryFromBuildTarget = void 0;
|
|
4
|
+
const devkit_1 = require("@nx/devkit");
|
|
5
|
+
const project_graph_1 = require("@nx/workspace/src/core/project-graph");
|
|
6
|
+
function getOutputDirectoryFromBuildTarget(context, buildTarget) {
|
|
7
|
+
const targetString = (0, devkit_1.parseTargetString)(buildTarget, (0, project_graph_1.readCachedProjectGraph)());
|
|
8
|
+
const targetOptions = (0, devkit_1.readTargetOptions)(targetString, context);
|
|
9
|
+
const outputDirectory = targetOptions === null || targetOptions === void 0 ? void 0 : targetOptions.outputPath;
|
|
10
|
+
if (!outputDirectory && (targetOptions === null || targetOptions === void 0 ? void 0 : targetOptions.buildTarget)) {
|
|
11
|
+
return getOutputDirectoryFromBuildTarget(context, targetOptions === null || targetOptions === void 0 ? void 0 : targetOptions.buildTarget);
|
|
12
|
+
}
|
|
13
|
+
return outputDirectory;
|
|
14
|
+
}
|
|
15
|
+
exports.getOutputDirectoryFromBuildTarget = getOutputDirectoryFromBuildTarget;
|
|
16
|
+
//# sourceMappingURL=get-output-directory-from-build-target.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"get-output-directory-from-build-target.js","sourceRoot":"","sources":["../../../../../packages/vercel/src/utils/get-output-directory-from-build-target.ts"],"names":[],"mappings":";;;AAAA,uCAAkF;AAClF,wEAA6E;AAE7E,SAAgB,iCAAiC,CAAC,OAAwB,EAAE,WAAmB;IAC7F,MAAM,YAAY,GAAG,IAAA,0BAAiB,EAAC,WAAW,EAAE,IAAA,sCAAsB,GAAE,CAAC,CAAA;IAC7E,MAAM,aAAa,GAAG,IAAA,0BAAiB,EAAC,YAAY,EAAE,OAAO,CAAC,CAAA;IAC9D,MAAM,eAAe,GAAG,aAAa,aAAb,aAAa,uBAAb,aAAa,CAAE,UAAU,CAAA;IAEjD,IAAI,CAAC,eAAe,KAAI,aAAa,aAAb,aAAa,uBAAb,aAAa,CAAE,WAAW,CAAA,EAAE;QAClD,OAAO,iCAAiC,CAAC,OAAO,EAAE,aAAa,aAAb,aAAa,uBAAb,aAAa,CAAE,WAAW,CAAC,CAAA;KAC9E;IAED,OAAO,eAAe,CAAA;AACxB,CAAC;AAVD,8EAUC"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export declare const isGithubCi: string;
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"is-github-ci.js","sourceRoot":"","sources":["../../../../../packages/vercel/src/utils/is-github-ci.ts"],"names":[],"mappings":";;;AAAa,QAAA,UAAU,GAAG,OAAO,CAAC,GAAG,CAAC,EAAE,IAAI,OAAO,CAAC,GAAG,CAAC,cAAc,CAAA"}
|