@vercel/go 2.0.11 → 2.0.12
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/index.js +9 -35
- package/package.json +3 -3
package/dist/index.js
CHANGED
|
@@ -17720,11 +17720,10 @@ async function initPrivateGit(credentials) {
|
|
|
17720
17720
|
* which works great for this feature. We also need to add a suffix during `vercel dev`
|
|
17721
17721
|
* since the entrypoint is already stripped of its suffix before build() is called.
|
|
17722
17722
|
*/
|
|
17723
|
-
async function getRenamedEntrypoint(entrypoint, files
|
|
17723
|
+
async function getRenamedEntrypoint(entrypoint, files) {
|
|
17724
17724
|
const filename = path_1.basename(entrypoint);
|
|
17725
17725
|
if (filename.startsWith('[')) {
|
|
17726
|
-
const
|
|
17727
|
-
const newEntrypoint = entrypoint.replace('/[', '/now-bracket[') + suffix;
|
|
17726
|
+
const newEntrypoint = entrypoint.replace('/[', '/now-bracket[');
|
|
17728
17727
|
const file = files[entrypoint];
|
|
17729
17728
|
delete files[entrypoint];
|
|
17730
17729
|
files[newEntrypoint] = file;
|
|
@@ -17735,7 +17734,7 @@ async function getRenamedEntrypoint(entrypoint, files, meta) {
|
|
|
17735
17734
|
}
|
|
17736
17735
|
exports.version = 3;
|
|
17737
17736
|
async function build({ files, entrypoint, config, workPath, meta = {}, }) {
|
|
17738
|
-
if (process.env.GIT_CREDENTIALS
|
|
17737
|
+
if (process.env.GIT_CREDENTIALS) {
|
|
17739
17738
|
build_utils_1.debug('Initialize Git credentials...');
|
|
17740
17739
|
await initPrivateGit(process.env.GIT_CREDENTIALS);
|
|
17741
17740
|
}
|
|
@@ -17750,17 +17749,16 @@ We highly recommend you leverage Go Modules in your project.
|
|
|
17750
17749
|
Learn more: https://github.com/golang/go/wiki/Modules
|
|
17751
17750
|
`);
|
|
17752
17751
|
}
|
|
17753
|
-
entrypoint = await getRenamedEntrypoint(entrypoint, files
|
|
17752
|
+
entrypoint = await getRenamedEntrypoint(entrypoint, files);
|
|
17754
17753
|
const entrypointArr = entrypoint.split(path_1.sep);
|
|
17755
17754
|
// eslint-disable-next-line prefer-const
|
|
17756
17755
|
let [goPath, outDir] = await Promise.all([
|
|
17757
17756
|
build_utils_1.getWriteableDirectory(),
|
|
17758
17757
|
build_utils_1.getWriteableDirectory(),
|
|
17759
17758
|
]);
|
|
17760
|
-
const forceMove = Boolean(meta.isDev);
|
|
17761
17759
|
const srcPath = path_1.join(goPath, 'src', 'lambda');
|
|
17762
|
-
|
|
17763
|
-
|
|
17760
|
+
const downloadPath = meta.skipDownload ? workPath : srcPath;
|
|
17761
|
+
const downloadedFiles = await build_utils_1.download(files, downloadPath, meta);
|
|
17764
17762
|
build_utils_1.debug(`Parsing AST for "${entrypoint}"`);
|
|
17765
17763
|
let analyzed;
|
|
17766
17764
|
try {
|
|
@@ -17788,16 +17786,6 @@ Learn more: https://vercel.com/docs/runtimes#official-runtimes/go
|
|
|
17788
17786
|
throw err;
|
|
17789
17787
|
}
|
|
17790
17788
|
const parsedAnalyzed = JSON.parse(analyzed);
|
|
17791
|
-
if (meta.isDev) {
|
|
17792
|
-
// Create cache so Go rebuilds fast with `vercel dev`
|
|
17793
|
-
// Old versions of the CLI don't assign this property
|
|
17794
|
-
const { devCacheDir = path_1.join(workPath, '.now', 'cache') } = meta;
|
|
17795
|
-
goPath = path_1.join(devCacheDir, 'go', path_1.basename(entrypoint, '.go'));
|
|
17796
|
-
const destLambda = path_1.join(goPath, 'src', 'lambda');
|
|
17797
|
-
await build_utils_1.download(downloadedFiles, destLambda);
|
|
17798
|
-
downloadedFiles = await build_utils_1.glob('**', destLambda);
|
|
17799
|
-
downloadPath = destLambda;
|
|
17800
|
-
}
|
|
17801
17789
|
// find `go.mod` in downloadedFiles
|
|
17802
17790
|
const entrypointDirname = path_1.dirname(downloadedFiles[entrypoint].fsPath);
|
|
17803
17791
|
let isGoModExist = false;
|
|
@@ -17829,12 +17817,12 @@ Learn more: https://vercel.com/docs/runtimes#official-runtimes/go
|
|
|
17829
17817
|
pathParts.push('go.mod');
|
|
17830
17818
|
const newFsPath = pathParts.join(path_1.sep);
|
|
17831
17819
|
build_utils_1.debug(`Moving api/go.mod to root: ${fsPath} to ${newFsPath}`);
|
|
17832
|
-
await fs_extra_1.move(fsPath, newFsPath
|
|
17820
|
+
await fs_extra_1.move(fsPath, newFsPath);
|
|
17833
17821
|
const oldSumPath = path_1.join(path_1.dirname(fsPath), 'go.sum');
|
|
17834
17822
|
const newSumPath = path_1.join(path_1.dirname(newFsPath), 'go.sum');
|
|
17835
17823
|
if (await fs_extra_1.pathExists(oldSumPath)) {
|
|
17836
17824
|
build_utils_1.debug(`Moving api/go.sum to root: ${oldSumPath} to ${newSumPath}`);
|
|
17837
|
-
await fs_extra_1.move(oldSumPath, newSumPath
|
|
17825
|
+
await fs_extra_1.move(oldSumPath, newSumPath);
|
|
17838
17826
|
}
|
|
17839
17827
|
break;
|
|
17840
17828
|
}
|
|
@@ -17919,9 +17907,7 @@ Learn more: https://vercel.com/docs/runtimes#official-runtimes/go
|
|
|
17919
17907
|
}
|
|
17920
17908
|
if (path_1.dirname(downloadedFiles[entrypoint].fsPath) === goModPath ||
|
|
17921
17909
|
!isGoModExist) {
|
|
17922
|
-
await fs_extra_1.move(downloadedFiles[entrypoint].fsPath, finalDestination
|
|
17923
|
-
overwrite: forceMove,
|
|
17924
|
-
});
|
|
17910
|
+
await fs_extra_1.move(downloadedFiles[entrypoint].fsPath, finalDestination);
|
|
17925
17911
|
}
|
|
17926
17912
|
}
|
|
17927
17913
|
catch (err) {
|
|
@@ -17938,13 +17924,6 @@ Learn more: https://vercel.com/docs/runtimes#official-runtimes/go
|
|
|
17938
17924
|
else {
|
|
17939
17925
|
baseGoModPath = entrypointDirname;
|
|
17940
17926
|
}
|
|
17941
|
-
if (meta.isDev) {
|
|
17942
|
-
const isGoModBk = await fs_extra_1.pathExists(path_1.join(baseGoModPath, 'go.mod.bk'));
|
|
17943
|
-
if (isGoModBk) {
|
|
17944
|
-
await fs_extra_1.move(path_1.join(baseGoModPath, 'go.mod.bk'), path_1.join(baseGoModPath, 'go.mod'), { overwrite: forceMove });
|
|
17945
|
-
await fs_extra_1.move(path_1.join(baseGoModPath, 'go.sum.bk'), path_1.join(baseGoModPath, 'go.sum'), { overwrite: forceMove });
|
|
17946
|
-
}
|
|
17947
|
-
}
|
|
17948
17927
|
build_utils_1.debug('Tidy `go.mod` file...');
|
|
17949
17928
|
try {
|
|
17950
17929
|
// ensure go.mod up-to-date
|
|
@@ -17964,11 +17943,6 @@ Learn more: https://vercel.com/docs/runtimes#official-runtimes/go
|
|
|
17964
17943
|
console.log('failed to `go build`');
|
|
17965
17944
|
throw err;
|
|
17966
17945
|
}
|
|
17967
|
-
if (meta.isDev) {
|
|
17968
|
-
// caching for `vercel dev`
|
|
17969
|
-
await fs_extra_1.move(path_1.join(baseGoModPath, 'go.mod'), path_1.join(baseGoModPath, 'go.mod.bk'), { overwrite: forceMove });
|
|
17970
|
-
await fs_extra_1.move(path_1.join(baseGoModPath, 'go.sum'), path_1.join(baseGoModPath, 'go.sum.bk'), { overwrite: forceMove });
|
|
17971
|
-
}
|
|
17972
17946
|
}
|
|
17973
17947
|
else {
|
|
17974
17948
|
// legacy mode
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@vercel/go",
|
|
3
|
-
"version": "2.0.
|
|
3
|
+
"version": "2.0.12",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"main": "./dist/index",
|
|
6
6
|
"homepage": "https://vercel.com/docs/runtimes#official-runtimes/go",
|
|
@@ -25,7 +25,7 @@
|
|
|
25
25
|
"@types/fs-extra": "^5.0.5",
|
|
26
26
|
"@types/node-fetch": "^2.3.0",
|
|
27
27
|
"@types/tar": "^4.0.0",
|
|
28
|
-
"@vercel/build-utils": "5.0.
|
|
28
|
+
"@vercel/build-utils": "5.0.8",
|
|
29
29
|
"@vercel/ncc": "0.24.0",
|
|
30
30
|
"async-retry": "1.3.1",
|
|
31
31
|
"execa": "^1.0.0",
|
|
@@ -35,5 +35,5 @@
|
|
|
35
35
|
"tar": "4.4.6",
|
|
36
36
|
"typescript": "4.3.4"
|
|
37
37
|
},
|
|
38
|
-
"gitHead": "
|
|
38
|
+
"gitHead": "543ffdfe5ccfb59c9c455fc50df3bb8ed1eaf567"
|
|
39
39
|
}
|