@driveflux/vercel 1.0.0-next.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.
Files changed (42) hide show
  1. package/.eslintrc +3 -0
  2. package/.turbo/turbo-build.log +6 -0
  3. package/CHANGELOG.md +7 -0
  4. package/deployment/build-vercel-url.d.ts.d.ts +1 -0
  5. package/deployment/build-vercel-url.js.cjs +1 -0
  6. package/deployment/make-deployment-lockfile.d.ts.d.ts +1 -0
  7. package/deployment/make-deployment-lockfile.js.cjs +1 -0
  8. package/deployment/use-deployment-lockfile.d.ts.d.ts +1 -0
  9. package/deployment/use-deployment-lockfile.js.cjs +1 -0
  10. package/deployment/utils.d.ts.d.ts +1 -0
  11. package/deployment/utils.js.cjs +1 -0
  12. package/dist/cjs/deployment/build-vercel-url.js +59 -0
  13. package/dist/cjs/deployment/make-deployment-lockfile.js +186 -0
  14. package/dist/cjs/deployment/use-deployment-lockfile.js +191 -0
  15. package/dist/cjs/deployment/utils.js +535 -0
  16. package/dist/cjs/index.js +12 -0
  17. package/dist/cjs/package.json +3 -0
  18. package/dist/deployment/build-vercel-url.d.ts +4 -0
  19. package/dist/deployment/build-vercel-url.d.ts.map +1 -0
  20. package/dist/deployment/build-vercel-url.js +33 -0
  21. package/dist/deployment/make-deployment-lockfile.d.ts +2 -0
  22. package/dist/deployment/make-deployment-lockfile.d.ts.map +1 -0
  23. package/dist/deployment/make-deployment-lockfile.js +182 -0
  24. package/dist/deployment/use-deployment-lockfile.d.ts +2 -0
  25. package/dist/deployment/use-deployment-lockfile.d.ts.map +1 -0
  26. package/dist/deployment/use-deployment-lockfile.js +187 -0
  27. package/dist/deployment/utils.d.ts +6 -0
  28. package/dist/deployment/utils.d.ts.map +1 -0
  29. package/dist/deployment/utils.js +503 -0
  30. package/dist/index.d.ts +3 -0
  31. package/dist/index.d.ts.map +1 -0
  32. package/dist/index.js +2 -0
  33. package/index.cjs +1 -0
  34. package/index.d.ts +2 -0
  35. package/package.json +35 -0
  36. package/src/deployment/build-vercel-url.ts +47 -0
  37. package/src/deployment/make-deployment-lockfile.ts +22 -0
  38. package/src/deployment/use-deployment-lockfile.ts +20 -0
  39. package/src/deployment/utils.ts +151 -0
  40. package/src/index.ts +2 -0
  41. package/tsconfig.json +12 -0
  42. package/tsconfig.tsbuildinfo +1 -0
package/.eslintrc ADDED
@@ -0,0 +1,3 @@
1
+ {
2
+ "extends": ["@driveflux/eslint-config/node.js"]
3
+ }
@@ -0,0 +1,6 @@
1
+
2
+ > @driveflux/vercel@1.0.0-next.0 build /Users/flux/Projects/flux/packages/vercel
3
+ > fab
4
+
5
+ Successfully compiled: 5 files with swc (33.54ms)
6
+ Successfully compiled: 5 files with swc (47.69ms)
package/CHANGELOG.md ADDED
@@ -0,0 +1,7 @@
1
+ # @driveflux/vercel
2
+
3
+ ## 1.0.0-next.0
4
+
5
+ ### Major Changes
6
+
7
+ - 4.5 pre-release
@@ -0,0 +1 @@
1
+ export * from '../dist/deployment/build-vercel-url'
@@ -0,0 +1 @@
1
+ module.exports = require('../dist/cjs/deployment/build-vercel-url.js')
@@ -0,0 +1 @@
1
+ export * from '../dist/deployment/make-deployment-lockfile'
@@ -0,0 +1 @@
1
+ module.exports = require('../dist/cjs/deployment/make-deployment-lockfile.js')
@@ -0,0 +1 @@
1
+ export * from '../dist/deployment/use-deployment-lockfile'
@@ -0,0 +1 @@
1
+ module.exports = require('../dist/cjs/deployment/use-deployment-lockfile.js')
@@ -0,0 +1 @@
1
+ export * from '../dist/deployment/utils'
@@ -0,0 +1 @@
1
+ module.exports = require('../dist/cjs/deployment/utils.js')
@@ -0,0 +1,59 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", {
3
+ value: true
4
+ });
5
+ function _export(target, all) {
6
+ for(var name in all)Object.defineProperty(target, name, {
7
+ enumerable: true,
8
+ get: all[name]
9
+ });
10
+ }
11
+ _export(exports, {
12
+ buildVercelUrl: function() {
13
+ return buildVercelUrl;
14
+ },
15
+ isPreviewButNotStaging: function() {
16
+ return isPreviewButNotStaging;
17
+ },
18
+ truncate: function() {
19
+ return truncate;
20
+ }
21
+ });
22
+ var _crypto = /*#__PURE__*/ _interop_require_default(require("crypto"));
23
+ function _interop_require_default(obj) {
24
+ return obj && obj.__esModule ? obj : {
25
+ default: obj
26
+ };
27
+ }
28
+ var slugify = function(str) {
29
+ var slug = str.toLowerCase() // Convert to lowercase
30
+ .replace(/\//, "-") // replace one forward slash with hyphen
31
+ .replace(/[^a-z0-9-]/g, "") // Replace any non-alphanumeric characters with hyphens
32
+ .replace(/-+/g, "-") // Replace any consecutive hyphens with a single hyphen
33
+ .replace(/^-|-$/g, "") // Remove any leading or trailing hyphens
34
+ ;
35
+ return slug;
36
+ };
37
+ var truncate = function(prefix, branch, projectName, org) {
38
+ var branchSlug = slugify(branch);
39
+ var deploymentName = "".concat(projectName, "-").concat(prefix, "-").concat(branchSlug, "-").concat(org);
40
+ if (deploymentName.length < 64) {
41
+ return "https://".concat(deploymentName, ".vercel.app");
42
+ }
43
+ var hash = _crypto.default.createHash("sha256").update("git-".concat(branch).concat(projectName)).digest("hex").slice(0, 6);
44
+ var suffix = "".concat(hash.slice(0, 6), "-").concat(org);
45
+ var truncatedName = deploymentName.slice(0, 61 - suffix.length);
46
+ return "https://".concat(truncatedName, "-").concat(suffix, ".vercel.app");
47
+ };
48
+ var buildVercelUrl = function(projectName, branchName) {
49
+ var scopeSlug = "driveflux";
50
+ var prefix = "git";
51
+ return truncate(prefix, branchName, projectName, scopeSlug);
52
+ };
53
+ var isPreviewButNotStaging = function() {
54
+ var KNOWN_BRANCHES = [
55
+ "develop",
56
+ "master"
57
+ ];
58
+ return !!process.env.VERCEL_GIT_COMMIT_REF && !KNOWN_BRANCHES.includes(process.env.VERCEL_GIT_COMMIT_REF);
59
+ };
@@ -0,0 +1,186 @@
1
+ // @ts-check
2
+ "use strict";
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ var _nodechild_process = require("node:child_process");
7
+ var _nodeutil = require("node:util");
8
+ var _utils = require("./utils.js");
9
+ function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) {
10
+ try {
11
+ var info = gen[key](arg);
12
+ var value = info.value;
13
+ } catch (error) {
14
+ reject(error);
15
+ return;
16
+ }
17
+ if (info.done) {
18
+ resolve(value);
19
+ } else {
20
+ Promise.resolve(value).then(_next, _throw);
21
+ }
22
+ }
23
+ function _async_to_generator(fn) {
24
+ return function() {
25
+ var self = this, args = arguments;
26
+ return new Promise(function(resolve, reject) {
27
+ var gen = fn.apply(self, args);
28
+ function _next(value) {
29
+ asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value);
30
+ }
31
+ function _throw(err) {
32
+ asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err);
33
+ }
34
+ _next(undefined);
35
+ });
36
+ };
37
+ }
38
+ function _ts_generator(thisArg, body) {
39
+ var f, y, t, g, _ = {
40
+ label: 0,
41
+ sent: function() {
42
+ if (t[0] & 1) throw t[1];
43
+ return t[1];
44
+ },
45
+ trys: [],
46
+ ops: []
47
+ };
48
+ return g = {
49
+ next: verb(0),
50
+ "throw": verb(1),
51
+ "return": verb(2)
52
+ }, typeof Symbol === "function" && (g[Symbol.iterator] = function() {
53
+ return this;
54
+ }), g;
55
+ function verb(n) {
56
+ return function(v) {
57
+ return step([
58
+ n,
59
+ v
60
+ ]);
61
+ };
62
+ }
63
+ function step(op) {
64
+ if (f) throw new TypeError("Generator is already executing.");
65
+ while(_)try {
66
+ if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
67
+ if (y = 0, t) op = [
68
+ op[0] & 2,
69
+ t.value
70
+ ];
71
+ switch(op[0]){
72
+ case 0:
73
+ case 1:
74
+ t = op;
75
+ break;
76
+ case 4:
77
+ _.label++;
78
+ return {
79
+ value: op[1],
80
+ done: false
81
+ };
82
+ case 5:
83
+ _.label++;
84
+ y = op[1];
85
+ op = [
86
+ 0
87
+ ];
88
+ continue;
89
+ case 7:
90
+ op = _.ops.pop();
91
+ _.trys.pop();
92
+ continue;
93
+ default:
94
+ if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) {
95
+ _ = 0;
96
+ continue;
97
+ }
98
+ if (op[0] === 3 && (!t || op[1] > t[0] && op[1] < t[3])) {
99
+ _.label = op[1];
100
+ break;
101
+ }
102
+ if (op[0] === 6 && _.label < t[1]) {
103
+ _.label = t[1];
104
+ t = op;
105
+ break;
106
+ }
107
+ if (t && _.label < t[2]) {
108
+ _.label = t[2];
109
+ _.ops.push(op);
110
+ break;
111
+ }
112
+ if (t[2]) _.ops.pop();
113
+ _.trys.pop();
114
+ continue;
115
+ }
116
+ op = body.call(thisArg, _);
117
+ } catch (e) {
118
+ op = [
119
+ 6,
120
+ e
121
+ ];
122
+ y = 0;
123
+ } finally{
124
+ f = t = 0;
125
+ }
126
+ if (op[0] & 5) throw op[1];
127
+ return {
128
+ value: op[0] ? op[1] : void 0,
129
+ done: true
130
+ };
131
+ }
132
+ }
133
+ var exec = (0, _nodeutil.promisify)(_nodechild_process.exec);
134
+ var start = function() {
135
+ var _ref = _async_to_generator(function() {
136
+ return _ts_generator(this, function(_state) {
137
+ switch(_state.label){
138
+ case 0:
139
+ _state.trys.push([
140
+ 0,
141
+ ,
142
+ 3,
143
+ 5
144
+ ]);
145
+ return [
146
+ 4,
147
+ (0, _utils.makeDeploymentLockfile)()
148
+ ];
149
+ case 1:
150
+ _state.sent();
151
+ return [
152
+ 4,
153
+ exec("git add -A")
154
+ ];
155
+ case 2:
156
+ _state.sent();
157
+ return [
158
+ 3,
159
+ 5
160
+ ];
161
+ case 3:
162
+ return [
163
+ 4,
164
+ (0, _utils.restoreLockfile)()
165
+ ];
166
+ case 4:
167
+ _state.sent();
168
+ return [
169
+ 7
170
+ ];
171
+ case 5:
172
+ process.exit(0);
173
+ return [
174
+ 2
175
+ ];
176
+ }
177
+ });
178
+ });
179
+ return function start() {
180
+ return _ref.apply(this, arguments);
181
+ };
182
+ }();
183
+ process.on("SIGINT", _utils.restoreLockfile);
184
+ start().catch(function(error) {
185
+ console.error("An error occurred:", error);
186
+ });
@@ -0,0 +1,191 @@
1
+ // @ts-check
2
+ "use strict";
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ var _utils = require("./utils.js");
7
+ function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) {
8
+ try {
9
+ var info = gen[key](arg);
10
+ var value = info.value;
11
+ } catch (error) {
12
+ reject(error);
13
+ return;
14
+ }
15
+ if (info.done) {
16
+ resolve(value);
17
+ } else {
18
+ Promise.resolve(value).then(_next, _throw);
19
+ }
20
+ }
21
+ function _async_to_generator(fn) {
22
+ return function() {
23
+ var self = this, args = arguments;
24
+ return new Promise(function(resolve, reject) {
25
+ var gen = fn.apply(self, args);
26
+ function _next(value) {
27
+ asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value);
28
+ }
29
+ function _throw(err) {
30
+ asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err);
31
+ }
32
+ _next(undefined);
33
+ });
34
+ };
35
+ }
36
+ function _ts_generator(thisArg, body) {
37
+ var f, y, t, g, _ = {
38
+ label: 0,
39
+ sent: function() {
40
+ if (t[0] & 1) throw t[1];
41
+ return t[1];
42
+ },
43
+ trys: [],
44
+ ops: []
45
+ };
46
+ return g = {
47
+ next: verb(0),
48
+ "throw": verb(1),
49
+ "return": verb(2)
50
+ }, typeof Symbol === "function" && (g[Symbol.iterator] = function() {
51
+ return this;
52
+ }), g;
53
+ function verb(n) {
54
+ return function(v) {
55
+ return step([
56
+ n,
57
+ v
58
+ ]);
59
+ };
60
+ }
61
+ function step(op) {
62
+ if (f) throw new TypeError("Generator is already executing.");
63
+ while(_)try {
64
+ if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
65
+ if (y = 0, t) op = [
66
+ op[0] & 2,
67
+ t.value
68
+ ];
69
+ switch(op[0]){
70
+ case 0:
71
+ case 1:
72
+ t = op;
73
+ break;
74
+ case 4:
75
+ _.label++;
76
+ return {
77
+ value: op[1],
78
+ done: false
79
+ };
80
+ case 5:
81
+ _.label++;
82
+ y = op[1];
83
+ op = [
84
+ 0
85
+ ];
86
+ continue;
87
+ case 7:
88
+ op = _.ops.pop();
89
+ _.trys.pop();
90
+ continue;
91
+ default:
92
+ if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) {
93
+ _ = 0;
94
+ continue;
95
+ }
96
+ if (op[0] === 3 && (!t || op[1] > t[0] && op[1] < t[3])) {
97
+ _.label = op[1];
98
+ break;
99
+ }
100
+ if (op[0] === 6 && _.label < t[1]) {
101
+ _.label = t[1];
102
+ t = op;
103
+ break;
104
+ }
105
+ if (t && _.label < t[2]) {
106
+ _.label = t[2];
107
+ _.ops.push(op);
108
+ break;
109
+ }
110
+ if (t[2]) _.ops.pop();
111
+ _.trys.pop();
112
+ continue;
113
+ }
114
+ op = body.call(thisArg, _);
115
+ } catch (e) {
116
+ op = [
117
+ 6,
118
+ e
119
+ ];
120
+ y = 0;
121
+ } finally{
122
+ f = t = 0;
123
+ }
124
+ if (op[0] & 5) throw op[1];
125
+ return {
126
+ value: op[0] ? op[1] : void 0,
127
+ done: true
128
+ };
129
+ }
130
+ }
131
+ var useDeploymentLockfile = function() {
132
+ var _ref = _async_to_generator(function() {
133
+ var e;
134
+ return _ts_generator(this, function(_state) {
135
+ switch(_state.label){
136
+ case 0:
137
+ _state.trys.push([
138
+ 0,
139
+ 2,
140
+ 5,
141
+ 6
142
+ ]);
143
+ return [
144
+ 4,
145
+ (0, _utils.copyDeploymentLockfile)()
146
+ ];
147
+ case 1:
148
+ _state.sent();
149
+ return [
150
+ 3,
151
+ 6
152
+ ];
153
+ case 2:
154
+ e = _state.sent();
155
+ // Something went wrong, let's try to make the production lockfile
156
+ return [
157
+ 4,
158
+ (0, _utils.makeDeploymentLockfile)()
159
+ ];
160
+ case 3:
161
+ _state.sent();
162
+ // Now we copy the file again
163
+ return [
164
+ 4,
165
+ (0, _utils.copyDeploymentLockfile)()
166
+ ];
167
+ case 4:
168
+ _state.sent();
169
+ return [
170
+ 3,
171
+ 6
172
+ ];
173
+ case 5:
174
+ (0, _utils.removePackagesFromWorkspace)();
175
+ return [
176
+ 7
177
+ ];
178
+ case 6:
179
+ return [
180
+ 2
181
+ ];
182
+ }
183
+ });
184
+ });
185
+ return function useDeploymentLockfile() {
186
+ return _ref.apply(this, arguments);
187
+ };
188
+ }();
189
+ useDeploymentLockfile().catch(function(error) {
190
+ console.error("An error occurred:", error);
191
+ });