@linktr.ee/create-link-app 1.7.1 → 1.7.4
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/commands/deploy.js +25 -19
- package/dist/lib/deploy/pack-project.js +10 -10
- package/oclif.manifest.json +8 -1
- package/package.json +1 -1
package/dist/commands/deploy.js
CHANGED
|
@@ -12,18 +12,13 @@ const pack_project_1 = __importDefault(require("../lib/deploy/pack-project"));
|
|
|
12
12
|
const upload_assets_1 = __importDefault(require("../lib/deploy/upload-assets"));
|
|
13
13
|
class Deploy extends base_1.default {
|
|
14
14
|
async run() {
|
|
15
|
-
try {
|
|
16
|
-
await this.parse(Deploy);
|
|
17
|
-
}
|
|
18
|
-
catch (err) {
|
|
19
|
-
console.log('err', err);
|
|
20
|
-
}
|
|
21
15
|
const { flags } = await this.parse(Deploy);
|
|
22
16
|
const appConfig = await this.getAppConfig(flags.qa ? 'qa' : 'production');
|
|
23
17
|
const accessToken = (0, access_token_1.getAccessToken)(appConfig.auth.audience);
|
|
24
18
|
const linkTypeServiceUrl = `${flags.endpoint ?? appConfig.link_types_url}/link-types`;
|
|
25
19
|
const isForceUpdate = !!flags['force-update'];
|
|
26
|
-
const
|
|
20
|
+
const isQa = !!flags.qa;
|
|
21
|
+
const packedFiles = await (0, pack_project_1.default)(flags.path);
|
|
27
22
|
this.log(`\n===`);
|
|
28
23
|
if (isForceUpdate) {
|
|
29
24
|
this.log('⚠️ "--force-update" flag will impact the existing PUBLISHED Link Apps.\n');
|
|
@@ -34,14 +29,16 @@ class Deploy extends base_1.default {
|
|
|
34
29
|
this.log(` - ${file}`);
|
|
35
30
|
});
|
|
36
31
|
}
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
32
|
+
if (!flags['skip-confirm']) {
|
|
33
|
+
const userConfirmDeploy = await core_1.CliUx.ux.prompt(`❓ ${isQa ? '[QA]' : ''} Do you want to proceed? (Y/n)`, { required: false });
|
|
34
|
+
if (userConfirmDeploy?.toLowerCase() !== 'y') {
|
|
35
|
+
this.log('Aborted!');
|
|
36
|
+
return;
|
|
37
|
+
}
|
|
41
38
|
}
|
|
42
|
-
const form = (0, create_form_data_1.default)(flags.path);
|
|
43
39
|
let linkTypeErrorCode = null;
|
|
44
40
|
try {
|
|
41
|
+
const form = (0, create_form_data_1.default)(flags.path);
|
|
45
42
|
const result = await (0, upload_assets_1.default)(linkTypeServiceUrl, form, accessToken, flags.update, isForceUpdate);
|
|
46
43
|
await this.processSuccess(flags, result);
|
|
47
44
|
}
|
|
@@ -66,13 +63,16 @@ class Deploy extends base_1.default {
|
|
|
66
63
|
}
|
|
67
64
|
}
|
|
68
65
|
if (linkTypeErrorCode === 'LINK_TYPE_ALREADY_EXISTS' && !flags.update && !isForceUpdate) {
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
66
|
+
if (!flags['skip-confirm']) {
|
|
67
|
+
this.log(`\n⚠️ [${isQa ? '[QA]' : ''}] This Link Type already exists! Do you want to update it?\n`);
|
|
68
|
+
const userConfirmUpdate = await core_1.CliUx.ux.prompt(`❓ Do you want to proceed? (Y/n)`, { required: false });
|
|
69
|
+
if (userConfirmUpdate.toLowerCase() !== 'y') {
|
|
70
|
+
this.log('Aborted!');
|
|
71
|
+
return;
|
|
72
|
+
}
|
|
74
73
|
}
|
|
75
74
|
try {
|
|
75
|
+
const form = (0, create_form_data_1.default)(flags.path);
|
|
76
76
|
const result = await (0, upload_assets_1.default)(linkTypeServiceUrl, form, accessToken, true, isForceUpdate);
|
|
77
77
|
await this.processSuccess(flags, result);
|
|
78
78
|
}
|
|
@@ -93,7 +93,7 @@ class Deploy extends base_1.default {
|
|
|
93
93
|
this.log(`\n===`);
|
|
94
94
|
this.log(JSON.stringify(result, null, 2));
|
|
95
95
|
const linkTypeId = result.linkType.linkTypeId;
|
|
96
|
-
const buildId = result.build
|
|
96
|
+
const buildId = result.build?.id;
|
|
97
97
|
const linkAppBuildUrl = flags.qa
|
|
98
98
|
? `https://buildkite.com/linktree/link-types-ci-service/builds/${buildId}`
|
|
99
99
|
: `https://linkapp-ci.replit.app/?linkTypeId=${linkTypeId}&buildId=${buildId}`;
|
|
@@ -103,7 +103,9 @@ class Deploy extends base_1.default {
|
|
|
103
103
|
this.log(`\n===`);
|
|
104
104
|
this.log(`✅ Draft Link App successfully ${flags.update ? 'updated' : 'uploaded'}`);
|
|
105
105
|
this.log(` - Link App ID: ${linkTypeId}`);
|
|
106
|
-
|
|
106
|
+
if (buildId) {
|
|
107
|
+
this.log(` - Check Link App build: ${linkAppBuildUrl}`);
|
|
108
|
+
}
|
|
107
109
|
this.log(` - Create Link App: ${linkAppCreateUrl}`);
|
|
108
110
|
}
|
|
109
111
|
}
|
|
@@ -130,4 +132,8 @@ Deploy.flags = {
|
|
|
130
132
|
description: 'Allow Link Type Admins to push updates to Link Apps in PUBLISHED state. Admin use only.',
|
|
131
133
|
hidden: true,
|
|
132
134
|
}),
|
|
135
|
+
'skip-confirm': core_1.Flags.boolean({
|
|
136
|
+
description: 'Skip confirmation prompt',
|
|
137
|
+
hidden: true,
|
|
138
|
+
}),
|
|
133
139
|
};
|
|
@@ -32,7 +32,7 @@ const path_1 = __importDefault(require("path"));
|
|
|
32
32
|
/**
|
|
33
33
|
* Pack the Link App source files into `package.tgz`. This includes the above required/optional directories and files.
|
|
34
34
|
*/
|
|
35
|
-
async function packProject() {
|
|
35
|
+
async function packProject(givenPath) {
|
|
36
36
|
const requiredFiles = ['manifest.json'];
|
|
37
37
|
const optionalDirs = ['src']; // For legacy LinkApp, it could have no src code.
|
|
38
38
|
const optionalFiles = [
|
|
@@ -40,13 +40,13 @@ async function packProject() {
|
|
|
40
40
|
'package-lock.json',
|
|
41
41
|
'yarn.lock',
|
|
42
42
|
'tsconfig.json',
|
|
43
|
-
'
|
|
43
|
+
'url_match_rules.json',
|
|
44
44
|
'settings.json',
|
|
45
45
|
'icon.svg',
|
|
46
46
|
];
|
|
47
47
|
const packedFiles = [];
|
|
48
48
|
await new Promise((resolve, reject) => {
|
|
49
|
-
const outputPath = resolveProjPath('package.tgz');
|
|
49
|
+
const outputPath = resolveProjPath(givenPath, 'package.tgz');
|
|
50
50
|
const outputWriteStream = fs_1.default.createWriteStream(outputPath);
|
|
51
51
|
const handleSuccess = () => resolve();
|
|
52
52
|
const handleFailure = (err) => {
|
|
@@ -67,21 +67,21 @@ async function packProject() {
|
|
|
67
67
|
});
|
|
68
68
|
archive.pipe(outputWriteStream);
|
|
69
69
|
requiredFiles.forEach((fileName) => {
|
|
70
|
-
if (!fs_1.default.existsSync(resolveProjPath(fileName))) {
|
|
70
|
+
if (!fs_1.default.existsSync(resolveProjPath(givenPath, fileName))) {
|
|
71
71
|
handleFailure(new archiver_1.ArchiverError(`File ${fileName} does not exist`, 'ENOENT'));
|
|
72
72
|
}
|
|
73
|
-
archive.file(resolveProjPath(fileName), { name: fileName });
|
|
73
|
+
archive.file(resolveProjPath(givenPath, fileName), { name: fileName });
|
|
74
74
|
packedFiles.push(fileName);
|
|
75
75
|
});
|
|
76
76
|
optionalFiles.forEach((fileName) => {
|
|
77
|
-
if (fs_1.default.existsSync(resolveProjPath(fileName))) {
|
|
78
|
-
archive.file(resolveProjPath(fileName), { name: fileName });
|
|
77
|
+
if (fs_1.default.existsSync(resolveProjPath(givenPath, fileName))) {
|
|
78
|
+
archive.file(resolveProjPath(givenPath, fileName), { name: fileName });
|
|
79
79
|
packedFiles.push(fileName);
|
|
80
80
|
}
|
|
81
81
|
});
|
|
82
82
|
optionalDirs.forEach((dirName) => {
|
|
83
|
-
if (fs_1.default.existsSync(resolveProjPath(dirName)) && fs_1.default.statSync(resolveProjPath(dirName)).isDirectory()) {
|
|
84
|
-
archive.directory(resolveProjPath(`${dirName}/`), dirName);
|
|
83
|
+
if (fs_1.default.existsSync(resolveProjPath(givenPath, dirName)) && fs_1.default.statSync(resolveProjPath(givenPath, dirName)).isDirectory()) {
|
|
84
|
+
archive.directory(resolveProjPath(givenPath, `${dirName}/`), dirName);
|
|
85
85
|
packedFiles.push(`${dirName}/`);
|
|
86
86
|
}
|
|
87
87
|
});
|
|
@@ -90,5 +90,5 @@ async function packProject() {
|
|
|
90
90
|
packedFiles.sort();
|
|
91
91
|
return packedFiles;
|
|
92
92
|
}
|
|
93
|
-
const resolveProjPath = (relativePath) => path_1.default.resolve(process.cwd(), relativePath);
|
|
93
|
+
const resolveProjPath = (givenPath, relativePath) => path_1.default.resolve(givenPath ?? process.cwd(), relativePath);
|
|
94
94
|
exports.default = packProject;
|
package/oclif.manifest.json
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
{
|
|
2
|
-
"version": "1.7.
|
|
2
|
+
"version": "1.7.4",
|
|
3
3
|
"commands": {
|
|
4
4
|
"build": {
|
|
5
5
|
"id": "build",
|
|
@@ -119,6 +119,13 @@
|
|
|
119
119
|
"description": "Allow Link Type Admins to push updates to Link Apps in PUBLISHED state. Admin use only.",
|
|
120
120
|
"hidden": true,
|
|
121
121
|
"allowNo": false
|
|
122
|
+
},
|
|
123
|
+
"skip-confirm": {
|
|
124
|
+
"name": "skip-confirm",
|
|
125
|
+
"type": "boolean",
|
|
126
|
+
"description": "Skip confirmation prompt",
|
|
127
|
+
"hidden": true,
|
|
128
|
+
"allowNo": false
|
|
122
129
|
}
|
|
123
130
|
},
|
|
124
131
|
"args": {}
|