@linktr.ee/create-link-app 1.7.15 → 1.7.17

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/README.md CHANGED
@@ -35,6 +35,7 @@ npx @linktr.ee/create-link-app --help
35
35
  * [`create-link-app login`](#create-link-app-login)
36
36
  * [`create-link-app logout`](#create-link-app-logout)
37
37
  * [`create-link-app storybook`](#create-link-app-storybook)
38
+ * [`create-link-app test-url-match-rules URL`](#create-link-app-test-url-match-rules-url)
38
39
 
39
40
  ## `create-link-app build`
40
41
 
@@ -210,4 +211,22 @@ FLAGS
210
211
  DESCRIPTION
211
212
  Start the Storybook development server
212
213
  ```
214
+
215
+ ## `create-link-app test-url-match-rules URL`
216
+
217
+ Test URL match rules
218
+
219
+ ```
220
+ USAGE
221
+ $ create-link-app test-url-match-rules URL
222
+
223
+ ARGUMENTS
224
+ URL URL to test
225
+
226
+ DESCRIPTION
227
+ Test URL match rules
228
+
229
+ EXAMPLES
230
+ $ create-link-app test-url-match-rules https://linktr.ee/linktree
231
+ ```
213
232
  <!-- commandsstop -->
@@ -0,0 +1,68 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ const core_1 = require("@oclif/core");
7
+ const fs_1 = __importDefault(require("fs"));
8
+ const path_1 = __importDefault(require("path"));
9
+ const base_1 = __importDefault(require("../base"));
10
+ const access_token_1 = require("../lib/auth/access-token");
11
+ const test_url_match_rules_1 = __importDefault(require("../lib/deploy/test-url-match-rules"));
12
+ class TestUrlMatchRules extends base_1.default {
13
+ async run() {
14
+ const { args, flags } = await this.parse(TestUrlMatchRules);
15
+ const appConfig = await this.getAppConfig(flags.qa ? 'qa' : 'production');
16
+ const linkTypeServiceUrl = `${flags.endpoint ?? appConfig.link_types_url}/link-types`;
17
+ const accessToken = (0, access_token_1.getAccessToken)(appConfig.auth.audience);
18
+ const url = args.url;
19
+ if (!url) {
20
+ this.error('❌ URL is required', { exit: 1 });
21
+ }
22
+ // Look up the local url_match_rules.json file
23
+ const urlMatchRulesPath = resolveProjPath(process.cwd(), 'url_match_rules.json');
24
+ if (!fs_1.default.existsSync(urlMatchRulesPath)) {
25
+ this.error('❌ url_match_rules.json not found', { exit: 1 });
26
+ }
27
+ const urlMatchRulesString = fs_1.default.readFileSync(urlMatchRulesPath, 'utf8');
28
+ if (!urlMatchRulesString) {
29
+ this.error('❌ url_match_rules.json is empty');
30
+ }
31
+ let urlMatchRules = null;
32
+ try {
33
+ urlMatchRules = JSON.parse(urlMatchRulesString);
34
+ }
35
+ catch (error) {
36
+ this.error('❌ url_match_rules.json is invalid');
37
+ }
38
+ try {
39
+ const result = await (0, test_url_match_rules_1.default)(linkTypeServiceUrl, url, urlMatchRules, accessToken);
40
+ this.log('🔍 Test URL Match Rules Result:');
41
+ this.log(JSON.stringify(result, null, 2));
42
+ }
43
+ catch (error) {
44
+ this.error(`❌ Something went wrong:\n${error.message ?? 'Unknown error'}`, { exit: 1 });
45
+ }
46
+ }
47
+ }
48
+ exports.default = TestUrlMatchRules;
49
+ TestUrlMatchRules.description = 'Test URL match rules';
50
+ TestUrlMatchRules.examples = ['$ create-link-app test-url-match-rules https://linktr.ee/linktree'];
51
+ TestUrlMatchRules.args = [
52
+ {
53
+ name: 'url',
54
+ description: 'URL to test',
55
+ required: true,
56
+ },
57
+ ];
58
+ TestUrlMatchRules.flags = {
59
+ qa: core_1.Flags.boolean({
60
+ description: 'Use QA environment. Admin use only.',
61
+ hidden: true,
62
+ }),
63
+ endpoint: core_1.Flags.string({
64
+ description: 'Custom API endpoint to push assets to. Admin use only.',
65
+ hidden: true,
66
+ }),
67
+ };
68
+ const resolveProjPath = (givenPath, relativePath) => path_1.default.resolve(givenPath ?? process.cwd(), relativePath);
@@ -0,0 +1,26 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ const axios_1 = __importDefault(require("axios"));
7
+ async function testUrlMatchRules(endpoint, url, rules, accessToken) {
8
+ try {
9
+ const response = await axios_1.default.post(`${endpoint}/test-url-match-rules`, {
10
+ url,
11
+ rules,
12
+ }, {
13
+ headers: {
14
+ Authorization: `Bearer ${accessToken}`,
15
+ },
16
+ });
17
+ return response.data;
18
+ }
19
+ catch (err) {
20
+ if (axios_1.default.isAxiosError(err) && err.response) {
21
+ return err.response.data;
22
+ }
23
+ throw err;
24
+ }
25
+ }
26
+ exports.default = testUrlMatchRules;
@@ -1,5 +1,5 @@
1
1
  {
2
- "version": "1.7.15",
2
+ "version": "1.7.17",
3
3
  "commands": {
4
4
  "build": {
5
5
  "id": "build",
@@ -289,6 +289,42 @@
289
289
  }
290
290
  },
291
291
  "args": {}
292
+ },
293
+ "test-url-match-rules": {
294
+ "id": "test-url-match-rules",
295
+ "description": "Test URL match rules",
296
+ "strict": true,
297
+ "pluginName": "@linktr.ee/create-link-app",
298
+ "pluginAlias": "@linktr.ee/create-link-app",
299
+ "pluginType": "core",
300
+ "aliases": [],
301
+ "hiddenAliases": [],
302
+ "examples": [
303
+ "$ create-link-app test-url-match-rules https://linktr.ee/linktree"
304
+ ],
305
+ "flags": {
306
+ "qa": {
307
+ "name": "qa",
308
+ "type": "boolean",
309
+ "description": "Use QA environment. Admin use only.",
310
+ "hidden": true,
311
+ "allowNo": false
312
+ },
313
+ "endpoint": {
314
+ "name": "endpoint",
315
+ "type": "option",
316
+ "description": "Custom API endpoint to push assets to. Admin use only.",
317
+ "hidden": true,
318
+ "multiple": false
319
+ }
320
+ },
321
+ "args": {
322
+ "url": {
323
+ "name": "url",
324
+ "description": "URL to test",
325
+ "required": true
326
+ }
327
+ }
292
328
  }
293
329
  }
294
330
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@linktr.ee/create-link-app",
3
- "version": "1.7.15",
3
+ "version": "1.7.17",
4
4
  "description": "Create a Link App on Linktr.ee.",
5
5
  "license": "UNLICENSED",
6
6
  "author": "Linktree",
@@ -1,10 +0,0 @@
1
- {
2
- "hostnames": [
3
- "example.com"
4
- ],
5
- "patterns": [
6
- {
7
- "pathname": "/path1"
8
- }
9
- ]
10
- }
@@ -7,7 +7,8 @@
7
7
  "upload": "create-link-app deploy",
8
8
  "storybook": "create-link-app storybook",
9
9
  "dev": "create-link-app dev",
10
- "prepack": "create-link-app build --native"
10
+ "prepack": "create-link-app build --native",
11
+ "test-url-match-rules": "create-link-app test-url-match-rules"
11
12
  },
12
13
  "devDependencies": {
13
14
  "@linktr.ee/create-link-app": "latest",