@linktr.ee/create-link-app 0.3.0-next.8 → 1.0.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 +24 -8
- package/dist/commands/build.js +19 -3
- package/dist/commands/dev.js +2 -1
- package/dist/commands/generate-types.js +111 -0
- package/dist/commands/storybook.js +1 -1
- package/dist/lib/create/create-project.js +3 -2
- package/dist/lib/deploy/create-form-data.js +10 -5
- package/dist/lib/deploy/pack-project.js +14 -3
- package/dist/lib/schema/compile.js +30 -0
- package/dist/postcss/postcss.config.js +22 -11
- package/dist/storybook/global.css +53 -0
- package/dist/storybook/main.js +25 -25
- package/dist/storybook/preview.js +10 -1
- package/dist/webpack/webpack.config.js +40 -32
- package/oclif.manifest.json +19 -2
- package/package.json +17 -10
- package/templates/common/README.md +38 -17
- package/templates/common/gitignore +2 -0
- package/templates/common/schema/editablePrivate.jtd.json +6 -0
- package/templates/common/schema/editablePublic.jtd.json +10 -0
- package/templates/common/schema/readonlyPrivate.jtd.json +8 -0
- package/templates/common/schema/readonlyPublic.jtd.json +6 -0
- package/templates/common/schema/system.jtd.json +6 -0
- package/templates/common/settings.json +11 -23
- package/templates/react/package.json +3 -2
- package/templates/react/src/index.jsx +2 -0
- package/templates/react/src/tailwind.css +5 -0
- package/templates/react-ts/package.json +31 -5
- package/templates/react-ts/src/App.tsx +23 -0
- package/templates/react-ts/src/Editor.tsx +7 -0
- package/templates/react-ts/src/Sheet.tsx +7 -0
- package/templates/react-ts/src/components/Layouts.tsx +59 -0
- package/templates/react-ts/src/stories/LinkApp.stories.tsx +71 -15
- package/templates/react-ts/src/stories/tailwind.sb.css +5 -0
- package/templates/react-ts/src/tailwind.css +4 -0
- package/templates/react-ts/src/types/global.d.ts +2 -4
- package/templates/react-ts/src/types/hack.d.ts +8 -0
- package/templates/react-ts/src/types/index.ts +7 -7
- package/templates/react-ts/src/types/schema/index.ts +33 -0
- package/templates/react-ts/tsconfig.json +0 -1
- package/templates/react-ts/src/index.tsx +0 -8
package/README.md
CHANGED
|
@@ -23,8 +23,9 @@ yarn create @linktr.ee/create-link-app my-link-app
|
|
|
23
23
|
* [`create-link-app create NAME`](#create-link-app-create-name)
|
|
24
24
|
* [`create-link-app deploy`](#create-link-app-deploy)
|
|
25
25
|
* [`create-link-app dev`](#create-link-app-dev)
|
|
26
|
+
* [`create-link-app generate-types`](#create-link-app-generate-types)
|
|
26
27
|
* [`create-link-app grant-access LINK_APP_ID USERNAME`](#create-link-app-grant-access-link_app_id-username)
|
|
27
|
-
* [`create-link-app help [
|
|
28
|
+
* [`create-link-app help [COMMAND]`](#create-link-app-help-command)
|
|
28
29
|
* [`create-link-app login`](#create-link-app-login)
|
|
29
30
|
* [`create-link-app logout`](#create-link-app-logout)
|
|
30
31
|
* [`create-link-app storybook`](#create-link-app-storybook)
|
|
@@ -35,7 +36,10 @@ Build Link App project to static assets used for production
|
|
|
35
36
|
|
|
36
37
|
```
|
|
37
38
|
USAGE
|
|
38
|
-
$ create-link-app build
|
|
39
|
+
$ create-link-app build [--native]
|
|
40
|
+
|
|
41
|
+
FLAGS
|
|
42
|
+
--native Build native components of a Link App ready for publishing to npm
|
|
39
43
|
|
|
40
44
|
DESCRIPTION
|
|
41
45
|
Build Link App project to static assets used for production
|
|
@@ -107,6 +111,18 @@ EXAMPLES
|
|
|
107
111
|
$ create-link-app dev --https
|
|
108
112
|
```
|
|
109
113
|
|
|
114
|
+
## `create-link-app generate-types`
|
|
115
|
+
|
|
116
|
+
Generate Typescript types from the schema definitions
|
|
117
|
+
|
|
118
|
+
```
|
|
119
|
+
USAGE
|
|
120
|
+
$ create-link-app generate-types
|
|
121
|
+
|
|
122
|
+
DESCRIPTION
|
|
123
|
+
Generate Typescript types from the schema definitions
|
|
124
|
+
```
|
|
125
|
+
|
|
110
126
|
## `create-link-app grant-access LINK_APP_ID USERNAME`
|
|
111
127
|
|
|
112
128
|
Grant access to other developers to push updates for your Link App
|
|
@@ -126,16 +142,16 @@ EXAMPLES
|
|
|
126
142
|
$ create-link-app grant-access my-link-app friend
|
|
127
143
|
```
|
|
128
144
|
|
|
129
|
-
## `create-link-app help [
|
|
145
|
+
## `create-link-app help [COMMAND]`
|
|
130
146
|
|
|
131
147
|
Display help for create-link-app.
|
|
132
148
|
|
|
133
149
|
```
|
|
134
150
|
USAGE
|
|
135
|
-
$ create-link-app help [
|
|
151
|
+
$ create-link-app help [COMMAND] [-n]
|
|
136
152
|
|
|
137
153
|
ARGUMENTS
|
|
138
|
-
|
|
154
|
+
COMMAND Command to show help for.
|
|
139
155
|
|
|
140
156
|
FLAGS
|
|
141
157
|
-n, --nested-commands Include all nested commands in the output.
|
|
@@ -144,7 +160,7 @@ DESCRIPTION
|
|
|
144
160
|
Display help for create-link-app.
|
|
145
161
|
```
|
|
146
162
|
|
|
147
|
-
_See code: [@oclif/plugin-help](https://github.com/oclif/plugin-help/blob/v5.
|
|
163
|
+
_See code: [@oclif/plugin-help](https://github.com/oclif/plugin-help/blob/v5.1.23/src/commands/help.ts)_
|
|
148
164
|
|
|
149
165
|
## `create-link-app login`
|
|
150
166
|
|
|
@@ -172,7 +188,7 @@ DESCRIPTION
|
|
|
172
188
|
|
|
173
189
|
## `create-link-app storybook`
|
|
174
190
|
|
|
175
|
-
Start the
|
|
191
|
+
Start the Storybook development server
|
|
176
192
|
|
|
177
193
|
```
|
|
178
194
|
USAGE
|
|
@@ -182,6 +198,6 @@ FLAGS
|
|
|
182
198
|
-p, --port=<value> [default: 6006] Port to run the Storybook server on
|
|
183
199
|
|
|
184
200
|
DESCRIPTION
|
|
185
|
-
Start the
|
|
201
|
+
Start the Storybook development server
|
|
186
202
|
```
|
|
187
203
|
<!-- commandsstop -->
|
package/dist/commands/build.js
CHANGED
|
@@ -7,12 +7,22 @@ const core_1 = require("@oclif/core");
|
|
|
7
7
|
const webpack_1 = __importDefault(require("webpack"));
|
|
8
8
|
const base_1 = __importDefault(require("../base"));
|
|
9
9
|
const webpack_config_1 = __importDefault(require("../webpack/webpack.config"));
|
|
10
|
+
const child_process_1 = require("child_process");
|
|
10
11
|
class Build extends base_1.default {
|
|
11
12
|
async run() {
|
|
12
13
|
const { flags } = await this.parse(Build);
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
}
|
|
14
|
+
if (flags['native']) {
|
|
15
|
+
this.native();
|
|
16
|
+
}
|
|
17
|
+
else {
|
|
18
|
+
this.webpack({
|
|
19
|
+
allowAnyOrigin: flags['allow-any-origin'],
|
|
20
|
+
});
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
async webpack(options) {
|
|
24
|
+
const config = await (0, webpack_config_1.default)('production', options);
|
|
25
|
+
(0, webpack_1.default)(config, (err, stats) => {
|
|
16
26
|
if (err) {
|
|
17
27
|
this.error(err);
|
|
18
28
|
}
|
|
@@ -24,6 +34,9 @@ class Build extends base_1.default {
|
|
|
24
34
|
}
|
|
25
35
|
});
|
|
26
36
|
}
|
|
37
|
+
async native() {
|
|
38
|
+
(0, child_process_1.spawn)('npx react-native-builder-bob build', { cwd: process.cwd(), shell: true, stdio: 'inherit' });
|
|
39
|
+
}
|
|
27
40
|
}
|
|
28
41
|
exports.default = Build;
|
|
29
42
|
Build.description = 'Build Link App project to static assets used for production';
|
|
@@ -32,4 +45,7 @@ Build.flags = {
|
|
|
32
45
|
description: 'Allow Link App iframe to be loadable from non-Linktree origins for debugging',
|
|
33
46
|
hidden: true,
|
|
34
47
|
}),
|
|
48
|
+
native: core_1.Flags.boolean({
|
|
49
|
+
description: 'Build native components of a Link App ready for publishing to npm',
|
|
50
|
+
}),
|
|
35
51
|
};
|
package/dist/commands/dev.js
CHANGED
|
@@ -11,6 +11,7 @@ const webpack_config_1 = __importDefault(require("../webpack/webpack.config"));
|
|
|
11
11
|
class Dev extends base_1.default {
|
|
12
12
|
async run() {
|
|
13
13
|
const { flags } = await this.parse(Dev);
|
|
14
|
+
const config = await (0, webpack_config_1.default)('development');
|
|
14
15
|
const devServer = new webpack_dev_server_1.default({
|
|
15
16
|
client: {
|
|
16
17
|
overlay: false,
|
|
@@ -18,7 +19,7 @@ class Dev extends base_1.default {
|
|
|
18
19
|
hot: false,
|
|
19
20
|
https: flags.https,
|
|
20
21
|
port: flags.port,
|
|
21
|
-
}, (0, webpack_1.default)(
|
|
22
|
+
}, (0, webpack_1.default)(config));
|
|
22
23
|
await devServer.start();
|
|
23
24
|
}
|
|
24
25
|
}
|
|
@@ -0,0 +1,111 @@
|
|
|
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 path_1 = __importDefault(require("path"));
|
|
7
|
+
const base_1 = __importDefault(require("../base"));
|
|
8
|
+
const child_process_1 = require("child_process");
|
|
9
|
+
class MissingDependencyException extends Error {
|
|
10
|
+
constructor(packageName) {
|
|
11
|
+
super(`'${packageName}' is required on your system. Please refer to the create-link-app README`);
|
|
12
|
+
}
|
|
13
|
+
}
|
|
14
|
+
const ucfirst = (str) => {
|
|
15
|
+
return str.charAt(0).toUpperCase() + str.slice(1);
|
|
16
|
+
};
|
|
17
|
+
class GenerateTypes extends base_1.default {
|
|
18
|
+
constructor() {
|
|
19
|
+
super(...arguments);
|
|
20
|
+
this.schemaDirPath = path_1.default.join(process.cwd(), '/schema');
|
|
21
|
+
this.tmpPath = path_1.default.join(process.cwd(), '/__temp__');
|
|
22
|
+
this.typesPath = path_1.default.join(process.cwd(), '/src/types/schema');
|
|
23
|
+
}
|
|
24
|
+
async run() {
|
|
25
|
+
try {
|
|
26
|
+
// Check for necessary deps
|
|
27
|
+
await this.dependOn('npx');
|
|
28
|
+
await this.dependOn('jtd-codegen');
|
|
29
|
+
await this.log('✓ All dependencies present');
|
|
30
|
+
// Ensure necessary directories exist
|
|
31
|
+
await this.cmd(`mkdir -p ${this.tmpPath} && touch ${this.tmpPath}/index.ts`);
|
|
32
|
+
await this.cmd(`mkdir -p ${this.typesPath} && touch ${this.typesPath}/index.ts`);
|
|
33
|
+
await this.log('✓ Files prepped for generation');
|
|
34
|
+
// Wipe existing types & drop comments
|
|
35
|
+
await this.cmd(`> ${this.typesPath}/index.ts`);
|
|
36
|
+
await this.cmd(`echo "/**" >> ${this.typesPath}/index.ts`);
|
|
37
|
+
await this.cmd(`echo " * These types were autogenerated by @linktr.ee/create-link-app" >> ${this.typesPath}/index.ts`);
|
|
38
|
+
await this.cmd(`echo " * https://www.npmjs.com/package/@linktr.ee/create-link-app " >> ${this.typesPath}/index.ts`);
|
|
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
|
+
// Clean up file formatting
|
|
50
|
+
await this.cmd(`npx prettier ${this.typesPath}/index.ts --write`);
|
|
51
|
+
await this.log('✓ All types created successfully');
|
|
52
|
+
// Garbage collect temporary dir
|
|
53
|
+
await this.cmd(`rm -rf ${this.tmpPath}`);
|
|
54
|
+
await this.log('✓ Cleanup complete');
|
|
55
|
+
}
|
|
56
|
+
catch (e) {
|
|
57
|
+
await this.log(`𐄂 ERROR: ${e}`);
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
/**
|
|
61
|
+
* Generates a Typescript type for the schema defined in schema/<schemaName>.jtd.json
|
|
62
|
+
* and appends that type to src/types/schema/index.ts
|
|
63
|
+
*/
|
|
64
|
+
async generateAndAppendSchemaType(schemaName) {
|
|
65
|
+
// Generate schema
|
|
66
|
+
await this.cmd(`jtd-codegen ${this.schemaDirPath}/${schemaName}.jtd.json --typescript-out ${this.tmpPath} --root-name=${ucfirst(schemaName)}Data`);
|
|
67
|
+
// Strip jtd comment
|
|
68
|
+
await this.cmd(`sed '/^\\/\\//d' ${this.tmpPath}/index.ts > ${this.tmpPath}/parsed.ts`);
|
|
69
|
+
// Append to final file
|
|
70
|
+
await this.cmd(`cat ${this.tmpPath}/parsed.ts >> ${this.typesPath}/index.ts`);
|
|
71
|
+
}
|
|
72
|
+
async dependOn(dependencyName) {
|
|
73
|
+
try {
|
|
74
|
+
await this.cmd(`command -v ${dependencyName} || exit 1`);
|
|
75
|
+
}
|
|
76
|
+
catch (e) {
|
|
77
|
+
throw new MissingDependencyException('prettier');
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
/**
|
|
81
|
+
* Run a command with spawn effectively synchronously
|
|
82
|
+
*/
|
|
83
|
+
async cmd(command, opts = {
|
|
84
|
+
shell: true,
|
|
85
|
+
stdio: 'ignore',
|
|
86
|
+
}, onError) {
|
|
87
|
+
await new Promise((resolve, reject) => {
|
|
88
|
+
(0, child_process_1.spawn)(command, opts)
|
|
89
|
+
.on('error', (e) => {
|
|
90
|
+
reject(e);
|
|
91
|
+
})
|
|
92
|
+
.on('exit', (code) => {
|
|
93
|
+
if (code === 1)
|
|
94
|
+
reject({ exitCode: code });
|
|
95
|
+
})
|
|
96
|
+
.on('close', () => {
|
|
97
|
+
resolve();
|
|
98
|
+
});
|
|
99
|
+
}).catch((e) => {
|
|
100
|
+
if (onError) {
|
|
101
|
+
onError();
|
|
102
|
+
}
|
|
103
|
+
else {
|
|
104
|
+
throw e;
|
|
105
|
+
}
|
|
106
|
+
});
|
|
107
|
+
return;
|
|
108
|
+
}
|
|
109
|
+
}
|
|
110
|
+
exports.default = GenerateTypes;
|
|
111
|
+
GenerateTypes.description = 'Generate Typescript types from the schema definitions';
|
|
@@ -18,7 +18,7 @@ class Storybook extends base_1.default {
|
|
|
18
18
|
}
|
|
19
19
|
}
|
|
20
20
|
exports.default = Storybook;
|
|
21
|
-
Storybook.description = 'Start the
|
|
21
|
+
Storybook.description = 'Start the Storybook development server';
|
|
22
22
|
Storybook.flags = {
|
|
23
23
|
port: core_1.Flags.integer({
|
|
24
24
|
char: 'p',
|
|
@@ -14,8 +14,9 @@ const createProject = async (template, targetDir) => {
|
|
|
14
14
|
await fs_extra_1.default.copy(templateDir, targetDir);
|
|
15
15
|
await fs_extra_1.default.copy(templateCommonDir, targetDir);
|
|
16
16
|
await fs_extra_1.default.move(`${targetDir}/gitignore`, `${targetDir}/.gitignore`);
|
|
17
|
-
|
|
18
|
-
|
|
17
|
+
// remove types that are only required when building the `create-link-app` project
|
|
18
|
+
if (await fs_extra_1.default.existsSync(`${targetDir}/src/types/hack.d.ts`)) {
|
|
19
|
+
await fs_extra_1.default.unlink(`${targetDir}/src/types/hack.d.ts`);
|
|
19
20
|
}
|
|
20
21
|
// update `name` field in project manifest
|
|
21
22
|
const manifest = await fs_extra_1.default.readJson(`${targetDir}/manifest.json`);
|
|
@@ -12,11 +12,6 @@ const RequiredAssets = [
|
|
|
12
12
|
fileName: 'manifest.json',
|
|
13
13
|
contentType: 'application/json',
|
|
14
14
|
},
|
|
15
|
-
{
|
|
16
|
-
key: 'settings',
|
|
17
|
-
fileName: 'settings.json',
|
|
18
|
-
contentType: 'application/json',
|
|
19
|
-
},
|
|
20
15
|
{
|
|
21
16
|
key: 'package',
|
|
22
17
|
fileName: 'package.tgz',
|
|
@@ -29,11 +24,21 @@ const OptionalAssets = [
|
|
|
29
24
|
fileName: 'icon.svg',
|
|
30
25
|
contentType: 'image/svg+xml',
|
|
31
26
|
},
|
|
27
|
+
{
|
|
28
|
+
key: 'settings',
|
|
29
|
+
fileName: 'settings.json',
|
|
30
|
+
contentType: 'application/json',
|
|
31
|
+
},
|
|
32
32
|
{
|
|
33
33
|
key: 'url_match_rules',
|
|
34
34
|
fileName: 'url_match_rules.json',
|
|
35
35
|
contentType: 'application/json',
|
|
36
36
|
},
|
|
37
|
+
{
|
|
38
|
+
key: 'urlRules',
|
|
39
|
+
fileName: 'urlRules.json',
|
|
40
|
+
contentType: 'application/json',
|
|
41
|
+
},
|
|
37
42
|
];
|
|
38
43
|
/**
|
|
39
44
|
* Create a readable multipart/form-data stream which includes the Link App asset files.
|
|
@@ -8,7 +8,13 @@ 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`
|
|
11
16
|
* - `src/`
|
|
17
|
+
* - `schema.json`
|
|
12
18
|
* - `package.json`
|
|
13
19
|
* - `package-lock.json` - *optional*
|
|
14
20
|
* - `yarn.lock` - *optional*
|
|
@@ -30,10 +36,10 @@ async function packProject() {
|
|
|
30
36
|
gzipOptions: { level: 9 },
|
|
31
37
|
});
|
|
32
38
|
archive.on('warning', (err) => {
|
|
33
|
-
if (err
|
|
34
|
-
// lock files and tsconfig may or may not exist
|
|
39
|
+
if (err?.code === 'ENOENT') {
|
|
40
|
+
// package, lock files and tsconfig may or may not exist
|
|
35
41
|
const fileName = path_1.default.basename(err.path);
|
|
36
|
-
if (fileName === 'package-lock.json' || fileName === 'yarn.lock' || fileName === 'tsconfig.json') {
|
|
42
|
+
if (fileName === 'package.json' || fileName === 'package-lock.json' || fileName === 'yarn.lock' || fileName === 'tsconfig.json') {
|
|
37
43
|
return;
|
|
38
44
|
}
|
|
39
45
|
}
|
|
@@ -43,6 +49,11 @@ async function packProject() {
|
|
|
43
49
|
handleFailure(err);
|
|
44
50
|
});
|
|
45
51
|
archive.pipe(outputWriteStream);
|
|
52
|
+
archive.file(resolveProjPath('schema/editablePublic.jtd.json'), { name: 'schema/editablePublic.jtd.json' });
|
|
53
|
+
archive.file(resolveProjPath('schema/readonlyPublic.jtd.json'), { name: 'schema/readonlyPublic.jtd.json' });
|
|
54
|
+
archive.file(resolveProjPath('schema/editablePrivate.jtd.json'), { name: 'schema/editablePrivate.jtd.json' });
|
|
55
|
+
archive.file(resolveProjPath('schema/readonlyPrivate.jtd.json'), { name: 'schema/readonlyPrivate.jtd.json' });
|
|
56
|
+
archive.file(resolveProjPath('schema/system.jtd.json'), { name: 'schema/system.jtd.json' });
|
|
46
57
|
archive.file(resolveProjPath('package.json'), { name: 'package.json' });
|
|
47
58
|
archive.file(resolveProjPath('package-lock.json'), { name: 'package-lock.json' });
|
|
48
59
|
archive.file(resolveProjPath('yarn.lock'), { name: 'yarn.lock' });
|
|
@@ -0,0 +1,30 @@
|
|
|
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 fs_extra_1 = __importDefault(require("fs-extra"));
|
|
7
|
+
const path_1 = __importDefault(require("path"));
|
|
8
|
+
const jtd_js_1 = __importDefault(require("ajv/dist/jtd.js"));
|
|
9
|
+
const index_js_1 = __importDefault(require("ajv/dist/standalone/index.js"));
|
|
10
|
+
const schemaNames = ['editablePublic', 'readonlyPublic', 'editablePrivate', 'readonlyPrivate', 'system'];
|
|
11
|
+
async function compileSchema() {
|
|
12
|
+
try {
|
|
13
|
+
const ajv = new jtd_js_1.default({
|
|
14
|
+
// @ts-expect-error: In JTD mode some options are not typed correctly.
|
|
15
|
+
strict: false,
|
|
16
|
+
code: { source: true, esm: true },
|
|
17
|
+
});
|
|
18
|
+
await Promise.all(schemaNames.map(async (schemaName) => {
|
|
19
|
+
const schemaPath = path_1.default.join(process.cwd(), `./schema/${schemaName}.jtd.json`);
|
|
20
|
+
const schema = await fs_extra_1.default.readJSON(schemaPath);
|
|
21
|
+
ajv.addSchema(schema, schemaName);
|
|
22
|
+
}));
|
|
23
|
+
const moduleCode = (0, index_js_1.default)(ajv);
|
|
24
|
+
return moduleCode;
|
|
25
|
+
}
|
|
26
|
+
catch (e) {
|
|
27
|
+
console.error(e);
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
exports.default = compileSchema;
|
|
@@ -3,18 +3,29 @@ 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
|
+
exports.getPostcssConfig = void 0;
|
|
6
7
|
const path_1 = __importDefault(require("path"));
|
|
7
8
|
const tailwindcss_1 = __importDefault(require("tailwindcss"));
|
|
8
9
|
const autoprefixer_1 = __importDefault(require("autoprefixer"));
|
|
9
10
|
const componentLibraryContentPath = path_1.default.join(require.resolve('@linktr.ee/component-library/tailwind.config').split('/').slice(0, -1).join('/'), 'dist', '**', '*.js');
|
|
10
|
-
const
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
11
|
+
const uiLinkKitPath = path_1.default.join(require.resolve('@linktr.ee/ui-link-kit').split('/').slice(0, -2).join('/'), '**', '*.js');
|
|
12
|
+
function getPostcssConfig({ linkTypeSlug, env = 'production' }) {
|
|
13
|
+
const isStorybook = env === 'storybook';
|
|
14
|
+
const content = [`${process.cwd()}/src/**/*.{js,jsx,ts,tsx}`, uiLinkKitPath];
|
|
15
|
+
if (isStorybook) {
|
|
16
|
+
content.push(componentLibraryContentPath);
|
|
17
|
+
}
|
|
18
|
+
return {
|
|
19
|
+
...(isStorybook && { inject: { insertAtTop: true } }),
|
|
20
|
+
plugins: [
|
|
21
|
+
(0, tailwindcss_1.default)({
|
|
22
|
+
important: `[data-link-type-id=${linkTypeSlug}]`,
|
|
23
|
+
content,
|
|
24
|
+
presets: [require('@linktr.ee/component-library/tailwind.config')],
|
|
25
|
+
plugins: [],
|
|
26
|
+
}),
|
|
27
|
+
(0, autoprefixer_1.default)(),
|
|
28
|
+
],
|
|
29
|
+
};
|
|
30
|
+
}
|
|
31
|
+
exports.getPostcssConfig = getPostcssConfig;
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
:root {
|
|
2
|
+
--lt-color-primary: #849589;
|
|
3
|
+
--lt-color-on-primary: #ffffff;
|
|
4
|
+
--lt-color-on-primary-alpha: #ffffffb2;
|
|
5
|
+
|
|
6
|
+
--lt-color-secondary: #67776b;
|
|
7
|
+
--lt-color-on-secondary: #ffffffb3;
|
|
8
|
+
|
|
9
|
+
--lt-color-background: #3a463c;
|
|
10
|
+
--lt-color-on-background: #f7fdf9;
|
|
11
|
+
|
|
12
|
+
--lt-color0: #ffffff;
|
|
13
|
+
--lt-color1: #f7fdf9;
|
|
14
|
+
--lt-color2: #eef6ed;
|
|
15
|
+
--lt-color3: #e0ece2;
|
|
16
|
+
--lt-color4: #c9d5cb;
|
|
17
|
+
--lt-color5: #b6c5b7;
|
|
18
|
+
--lt-color6: #849589;
|
|
19
|
+
--lt-color7: #67776b;
|
|
20
|
+
--lt-color8: #4d5e52;
|
|
21
|
+
--lt-color9: #3a463c;
|
|
22
|
+
--lt-color10: #29382d;
|
|
23
|
+
--lt-color11: #151e16;
|
|
24
|
+
--lt-color12: #0b140c;
|
|
25
|
+
--lt-color13: #000501;
|
|
26
|
+
--lt-color14: #000000;
|
|
27
|
+
--lt-color15: #000000;
|
|
28
|
+
|
|
29
|
+
--lt-treetop-radius-mobile: 2.5rem;
|
|
30
|
+
|
|
31
|
+
--lt-cover-radius: 6rem;
|
|
32
|
+
--lt-cover-radius-mobile: 4rem;
|
|
33
|
+
|
|
34
|
+
--lt-feature-container-radius: 2rem;
|
|
35
|
+
--lt-feature-thumbnail-radius: 1.5rem;
|
|
36
|
+
|
|
37
|
+
--lt-carousel-container-radius: 1.5rem;
|
|
38
|
+
--lt-carousel-thumbnail-radius: 1rem;
|
|
39
|
+
|
|
40
|
+
--lt-grid-container-radius: 1.25rem;
|
|
41
|
+
--lt-grid-thumbnail-radius: 0.75rem;
|
|
42
|
+
|
|
43
|
+
--lt-stack-container-radius: 1rem;
|
|
44
|
+
--lt-stack-thumbnail-radius: 0.65rem;
|
|
45
|
+
|
|
46
|
+
--lt-font-family: INTER;
|
|
47
|
+
--lt-text-2xl: 1.5rem;
|
|
48
|
+
--lt-text-xl: 1.25rem;
|
|
49
|
+
--lt-text-lg: 1.125rem;
|
|
50
|
+
--lt-text-md: 1rem;
|
|
51
|
+
--lt-text-sm: 0.875rem;
|
|
52
|
+
--lt-text-xs: 0.75rem;
|
|
53
|
+
}
|
package/dist/storybook/main.js
CHANGED
|
@@ -1,33 +1,14 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
-
if (k2 === undefined) k2 = k;
|
|
4
|
-
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
-
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
-
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
-
}
|
|
8
|
-
Object.defineProperty(o, k2, desc);
|
|
9
|
-
}) : (function(o, m, k, k2) {
|
|
10
|
-
if (k2 === undefined) k2 = k;
|
|
11
|
-
o[k2] = m[k];
|
|
12
|
-
}));
|
|
13
|
-
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
-
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
-
}) : function(o, v) {
|
|
16
|
-
o["default"] = v;
|
|
17
|
-
});
|
|
18
|
-
var __importStar = (this && this.__importStar) || function (mod) {
|
|
19
|
-
if (mod && mod.__esModule) return mod;
|
|
20
|
-
var result = {};
|
|
21
|
-
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
22
|
-
__setModuleDefault(result, mod);
|
|
23
|
-
return result;
|
|
24
|
-
};
|
|
25
2
|
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
26
3
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
27
4
|
};
|
|
28
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
29
6
|
const postcss_1 = __importDefault(require("postcss"));
|
|
30
|
-
const
|
|
7
|
+
const webpack_1 = __importDefault(require("webpack"));
|
|
8
|
+
const postcss_config_1 = require("../postcss/postcss.config");
|
|
9
|
+
// Do not need to be the real values, just need to be defined for storybook
|
|
10
|
+
const linkTypeSlug = 'test-id';
|
|
11
|
+
const linkTypeId = 'testId';
|
|
31
12
|
const config = {
|
|
32
13
|
stories: [`${process.cwd()}/src/**/*.stories.@(js|jsx|ts|tsx)`],
|
|
33
14
|
addons: [
|
|
@@ -49,7 +30,7 @@ const config = {
|
|
|
49
30
|
cssLoaderOptions: { importLoaders: 1 },
|
|
50
31
|
postcssLoaderOptions: {
|
|
51
32
|
implementation: postcss_1.default,
|
|
52
|
-
postcssOptions: {
|
|
33
|
+
postcssOptions: (0, postcss_config_1.getPostcssConfig)({ linkTypeSlug, env: 'storybook' }),
|
|
53
34
|
},
|
|
54
35
|
},
|
|
55
36
|
},
|
|
@@ -58,5 +39,24 @@ const config = {
|
|
|
58
39
|
core: {
|
|
59
40
|
builder: 'webpack5',
|
|
60
41
|
},
|
|
42
|
+
webpackFinal: async (config) => {
|
|
43
|
+
if (config.plugins?.length) {
|
|
44
|
+
// Add the DefinePlugin to the Webpack plugins array
|
|
45
|
+
config.plugins.push(new webpack_1.default.DefinePlugin({
|
|
46
|
+
__LINK_TYPE_ID__: JSON.stringify(linkTypeId),
|
|
47
|
+
__LINK_TYPE_SLUG__: JSON.stringify(linkTypeSlug),
|
|
48
|
+
}));
|
|
49
|
+
}
|
|
50
|
+
config.module?.rules?.push({
|
|
51
|
+
test: /\.(ts|tsx)$/,
|
|
52
|
+
use: [
|
|
53
|
+
{
|
|
54
|
+
loader: require.resolve('ts-loader'),
|
|
55
|
+
},
|
|
56
|
+
],
|
|
57
|
+
});
|
|
58
|
+
config.resolve?.extensions?.push('.ts', '.tsx');
|
|
59
|
+
return config;
|
|
60
|
+
},
|
|
61
61
|
};
|
|
62
62
|
module.exports = config;
|
|
@@ -1,6 +1,11 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
2
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.parameters = void 0;
|
|
6
|
+
exports.decorators = exports.parameters = void 0;
|
|
7
|
+
const react_1 = __importDefault(require("react"));
|
|
8
|
+
require("./global.css");
|
|
4
9
|
exports.parameters = {
|
|
5
10
|
actions: { argTypesRegex: '^on[A-Z].*' },
|
|
6
11
|
controls: {
|
|
@@ -10,3 +15,7 @@ exports.parameters = {
|
|
|
10
15
|
},
|
|
11
16
|
},
|
|
12
17
|
};
|
|
18
|
+
const WrapperDecorator = (storyFn) => (react_1.default.createElement("div", { style: {
|
|
19
|
+
display: 'contents',
|
|
20
|
+
}, "data-link-type-id": __LINK_TYPE_SLUG__ }, storyFn()));
|
|
21
|
+
exports.decorators = [WrapperDecorator];
|