@linktr.ee/create-link-app 1.1.6 → 1.4.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/README.md CHANGED
@@ -2,18 +2,24 @@
2
2
 
3
3
  CLI tool to create [Link Apps](https://linktr.ee/marketplace) on [Linktr.ee](https://linktr.ee).
4
4
 
5
- ## Getting Started
5
+ [Public document](https://docs.linktr.ee/sdk-documentation)
6
6
 
7
- Create a project with either npm:
7
+ ## Getting Started
8
8
 
9
+ (Optional) Install create-link-app globally
9
10
  ```sh
10
- npm init @linktr.ee/create-link-app my-link-app
11
- ```
11
+ yarn global add @linktr.ee/create-link-app
12
+ # or
13
+ npm install -g @linktr.ee/create-link-app
12
14
 
13
- Or Yarn:
15
+ which create-link-app
16
+
17
+ create-link-app --help
18
+ ```
14
19
 
20
+ Or run with npx
15
21
  ```sh
16
- yarn create @linktr.ee/create-link-app my-link-app
22
+ npx @linktr.ee/create-link-app --help
17
23
  ```
18
24
 
19
25
  ## Commands
@@ -22,7 +22,8 @@ class Create extends base_1.default {
22
22
  const relativeProjectPath = path_1.default.relative(process.cwd(), targetDir);
23
23
  this.log('✅ Project created, to get started:\n');
24
24
  this.log(` cd ${relativeProjectPath}`);
25
- this.log(` ${useYarn ? 'yarn dev' : 'npm run dev'}\n`);
25
+ this.log(` yarn install | npm install`);
26
+ this.log(` yarn dev | npm run dev\n`);
26
27
  }
27
28
  }
28
29
  exports.default = Create;
@@ -37,15 +37,6 @@ class GenerateTypes extends base_1.default {
37
37
  await this.cmd(`echo " * These types were autogenerated by @linktr.ee/create-link-app" >> ${this.typesPath}/index.ts`);
38
38
  await this.cmd(`echo " * https://www.npmjs.com/package/@linktr.ee/create-link-app " >> ${this.typesPath}/index.ts`);
39
39
  await this.cmd(`echo " */" >> ${this.typesPath}/index.ts`);
40
- // Generate and append types
41
- await this.generateAndAppendSchemaType('editablePublic');
42
- await this.log('✓ Generated EditablePublicData type');
43
- await this.generateAndAppendSchemaType('readonlyPublic');
44
- await this.log('✓ Generated ReadonlyPublicData type');
45
- await this.generateAndAppendSchemaType('editablePrivate');
46
- await this.log('✓ Generated EditablePrivateData type');
47
- await this.generateAndAppendSchemaType('readonlyPrivate');
48
- await this.log('✓ Generated ReadonlyPrivateData type');
49
40
  // Clean up file formatting
50
41
  await this.cmd(`npx prettier ${this.typesPath}/index.ts --write`);
51
42
  await this.log('✓ All types created successfully');
@@ -8,11 +8,6 @@ const fs_1 = __importDefault(require("fs"));
8
8
  const path_1 = __importDefault(require("path"));
9
9
  /**
10
10
  * Pack the Link App source files into `package.tgz`. This includes the following:
11
- * - `schema/editablePublic.jtd.json`
12
- * - `schema/readonlyPublic.jtd.json`
13
- * - `schema/editablePrivate.jtd.json`
14
- * - `schema/readonlyPrivate.jtd.json`
15
- * - `schema/system.jtd.json`
16
11
  * - `src/`
17
12
  * - `schema.json`
18
13
  * - `package.json`
@@ -53,11 +48,6 @@ async function packProject() {
53
48
  handleFailure(err);
54
49
  });
55
50
  archive.pipe(outputWriteStream);
56
- archive.file(resolveProjPath('schema/editablePublic.jtd.json'), { name: 'schema/editablePublic.jtd.json' });
57
- archive.file(resolveProjPath('schema/readonlyPublic.jtd.json'), { name: 'schema/readonlyPublic.jtd.json' });
58
- archive.file(resolveProjPath('schema/editablePrivate.jtd.json'), { name: 'schema/editablePrivate.jtd.json' });
59
- archive.file(resolveProjPath('schema/readonlyPrivate.jtd.json'), { name: 'schema/readonlyPrivate.jtd.json' });
60
- archive.file(resolveProjPath('schema/system.jtd.json'), { name: 'schema/system.jtd.json' });
61
51
  archive.file(resolveProjPath('package.json'), { name: 'package.json' });
62
52
  archive.file(resolveProjPath('package-lock.json'), { name: 'package-lock.json' });
63
53
  archive.file(resolveProjPath('yarn.lock'), { name: 'yarn.lock' });
@@ -3,12 +3,11 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
3
3
  return (mod && mod.__esModule) ? mod : { "default": mod };
4
4
  };
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
- const fs_extra_1 = __importDefault(require("fs-extra"));
7
- const path_1 = __importDefault(require("path"));
8
6
  const jtd_js_1 = __importDefault(require("ajv/dist/jtd.js"));
9
7
  const index_js_1 = __importDefault(require("ajv/dist/standalone/index.js"));
10
- const schemaNames = ['editablePublic', 'readonlyPublic', 'editablePrivate', 'readonlyPrivate', 'system'];
11
- async function compileSchema() {
8
+ const fs_extra_1 = __importDefault(require("fs-extra"));
9
+ const path_1 = __importDefault(require("path"));
10
+ async function compileSchema(schemaNames) {
12
11
  try {
13
12
  const ajv = new jtd_js_1.default({
14
13
  // @ts-expect-error: In JTD mode some options are not typed correctly.
@@ -10,7 +10,7 @@ const root = document.getElementById('root');
10
10
  // First set up event handler for extension data
11
11
  window.addEventListener('message', function handler(event) {
12
12
  if (!__ALLOW_ANY_ORIGIN__) {
13
- if (!/^https:\/\/(qa\.)?linktr.ee$|^https:\/\/linktree\.local$/.test(event.origin))
13
+ if (!/^https:\/\/(qa\.)?linktr.ee$|^https:\/\/linktree\.local$|^https?:\/\/localhost(:\d+)?$/.test(event.origin))
14
14
  return;
15
15
  }
16
16
  if (event.data?.type !== 'extension-data')
@@ -130,7 +130,8 @@ async function default_1(env, options) {
130
130
  const exposedEntryPoints = {
131
131
  // Default entry points
132
132
  ['./App']: appEntry,
133
- ['./validate']: toVirtualModule((await (0, compile_1.default)())),
133
+ // Add schema if we need to
134
+ ['./validate']: toVirtualModule((await (0, compile_1.default)([]))),
134
135
  };
135
136
  if (useEditorEntry) {
136
137
  exposedEntryPoints['./Editor'] = path_1.default.resolve(appDir, 'src/Editor');
@@ -1,5 +1,5 @@
1
1
  {
2
- "version": "1.1.6",
2
+ "version": "1.4.0",
3
3
  "commands": {
4
4
  "build": {
5
5
  "id": "build",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@linktr.ee/create-link-app",
3
- "version": "1.1.6",
3
+ "version": "1.4.0",
4
4
  "description": "Create a Link App on Linktr.ee.",
5
5
  "license": "UNLICENSED",
6
6
  "author": "Linktree",
@@ -45,7 +45,7 @@
45
45
  "@storybook/manager-webpack5": "^6.5.9",
46
46
  "@storybook/react": "^6.5.9",
47
47
  "@tailwindcss/line-clamp": "^0.4.4",
48
- "@testing-library/react": "^12.1.4",
48
+ "@testing-library/react": "^16.3.0",
49
49
  "@testing-library/user-event": "14",
50
50
  "ajv": "^8.12.0",
51
51
  "archiver": "^5.3.1",
@@ -83,6 +83,7 @@
83
83
  },
84
84
  "devDependencies": {
85
85
  "@oclif/test": "^2.1.0",
86
+ "@storybook/core-common": "^8.6.14",
86
87
  "@types/archiver": "^5.3.1",
87
88
  "@types/axios": "^0.14.0",
88
89
  "@types/form-data": "^2.5.0",
@@ -95,6 +96,7 @@
95
96
  "babel-jest": "^29.7.0",
96
97
  "jest": "^28.1.1",
97
98
  "oclif": "^3.0.1",
99
+ "postcss-load-config": "^6.0.1",
98
100
  "shx": "^0.3.4",
99
101
  "ts-jest": "^28.0.4",
100
102
  "ts-node": "^10.8.1",
@@ -21,27 +21,7 @@ Several files were created during the bootstrapping of this project. Some of the
21
21
  | `settings.json` | Defines the settings made available to Linktree users when configuring the Link App via [Linktree Admin](https://linktr.ee/admin) |
22
22
  | `fixtures/props-data.json` | Used during development, this file acts as mock data for the `settings.json` output, it is injected as props to the entry point component |
23
23
  | `url-match-rules.json` | Defines the URL pattern to match against when users add a link on Linktree via URL, its structure follows the [URL Pattern API](https://developer.mozilla.org/en-US/docs/Web/API/URL_Pattern_API) |
24
- | `schema/*.jtd.json` | These files define the shape of the data that is stored for each Link that uses this Link App. They are used to validate the data on the front and back end and to generate Typescript types shared between client and server. The format for these schemas adheres to the [JSON Type Definition](https://jsontypedef.com/), aka [RFC 8927](https://datatracker.ietf.org/doc/html/rfc8927), standard. |
25
24
 
26
- ## Generating types from your `schema/*.jtd.json` files
27
-
28
- Under the hood Linktree uses the `jtd-codegen` package to generate types from your schema. If you want to generate types for local development, this package must first be installed on your system. You can install it with the following command:
29
-
30
- ```sh
31
- brew install jsontypedef/jsontypedef/jtd-codegen
32
- ```
33
-
34
- You will also require `prettier`
35
-
36
- ```sh
37
- brew install prettier
38
- ```
39
-
40
- When you have these packages installed, you can generate types by running one of the following commands:
41
-
42
- `npm run generate:types` or `yarn generate:types`
43
-
44
- For more information on using `jtd-codegen` to generate code see the [official documentation](https://jsontypedef.com/docs/jtd-codegen/), or for specifics on generating Typescript code [here](https://jsontypedef.com/docs/typescript-codegen/).
45
25
 
46
26
  ## UI Components
47
27
 
@@ -1,3 +1,4 @@
1
1
  {
2
- "title": "Link App Title"
2
+ "__linkUrl": "https://linktr.ee/linkapp",
3
+ "__layout": "STACK"
3
4
  }
@@ -6,6 +6,7 @@
6
6
  "This example code acts as a base for experimenting with link type capabilities"
7
7
  ],
8
8
  "manifest_version": "1.0.0",
9
+ "version": "1.0.0",
9
10
  "supporting_links": {
10
11
  "terms_of_service": "https://example.com/terms-of-service",
11
12
  "privacy_policy": "https://example.com/privacy-policy"
@@ -2,14 +2,16 @@
2
2
  "private": true,
3
3
  "scripts": {
4
4
  "build": "create-link-app build",
5
- "deploy": "create-link-app deploy",
5
+ "login": "create-link-app login",
6
+ "logout": "create-link-app logout",
7
+ "upload": "create-link-app deploy",
8
+ "update": "create-link-app deploy --update",
6
9
  "storybook": "create-link-app storybook",
7
10
  "dev": "create-link-app dev",
8
- "generate:types": "jtd-codegen ./schema.json --typescript-out src/types --root-name=LinkAppData"
11
+ "prepack": "create-link-app build --native"
9
12
  },
10
13
  "devDependencies": {
11
- "@linktr.ee/component-library": "latest",
12
- "@linktr.ee/create-link-app": "next",
14
+ "@linktr.ee/create-link-app": "latest",
13
15
  "@linktr.ee/ui-link-kit": "latest"
14
16
  }
15
17
  }
@@ -1,9 +1,12 @@
1
- import P from '@linktr.ee/component-library/P'
2
-
3
1
  import './tailwind.css'
4
2
 
5
- function App({ title }) {
6
- return <P>{title}</P>
3
+ function App({ __linkUrl, __layout }) {
4
+ return (
5
+ <div>
6
+ <p>{__linkUrl}</p>
7
+ <p>{__layout}</p>
8
+ </div>
9
+ )
7
10
  }
8
11
 
9
12
  export default App
@@ -2,14 +2,15 @@
2
2
  "private": true,
3
3
  "scripts": {
4
4
  "build": "create-link-app build",
5
- "deploy": "create-link-app deploy",
5
+ "login": "create-link-app login",
6
+ "logout": "create-link-app logout",
7
+ "upload": "create-link-app deploy",
8
+ "update": "create-link-app deploy --update",
6
9
  "storybook": "create-link-app storybook",
7
10
  "dev": "create-link-app dev",
8
- "generate:types": "create-link-app generate-types",
9
11
  "prepack": "create-link-app build --native"
10
12
  },
11
13
  "devDependencies": {
12
- "@linktr.ee/component-library": "latest",
13
14
  "@linktr.ee/create-link-app": "latest",
14
15
  "@linktr.ee/ui-link-kit": "latest",
15
16
  "@types/react": "^18.2.8",
@@ -1,22 +1,22 @@
1
1
  import { Featured, Carousel, Grid, Stack } from './components/Layouts'
2
- import { AppProps, Layout } from './types'
2
+ import { AppProps } from './types'
3
3
 
4
4
  import './tailwind.css'
5
5
 
6
6
  function App(props: AppProps) {
7
- const { layout } = props
7
+ const { __layout } = props
8
8
 
9
- switch (layout) {
10
- case Layout.Stack:
9
+ switch (__layout) {
10
+ case 'STACK':
11
11
  return <Stack {...props} />
12
- case Layout.Grid:
12
+ case 'GRID':
13
13
  return <Grid {...props} />
14
- case Layout.Carousel:
14
+ case 'CAROUSEL':
15
15
  return <Carousel {...props} />
16
- case Layout.Featured:
16
+ case 'FEATURED':
17
17
  return <Featured {...props} />
18
18
  default:
19
- return <div>Unknown layout: {props.layout}</div>
19
+ return <div>Unknown layout: {__layout}</div>
20
20
  }
21
21
  }
22
22
 
@@ -3,8 +3,6 @@ import { ComponentStory, ComponentMeta } from '@storybook/react'
3
3
  import manifest from '../../manifest.json'
4
4
  import fixture from '../../fixtures/props-data.json'
5
5
 
6
- import { Layout } from '../types'
7
-
8
6
  import LinkApp from '../App'
9
7
 
10
8
  import './tailwind.sb.css'
@@ -42,7 +40,7 @@ export const Stack: ComponentStory<typeof LinkApp> = (args) => (
42
40
  </div>
43
41
  )
44
42
  Stack.args = {
45
- layout: Layout.Stack,
43
+ __layout: 'STACK',
46
44
  }
47
45
 
48
46
  export const Grid: ComponentStory<typeof LinkApp> = (args) => (
@@ -58,7 +56,7 @@ export const Grid: ComponentStory<typeof LinkApp> = (args) => (
58
56
  </div>
59
57
  )
60
58
  Grid.args = {
61
- layout: Layout.Grid,
59
+ __layout: 'GRID',
62
60
  }
63
61
 
64
62
  export const Carousel: ComponentStory<typeof LinkApp> = (args) => (
@@ -74,7 +72,7 @@ export const Carousel: ComponentStory<typeof LinkApp> = (args) => (
74
72
  </div>
75
73
  )
76
74
  Carousel.args = {
77
- layout: Layout.Carousel,
75
+ __layout: 'CAROUSEL',
78
76
  }
79
77
 
80
78
  export const Featured: ComponentStory<typeof LinkApp> = (args) => (
@@ -90,5 +88,5 @@ export const Featured: ComponentStory<typeof LinkApp> = (args) => (
90
88
  </div>
91
89
  )
92
90
  Featured.args = {
93
- layout: Layout.Featured,
91
+ __layout: 'FEATURED',
94
92
  }
@@ -1,8 +1,15 @@
1
- import type { HostData } from '@linktr.ee/ui-link-kit/Schemas'
2
- import { EditablePrivateData, EditablePublicData, ReadonlyPrivateData, ReadonlyPublicData } from './schema'
1
+ type LinktreeLinkAppContext = {
2
+ /**
3
+ * The URL of the link.
4
+ */
5
+ __linkUrl: string
3
6
 
4
- export type { HostData } from '@linktr.ee/ui-link-kit/Schemas'
5
- export { HostDataLayout as Layout } from '@linktr.ee/ui-link-kit/Schemas'
7
+ /**
8
+ * The layout style for the link in Linktree profile page.
9
+ */
10
+ __layout: 'STACK' | 'GRID' | 'CAROUSEL' | 'FEATURED'
11
+ }
6
12
 
7
- export type AppProps = HostData & EditablePublicData & ReadonlyPublicData
8
- export type EditorProps = EditablePublicData & ReadonlyPublicData & EditablePrivateData & ReadonlyPrivateData
13
+ export type AppProps = LinktreeLinkAppContext & {
14
+ // Additional properties here
15
+ }
@@ -1,6 +0,0 @@
1
- {
2
- "metadata": {
3
- "description": "These are properties that the Linker can `read` and `write`, but the Visitor will never have access to."
4
- },
5
- "properties": {}
6
- }
@@ -1,10 +0,0 @@
1
- {
2
- "metadata": {
3
- "description": "These are properties that the Linker can `read` and `write`, and the Visitor can `read`"
4
- },
5
- "properties": {
6
- "thumbnailUrl": { "type": "string" },
7
- "title": { "type": "string" },
8
- "url": { "type": "string" }
9
- }
10
- }
@@ -1,8 +0,0 @@
1
- {
2
- "metadata": {
3
- "description": "These are properties that only the Linker can `read`. The Visitor will never have access to these properties"
4
- },
5
- "properties": {
6
- "httpResponseCode": { "type": "int16" }
7
- }
8
- }
@@ -1,6 +0,0 @@
1
- {
2
- "metadata": {
3
- "description": "These are properties that the Linker can `read`, and the Visitor can `read`"
4
- },
5
- "properties": {}
6
- }
@@ -1,6 +0,0 @@
1
- {
2
- "metadata": {
3
- "description": "These are internal-only properties that neither the Linker nor Visitor will ever have access to."
4
- },
5
- "properties": {}
6
- }
@@ -1,7 +0,0 @@
1
- import './tailwind.css'
2
-
3
- const Editor = () => {
4
- return <div>Editor</div>
5
- }
6
-
7
- export default Editor
@@ -1,7 +0,0 @@
1
- import './tailwind.css'
2
-
3
- const Sheet = () => {
4
- return <div>Sheet</div>
5
- }
6
-
7
- export default Sheet
@@ -1,33 +0,0 @@
1
- /**
2
- * These types were autogenerated by @linktr.ee/create-link-app
3
- * https://www.npmjs.com/package/@linktr.ee/create-link-app
4
- */
5
-
6
- /**
7
- * These are properties that the Linker can `read` and `write`, and the Visitor
8
- * can `read`
9
- */
10
- export interface EditablePublicData {
11
- thumbnailUrl: string
12
- title: string
13
- url: string
14
- }
15
-
16
- /**
17
- * These are properties that the Linker can `read`, and the Visitor can `read`
18
- */
19
- export interface ReadonlyPublicData {}
20
-
21
- /**
22
- * These are properties that the Linker can `read` and `write`, but the Visitor
23
- * will never have access to.
24
- */
25
- export interface EditablePrivateData {}
26
-
27
- /**
28
- * These are properties that only the Linker can `read`. The Visitor will never
29
- * have access to these properties
30
- */
31
- export interface ReadonlyPrivateData {
32
- httpResponseCode: number
33
- }