@preply/ds-docs 0.17.0 → 0.19.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 +3 -1
- package/config/main.js +2 -2
- package/{utils → config/utils}/globs.js +0 -0
- package/{utils → config/utils}/statics.js +0 -0
- package/dist/0.c2c52a48.iframe.bundle.js +1 -0
- package/dist/{15.08d41143.iframe.bundle.js → 17.36e3b147.iframe.bundle.js} +1 -1
- package/dist/{16.6d35c467.iframe.bundle.js → 18.c82cd4f6.iframe.bundle.js} +1 -1
- package/dist/{17.e5e0cff4.iframe.bundle.js → 19.a7c546de.iframe.bundle.js} +1 -1
- package/dist/{4.b747d0126f12a3174989.manager.bundle.js → 4.f22207b64e4d1767a207.manager.bundle.js} +2 -2
- package/dist/{4.b747d0126f12a3174989.manager.bundle.js.LICENSE.txt → 4.f22207b64e4d1767a207.manager.bundle.js.LICENSE.txt} +0 -0
- package/dist/global/docs/static/data/features.json +1 -0
- package/dist/global/docs/static/data/projects.json +1 -0
- package/dist/global/docs/static/data/used-by.json +1 -0
- package/dist/iframe.html +1 -1
- package/dist/index.html +1 -1
- package/dist/main~3c949452.603af522.iframe.bundle.js +1 -0
- package/dist/main~493df0b3.9a80c8ad.iframe.bundle.js +1 -0
- package/dist/main~6dcfc2f7.ac42cfb7.iframe.bundle.js +1 -0
- package/dist/main~adec5aba.03d9d978.iframe.bundle.js +1 -0
- package/dist/main~dc51bad7.41dee229.iframe.bundle.js +1 -0
- package/dist/{runtime~main.b74eee19.iframe.bundle.js → runtime~main.4e3eae6c.iframe.bundle.js} +1 -1
- package/dist/{runtime~main.8e5bef40c9e66074a4b5.manager.bundle.js → runtime~main.b6fd37872fbce985f385.manager.bundle.js} +1 -1
- package/dist/vendors~main~253ae210.94345bce.iframe.bundle.js +1 -0
- package/dist/vendors~main~4134d62c.fa875551.iframe.bundle.js +1 -0
- package/dist/{vendors~main~678f84af.0ec649e4.iframe.bundle.js → vendors~main~678f84af.8ccf9640.iframe.bundle.js} +1 -1
- package/dist/{vendors~main~a353122d.a896d87b.iframe.bundle.js → vendors~main~a353122d.6c9e7044.iframe.bundle.js} +1 -1
- package/dist/{vendors~main~ab68c3a7.9826dc9a.iframe.bundle.js → vendors~main~ab68c3a7.76cee064.iframe.bundle.js} +1 -1
- package/dist/{vendors~main~bdc480fb.645475cd.iframe.bundle.js → vendors~main~bdc480fb.408ce141.iframe.bundle.js} +1 -1
- package/dist/{vendors~main~d88e64ba.8bc6102b.iframe.bundle.js → vendors~main~d88e64ba.9e502858.iframe.bundle.js} +1 -1
- package/package.json +11 -8
- package/scripts/copy-statics.js +1 -1
- package/dist/0.bef0adc4.iframe.bundle.js +0 -1
- package/dist/main~493df0b3.a330297e.iframe.bundle.js +0 -1
- package/dist/main~6dcfc2f7.ea82fa4d.iframe.bundle.js +0 -1
- package/dist/main~dc51bad7.819adf82.iframe.bundle.js +0 -1
- package/dist/vendors~main~253ae210.1378a211.iframe.bundle.js +0 -1
- package/dist/vendors~main~4134d62c.c3c3dc77.iframe.bundle.js +0 -1
- package/scripts/copy-metadata-and-assets.js +0 -87
|
@@ -1,87 +0,0 @@
|
|
|
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));
|