@preply/ds-docs 0.4.3-beta.34

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 (54) hide show
  1. package/CHANGELOG.md +46 -0
  2. package/README.md +92 -0
  3. package/config/main.js +23 -0
  4. package/config/manager-head.html +1 -0
  5. package/config/manager.js +16 -0
  6. package/config/packages.js +21 -0
  7. package/config/preview-head.html +1 -0
  8. package/config/preview.js +16 -0
  9. package/config/webpack.config.js +97 -0
  10. package/dist/0.338f6ec8c298c14e9987.manager.bundle.js +1 -0
  11. package/dist/0.3fa9c511.iframe.bundle.js +1 -0
  12. package/dist/10.cbab8b16.iframe.bundle.js +1 -0
  13. package/dist/11.eb6590ee.iframe.bundle.js +1 -0
  14. package/dist/12.14fcbdc9.iframe.bundle.js +1 -0
  15. package/dist/4.ca91571aa289a44fd646.manager.bundle.js +2 -0
  16. package/dist/4.ca91571aa289a44fd646.manager.bundle.js.LICENSE.txt +8 -0
  17. package/dist/5.09384b194ae4afd5b83d.manager.bundle.js +1 -0
  18. package/dist/6.32fc62c8a6ce2df04956.manager.bundle.js +2 -0
  19. package/dist/6.32fc62c8a6ce2df04956.manager.bundle.js.LICENSE.txt +12 -0
  20. package/dist/7.caafbbb780553290f515.manager.bundle.js +1 -0
  21. package/dist/8.66293b7ba6e3ca90f9ef.manager.bundle.js +1 -0
  22. package/dist/9.50d8be07.iframe.bundle.js +1 -0
  23. package/dist/docs-pages/docs/pages/00.welcome/static/andre.jpg +0 -0
  24. package/dist/docs-pages/docs/pages/00.welcome/static/designers.svg +5 -0
  25. package/dist/docs-pages/docs/pages/00.welcome/static/developers.svg +5 -0
  26. package/dist/docs-pages/docs/pages/00.welcome/static/header.png +0 -0
  27. package/dist/docs-pages/docs/pages/00.welcome/static/vadim.jpg +0 -0
  28. package/dist/docs-pages/docs/pages/04.contributing/static/flowchart.png +0 -0
  29. package/dist/favicon.ico +0 -0
  30. package/dist/global/docs/static/favicon.svg +4 -0
  31. package/dist/global/docs/static/logo.svg +1 -0
  32. package/dist/iframe.html +138 -0
  33. package/dist/index.html +55 -0
  34. package/dist/main.515f4f3f1dbf7ce958bc.manager.bundle.js +1 -0
  35. package/dist/main~493df0b3.15207f51.iframe.bundle.js +1 -0
  36. package/dist/runtime~main.b422f1cd6ad7b4837a59.manager.bundle.js +1 -0
  37. package/dist/runtime~main.b9288cbc.iframe.bundle.js +1 -0
  38. package/dist/vendors~main.a298dbf4b4228db7a7c0.manager.bundle.js +2 -0
  39. package/dist/vendors~main.a298dbf4b4228db7a7c0.manager.bundle.js.LICENSE.txt +82 -0
  40. package/dist/vendors~main~253ae210.4ae5c9e8.iframe.bundle.js +1 -0
  41. package/dist/vendors~main~4134d62c.1d98f7f4.iframe.bundle.js +1 -0
  42. package/dist/vendors~main~678f84af.7ab7d52f.iframe.bundle.js +1 -0
  43. package/dist/vendors~main~a353122d.312fbc2d.iframe.bundle.js +1 -0
  44. package/dist/vendors~main~bdc480fb.2ad5d7bf.iframe.bundle.js +1 -0
  45. package/dist/vendors~main~d88e64ba.a117b568.iframe.bundle.js +1 -0
  46. package/dist/web-lib/src/components/Avatar/docs/static/avatar.png +0 -0
  47. package/docs/static/favicon.svg +4 -0
  48. package/docs/static/logo.svg +1 -0
  49. package/package.json +47 -0
  50. package/scripts/copy-metadata-and-assets.js +87 -0
  51. package/scripts/copy-statics.js +10 -0
  52. package/tsconfig.json +3 -0
  53. package/utils/globs.js +16 -0
  54. package/utils/statics.js +30 -0
@@ -0,0 +1,4 @@
1
+ <svg width="32" height="32" viewBox="0 0 32 32" fill="none" xmlns="http://www.w3.org/2000/svg">
2
+ <path fill-rule="evenodd" clip-rule="evenodd" d="M22.5389 5.65395C20.0561 6.3323 17.9432 6.90958 17.6377 7.94674C17.7582 8.354 18.1563 8.69 18.746 8.98907C19.7143 8.60782 20.8618 8.29418 22.0808 7.9613C23.9094 7.46198 25.9144 6.91429 27.6268 6.03632C27.9254 5.88445 28.2949 5.99523 28.452 6.28442C28.6091 6.57361 28.4945 6.93198 28.196 7.08385C26.373 8.01908 24.3079 8.58352 22.4235 9.09857L22.4112 9.10193L22.4035 9.10403C21.7268 9.28896 21.0763 9.46672 20.4761 9.65119C21.0907 9.8425 21.7715 10.0289 22.4833 10.2238L22.5424 10.24C22.9911 10.3622 23.4494 10.4875 23.9126 10.6197C25.1882 10.2415 26.4734 9.80046 27.6268 9.2096C27.9254 9.0572 28.2949 9.16851 28.452 9.4577C28.6091 9.74689 28.4945 10.1047 28.196 10.2571C27.4568 10.6363 26.6773 10.9546 25.8859 11.2329C27.5719 11.8144 29.2197 12.566 30.5781 13.691C30.6712 13.768 30.761 13.846 30.8492 13.9256C30.8783 13.7206 30.8928 13.51 30.8928 13.2936L30.888 2.10263C30.8406 2.08702 30.7927 2.08286 30.7492 2.09015C30.7169 2.09587 30.69 2.10679 30.6717 2.12239C28.4015 4.05309 25.2861 4.90402 22.5424 5.65299L22.5389 5.65395ZM17.5995 10.8225V23.862C17.5995 25.0697 19.8547 25.6861 22.5424 26.42C25.2861 27.169 28.4015 28.0199 30.6717 29.9506C30.69 29.9662 30.7169 29.9771 30.7492 29.9828C30.7927 29.9901 30.8406 29.9865 30.8928 29.9683V18.7794C30.8928 18.1032 30.7508 17.4816 30.47 16.9173C30.1805 16.3363 29.7394 15.7996 29.1487 15.3101C27.2567 13.742 24.4361 12.9717 21.948 12.2924C20.2948 11.8409 18.7648 11.4227 17.5995 10.8225Z" fill="#006EF0"/>
3
+ <path fill-rule="evenodd" clip-rule="evenodd" d="M15.3955 21.2509V8.2109C15.3955 7.00345 13.1414 6.38763 10.4539 5.65343L10.4521 5.65293C7.70897 4.90395 4.59358 4.05303 2.32334 2.12233C2.30505 2.10672 2.27815 2.0958 2.24587 2.09008C2.20176 2.0828 2.15442 2.08696 2.10223 2.10464V13.2935C2.10223 13.9697 2.24426 14.5913 2.52562 15.1566C2.81451 15.7366 3.25564 16.2739 3.8458 16.7633C5.73684 18.3302 8.55437 19.1 11.041 19.7794L11.0471 19.7811C12.7008 20.2325 14.2303 20.6502 15.3955 21.2509ZM15.3573 24.1262C15.2373 23.7194 14.8392 23.3834 14.2496 23.0844C13.2807 23.4651 12.1332 23.7787 10.9142 24.1116C9.08564 24.6109 7.08062 25.1591 5.36826 26.0366C5.06968 26.1885 4.70063 26.0777 4.54301 25.7885C4.38592 25.4993 4.50051 25.1409 4.79908 24.9891C6.62509 24.0523 8.69402 23.4875 10.5815 22.9723L10.5844 22.9715L10.6407 22.9561C11.2999 22.7754 11.9336 22.6018 12.519 22.4222C11.9001 22.2287 11.2153 22.0417 10.4988 21.8461L10.4526 21.8335L10.3414 21.8031C9.92833 21.6901 9.50736 21.5749 9.08187 21.4533C7.80688 21.8314 6.52113 22.2724 5.36826 22.8633C5.06968 23.0162 4.70063 22.9044 4.54301 22.6157C4.38592 22.3265 4.50051 21.9682 4.79908 21.8158C5.53825 21.4366 6.31831 21.1183 7.10913 20.84C5.42367 20.259 3.77532 19.5075 2.41641 18.3819C2.32388 18.3049 2.2335 18.2269 2.14581 18.1473C2.11676 18.3528 2.10223 18.5634 2.10223 18.7793L2.10761 29.9703C2.15442 29.9864 2.20176 29.99 2.24587 29.9828C2.27815 29.977 2.30505 29.9661 2.32334 29.9505C4.59358 28.0198 7.70897 27.1689 10.4521 26.4199C12.937 25.7417 15.0517 25.1638 15.3573 24.1262Z" fill="#006EF0"/>
4
+ </svg>
@@ -0,0 +1 @@
1
+ <svg width="99" height="28" viewBox="0 0 99 28" xmlns="http://www.w3.org/2000/svg"><title>Preply + Imported Layers</title><desc>Created with Sketch.</desc><g fill="none"><path d="M40.05 15.489v5.511h-3.223v-15.641h6.102c1.174 0 2.208.215 3.099.645.892.43 1.577 1.04 2.057 1.832.48.791.72 1.692.72 2.702 0 1.533-.525 2.741-1.574 3.625-1.049.884-2.501 1.327-4.356 1.327h-2.825zm0-2.61h2.879c.852 0 1.502-.201 1.95-.602.448-.401.671-.974.671-1.719 0-.766-.226-1.386-.677-1.858-.451-.473-1.074-.716-1.869-.73h-2.954v4.909zm17.295-.591c-.423-.057-.795-.086-1.117-.086-1.174 0-1.944.397-2.31 1.192v7.605h-3.104v-11.623h2.933l.086 1.386c.623-1.067 1.486-1.601 2.589-1.601.344 0 .666.047.967.14l-.043 2.986zm6.843 8.927c-1.704 0-3.092-.523-4.163-1.568-1.071-1.046-1.606-2.438-1.606-4.179v-.301c0-1.167.226-2.211.677-3.131.451-.92 1.09-1.629 1.917-2.127.827-.498 1.771-.747 2.831-.747 1.59 0 2.841.501 3.754 1.504.913 1.003 1.37 2.424 1.37 4.265v1.268h-7.401c.1.759.403 1.368.908 1.826.505.458 1.144.688 1.917.688 1.196 0 2.131-.433 2.804-1.3l1.525 1.708c-.465.659-1.096 1.173-1.891 1.542-.795.369-1.676.553-2.643.553zm-.354-9.539c-.616 0-1.115.208-1.499.623-.383.415-.628 1.01-.736 1.783h4.318v-.247c-.014-.688-.201-1.219-.559-1.595-.358-.376-.867-.564-1.525-.564zm17.359 3.62c0 1.79-.406 3.224-1.219 4.302-.813 1.078-1.91 1.617-3.292 1.617-1.174 0-2.123-.408-2.847-1.225v5.479h-3.104v-16.092h2.879l.107 1.139c.752-.902 1.733-1.354 2.943-1.354 1.432 0 2.546.53 3.341 1.59.795 1.06 1.192 2.521 1.192 4.383v.161zm-3.104-.226c0-1.081-.192-1.916-.575-2.503-.383-.587-.94-.881-1.67-.881-.974 0-1.644.372-2.009 1.117v4.759c.38.766 1.056 1.149 2.03 1.149 1.482 0 2.224-1.214 2.224-3.642zm8.304 5.93h-3.115v-16.5h3.115v16.5zm6.896-4.394l2.148-7.229h3.33l-4.673 13.428-.258.612c-.695 1.518-1.84 2.277-3.438 2.277-.451 0-.91-.068-1.375-.204v-2.353l.473.011c.587 0 1.026-.09 1.316-.269.29-.179.517-.476.682-.892l.365-.956-4.071-11.655h3.341l2.159 7.229z" fill="#000"/><g><path d="M12.598 6.54c0-1.161-2.096-1.753-4.594-2.459-2.55-.72-5.445-1.538-7.555-3.394l-.072-.031-.129.012-.005.002v10.756c0 .65.132 1.247.393 1.791.269.558.678 1.074 1.227 1.545 1.759 1.508 4.38 2.248 6.693 2.901 1.537.434 2.959.836 4.042 1.413v-12.535" fill="#3BB3BD"/><path d="M14.682 6.286c.112.391.482.714 1.03 1.002.9-.367 1.967-.668 3.099-.988 1.7-.48 3.563-1.007 5.155-1.851.277-.146.621-.039.767.239.146.278.04.622-.238.768-1.698.901-3.622 1.444-5.377 1.94-.631.178-1.239.35-1.798.528.587.189 1.239.373 1.92.566l1.274.365c1.185-.363 2.38-.787 3.452-1.355.277-.147.621-.04.767.238.146.278.04.622-.238.769-.687.364-1.412.67-2.147.938 1.567.559 3.099 1.281 4.361 2.363l.252.225c.027-.197.04-.399.04-.607v-10.756l-.004-.002-.129-.012-.072.031c-2.11 1.856-5.006 2.674-7.555 3.394-2.309.652-4.275 1.208-4.559 2.205" fill="#F9463D"/><path d="M14.646 21.586c0 1.161 2.096 1.753 4.594 2.459 2.55.72 5.445 1.538 7.555 3.394l.072.031.129-.012.004-.002v-10.756c0-.65-.132-1.247-.393-1.79-.269-.558-.679-1.074-1.228-1.545-1.759-1.507-4.38-2.248-6.692-2.901-1.537-.434-2.959-.836-4.042-1.413v12.535" fill="#F9463D"/><path d="M11.533 20.838c-.9.366-1.967.668-3.1.988-1.7.48-3.563 1.007-5.155 1.85-.277.146-.621.04-.767-.238-.146-.278-.039-.623.238-.769 1.698-.901 3.622-1.444 5.377-1.939.631-.179 1.239-.35 1.798-.528-.587-.19-1.239-.374-1.92-.566l-1.274-.365c-1.185.363-2.38.787-3.452 1.356-.277.147-.621.039-.767-.238-.146-.278-.039-.622.238-.769.687-.364 1.412-.67 2.147-.938-1.567-.558-3.099-1.281-4.361-2.363l-.252-.225c-.027.197-.04.4-.04.607v10.756l.005.002.129.012.072-.031c2.11-1.856 5.006-2.674 7.555-3.394 2.309-.652 4.275-1.207 4.559-2.205-.111-.391-.481-.714-1.03-1.002" fill="#3BB3BD"/></g></g></svg>
package/package.json ADDED
@@ -0,0 +1,47 @@
1
+ {
2
+ "name": "@preply/ds-docs",
3
+ "version": "0.4.3-beta.34+62b440f",
4
+ "publishConfig": {
5
+ "access": "public"
6
+ },
7
+ "scripts": {
8
+ "clean": "rm -rf dist && rm -rf static",
9
+ "lint": "run --top-level eslint --ext .js,.ts,.tsx,.mdx config/ scripts/",
10
+ "docs": "run clean && run docs:storybook",
11
+ "docs:storybook": "start-storybook -c config -s ./static -p 6006",
12
+ "docs:skip-cache": "start-storybook -c config --no-manager-cache -s ./static -p 6006",
13
+ "build": "node ./scripts/copy-statics.js && run build:storybook",
14
+ "build:meta": "node scripts/copy-metadata-and-assets.js",
15
+ "build:storybook": "build-storybook -c config -s ./static -o dist/"
16
+ },
17
+ "devDependencies": {
18
+ "@babel/core": "7.16.0",
19
+ "@storybook/addon-actions": "6.3.12",
20
+ "@storybook/addon-docs": "6.3.12",
21
+ "@storybook/addon-essentials": "6.3.12",
22
+ "@storybook/addon-links": "6.3.12",
23
+ "@storybook/components": "6.3.12",
24
+ "@storybook/node-logger": "6.3.12",
25
+ "@storybook/react": "6.3.12",
26
+ "@svgr/webpack": "5.5.0",
27
+ "babel-eslint": "10.1.0",
28
+ "babel-loader": "8.2.2",
29
+ "cpx": "^1.5.0",
30
+ "css-loader": "5.2.6",
31
+ "eslint": "7.27.0",
32
+ "less": "4.1.2",
33
+ "less-loader": "7.3.0",
34
+ "postcss": "8.3.11",
35
+ "postcss-loader": "4.2.0",
36
+ "postcss-preset-env": "6.7.0",
37
+ "react": "16.13.1",
38
+ "react-dom": "16.13.1",
39
+ "source-map-loader": "1.1.3",
40
+ "style-loader": "2.0.0",
41
+ "styled-components": "4.4.1",
42
+ "typescript": "4.4.4",
43
+ "webpack": "4.46.0",
44
+ "webpack-merge": "5.8.0"
45
+ },
46
+ "gitHead": "62b440fd62192714d5273a0a19ab36df02116f77"
47
+ }
@@ -0,0 +1,87 @@
1
+ const { existsSync } = require('fs');
2
+ const { copyFile, readFile, mkdir } = require('fs').promises;
3
+ const { dirname, join, resolve } = require('path');
4
+
5
+ const TOOLS_DATA_PATH = './fe-tools/data/'; // **WIP**
6
+ const SB_DATA_PATH = './static/data/';
7
+ const SB_ASSETS_PATH = './static/assets/';
8
+
9
+ const METADATA_FILES = ['projects', 'components', 'assets'];
10
+
11
+ const metadataSource = name => join(TOOLS_DATA_PATH, `${name}.json`);
12
+ const metadataTarget = name => join(SB_DATA_PATH, `${name}.json`);
13
+
14
+ // ./src/foo/bar/name.svg
15
+ const assetExposedFile = asset => join(asset.path, asset.exposes[0].source);
16
+
17
+ // ./client/preply-space/src/foo/bar/name.svg
18
+ const assetSource = (projects, asset) => {
19
+ const type = asset.library ? 'library' : 'app';
20
+ const name = asset.library ? asset.library : asset.app;
21
+ const project = projects.find(p => p.type === type && p.name === name);
22
+ if (!project) {
23
+ throw new Error(`<unknown project ${type}:${name}>`);
24
+ }
25
+ return resolve(project.path, assetExposedFile(asset));
26
+ };
27
+
28
+ // ./preply-space
29
+ const assetTargetPath = asset => asset.app || asset.library;
30
+ // ./.storybook/assets/preply-space/foo/bar/name.svg
31
+ const assetTarget = asset => join(SB_ASSETS_PATH, assetTargetPath(asset), assetExposedFile(asset));
32
+
33
+ const readJson = async filename => {
34
+ try {
35
+ const contents = await readFile(filename, { encoding: 'utf-8' });
36
+ return JSON.parse(contents);
37
+ } catch (err) {
38
+ throw new Error(`Failed to load ${filename} : ${err.message}`);
39
+ }
40
+ };
41
+
42
+ const copyAsset = async (projects, asset) => {
43
+ const source = assetSource(projects, asset);
44
+ const target = assetTarget(asset);
45
+ if (!existsSync(dirname(target))) {
46
+ await mkdir(dirname(target), { recursive: true });
47
+ }
48
+ try {
49
+ await copyFile(source, target);
50
+ console.info(`asset: ${asset.name} => ${target}`);
51
+ } catch (err) {
52
+ if (err.code === 'ENOENT') {
53
+ console.warn(`WARNING: asset "${asset.name}" not found (${source})`);
54
+ } else {
55
+ throw err;
56
+ }
57
+ }
58
+ };
59
+
60
+ const copyMetadata = async name => {
61
+ const source = metadataSource(name);
62
+ const target = metadataTarget(name);
63
+ try {
64
+ await copyFile(source, target);
65
+ console.info(`metadata: ${name} => ${target}`);
66
+ } catch (err) {
67
+ if (err.code === 'ENOENT') {
68
+ console.warn(
69
+ `WARNING: no ${name} metadata found (${source}). Run yarn:${name} in fe-tools/`,
70
+ );
71
+ } else {
72
+ throw err;
73
+ }
74
+ }
75
+ };
76
+
77
+ const main = async () => {
78
+ const metadataCopies = METADATA_FILES.map(name => copyMetadata(name));
79
+ await Promise.all(metadataCopies);
80
+
81
+ const assets = await readJson(metadataTarget('assets'));
82
+ const projects = await readJson(metadataTarget('projects'));
83
+ const assetCopies = assets.map(asset => copyAsset(projects, asset));
84
+ await Promise.all(assetCopies);
85
+ };
86
+
87
+ main().catch(err => console.error(err));
@@ -0,0 +1,10 @@
1
+ const { mkdirSync } = require('fs');
2
+
3
+ const { packages } = require('../config/packages');
4
+ const { preparePackageStatics, staticsCopy } = require('../utils/statics');
5
+
6
+ console.info('copy statics');
7
+
8
+ mkdirSync('./static', { recursive: true });
9
+
10
+ packages.forEach(pkg => preparePackageStatics(pkg, staticsCopy));
package/tsconfig.json ADDED
@@ -0,0 +1,3 @@
1
+ {
2
+ "extends": "../../tsconfig.json"
3
+ }
package/utils/globs.js ADDED
@@ -0,0 +1,16 @@
1
+ const { join } = require('path');
2
+
3
+ const getPackagePathGlobs = (pkg, srcsPath) => {
4
+ return [
5
+ join(pkg.root, srcsPath, '**/*.stories.mdx'),
6
+ join(pkg.root, srcsPath, '**/*.stories.tsx'),
7
+ ];
8
+ };
9
+
10
+ const getPackageGlobs = pkg => {
11
+ return pkg.paths.map(path => getPackagePathGlobs(pkg, path)).flat();
12
+ };
13
+
14
+ module.exports = {
15
+ getPackageGlobs,
16
+ };
@@ -0,0 +1,30 @@
1
+ const cpx = require('cpx');
2
+ const { join } = require('path');
3
+
4
+ const staticsCopy = (from, to) => {
5
+ console.info('copy:', { from, to });
6
+ cpx.copySync(from, to);
7
+ };
8
+
9
+ const staticsWatcher = (from, to) => {
10
+ console.info('watch:', { from, to });
11
+ cpx.copySync(from, to);
12
+ // eslint-disable-next-line security/detect-non-literal-fs-filename
13
+ const watcher = cpx.watch(from, to, { initialCopy: false });
14
+ watcher.on('copy', event => console.info('watch: copy', event));
15
+ watcher.on('remove', event => console.info('watch: remove', event));
16
+ };
17
+
18
+ const preparePackageStatics = (pkg, staticsFn) => {
19
+ pkg.paths.forEach(path => {
20
+ const from = join(pkg.root, path, '**/static/**/*');
21
+ const to = join('./static/', pkg.name, path);
22
+ staticsFn(from, to);
23
+ });
24
+ };
25
+
26
+ module.exports = {
27
+ preparePackageStatics,
28
+ staticsCopy,
29
+ staticsWatcher,
30
+ };