@platformos/platformos-check-docs-updater 0.0.7 → 0.0.8
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/CHANGELOG.md +8 -0
- package/data/manifest_platformos.json +5 -0
- package/data/platformos_system_translations.json +3 -0
- package/dist/index.d.ts +2 -2
- package/dist/index.js +8 -8
- package/dist/index.js.map +1 -1
- package/dist/platformOSLiquidDocsDownloader.d.ts +14 -0
- package/dist/platformOSLiquidDocsDownloader.js +100 -0
- package/dist/platformOSLiquidDocsDownloader.js.map +1 -0
- package/dist/platformOSLiquidDocsManager.d.ts +26 -0
- package/dist/platformOSLiquidDocsManager.js +139 -0
- package/dist/platformOSLiquidDocsManager.js.map +1 -0
- package/dist/themeLiquidDocsDownloader.js +2 -1
- package/dist/themeLiquidDocsDownloader.js.map +1 -1
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/package.json +2 -2
- package/scripts/cli.js +2 -2
- package/src/index.ts +3 -3
- package/src/platformOSLiquidDocsDownloader.ts +118 -0
- package/src/{themeLiquidDocsManager.spec.ts → platformOSLiquidDocsManager.spec.ts} +11 -24
- package/src/{themeLiquidDocsManager.ts → platformOSLiquidDocsManager.ts} +11 -84
- package/data/shopify_system_translations.json +0 -2461
- package/src/themeLiquidDocsDownloader.ts +0 -191
|
@@ -1,34 +1,25 @@
|
|
|
1
1
|
import {
|
|
2
2
|
FilterEntry,
|
|
3
3
|
JsonValidationSet,
|
|
4
|
-
Mode,
|
|
5
4
|
ObjectEntry,
|
|
6
5
|
SchemaDefinition,
|
|
7
6
|
TagEntry,
|
|
8
|
-
|
|
9
|
-
Translations,
|
|
7
|
+
PlatformOSDocset,
|
|
10
8
|
} from '@platformos/platformos-check-common';
|
|
11
9
|
import fs from 'node:fs/promises';
|
|
12
10
|
import path from 'node:path';
|
|
13
11
|
import {
|
|
14
|
-
Manifests,
|
|
15
12
|
Resource,
|
|
16
|
-
ThemeCustomSchemas,
|
|
17
|
-
ThemeLiquidDocsRoot,
|
|
18
|
-
ThemeLiquidDocsRootFallback,
|
|
19
13
|
downloadResource,
|
|
20
|
-
|
|
14
|
+
downloadPlatformOSLiquidDocs,
|
|
21
15
|
exists,
|
|
22
16
|
graphQLPath,
|
|
23
17
|
resourcePath,
|
|
24
18
|
root,
|
|
25
|
-
|
|
26
|
-
} from './
|
|
27
|
-
import { Logger, identity, memo, memoize, noop, tap } from './utils';
|
|
19
|
+
} from './platformOSLiquidDocsDownloader';
|
|
20
|
+
import { Logger, memo, noop, tap } from './utils';
|
|
28
21
|
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
export class ThemeLiquidDocsManager implements ThemeDocset, JsonValidationSet {
|
|
22
|
+
export class PlatformOSLiquidDocsManager implements PlatformOSDocset, JsonValidationSet {
|
|
32
23
|
constructor(private log: Logger = noop) {}
|
|
33
24
|
|
|
34
25
|
filters = memo(async (): Promise<FilterEntry[]> => {
|
|
@@ -48,54 +39,15 @@ export class ThemeLiquidDocsManager implements ThemeDocset, JsonValidationSet {
|
|
|
48
39
|
});
|
|
49
40
|
|
|
50
41
|
graphQL = memo(async (): Promise<string | null> => {
|
|
51
|
-
return findSuitableResource(this.
|
|
42
|
+
return findSuitableResource(this.graphqlLoaders(), (x: string) => x, null, this.log);
|
|
52
43
|
});
|
|
53
44
|
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
this.loaders('shopify_system_translations'),
|
|
57
|
-
JSON.parse,
|
|
58
|
-
{},
|
|
59
|
-
this.log,
|
|
60
|
-
);
|
|
61
|
-
});
|
|
62
|
-
|
|
63
|
-
schemas = memoize(
|
|
64
|
-
(mode: Mode) =>
|
|
65
|
-
findSuitableResource<JSONSchemaManifest>(
|
|
66
|
-
this.loaders(Manifests[mode]),
|
|
67
|
-
JSON.parse,
|
|
68
|
-
{
|
|
69
|
-
schemas: [],
|
|
70
|
-
},
|
|
71
|
-
this.log,
|
|
72
|
-
).then((manifest) => {
|
|
73
|
-
return Promise.all(
|
|
74
|
-
manifest.schemas.map(async (schemaDefinition): Promise<SchemaDefinition> => {
|
|
75
|
-
let schemaRoot = `${ThemeLiquidDocsRootFallback}/schemas`;
|
|
76
|
-
|
|
77
|
-
if (ThemeCustomSchemas.includes(schemaDefinition.uri)) {
|
|
78
|
-
schemaRoot = ThemeLiquidDocsRoot;
|
|
79
|
-
}
|
|
80
|
-
return {
|
|
81
|
-
uri: `${schemaRoot}/${schemaDefinition.uri}`,
|
|
82
|
-
fileMatch: schemaDefinition.fileMatch,
|
|
83
|
-
schema: await findSuitableResource(
|
|
84
|
-
this.schemaLoaders(schemaDefinition.uri),
|
|
85
|
-
identity,
|
|
86
|
-
'',
|
|
87
|
-
this.log,
|
|
88
|
-
),
|
|
89
|
-
};
|
|
90
|
-
}),
|
|
91
|
-
);
|
|
92
|
-
}),
|
|
93
|
-
identity<Mode>,
|
|
94
|
-
);
|
|
45
|
+
// platformOS does not use JSON schemas for sections/blocks/settings.
|
|
46
|
+
schemas = memo(async (): Promise<SchemaDefinition[]> => []);
|
|
95
47
|
|
|
96
48
|
/**
|
|
97
49
|
* The setup method checks that the latest revision matches the one from
|
|
98
|
-
*
|
|
50
|
+
* the platformOS liquid docs. If there's a diff in revision, it means
|
|
99
51
|
* that the documentations that you have locally are out of date.
|
|
100
52
|
*
|
|
101
53
|
* The setup method then downloads the other files.
|
|
@@ -110,7 +62,7 @@ export class ThemeLiquidDocsManager implements ThemeDocset, JsonValidationSet {
|
|
|
110
62
|
await downloadResource('latest', root, this.log);
|
|
111
63
|
const remote = await this.latestRevision();
|
|
112
64
|
if (local !== remote) {
|
|
113
|
-
await
|
|
65
|
+
await downloadPlatformOSLiquidDocs(root, this.log);
|
|
114
66
|
}
|
|
115
67
|
} catch (error) {
|
|
116
68
|
if (error instanceof Error) {
|
|
@@ -141,12 +93,6 @@ export class ThemeLiquidDocsManager implements ThemeDocset, JsonValidationSet {
|
|
|
141
93
|
return fs.readFile(resourcePath(name), 'utf8');
|
|
142
94
|
}
|
|
143
95
|
|
|
144
|
-
private async loadSchema(relativeUri: string) {
|
|
145
|
-
return fs
|
|
146
|
-
.readFile(schemaPath(relativeUri), 'utf8')
|
|
147
|
-
.then(tap(() => this.log(`Loaded schema from ${schemaPath(relativeUri)}`)));
|
|
148
|
-
}
|
|
149
|
-
|
|
150
96
|
private async loadGraphQL() {
|
|
151
97
|
return fs.readFile(graphQLPath(), 'utf8').then(tap(() => this.log(`Loaded graphQL`)));
|
|
152
98
|
}
|
|
@@ -158,14 +104,7 @@ export class ThemeLiquidDocsManager implements ThemeDocset, JsonValidationSet {
|
|
|
158
104
|
];
|
|
159
105
|
}
|
|
160
106
|
|
|
161
|
-
private
|
|
162
|
-
return [
|
|
163
|
-
loader(() => this.loadSchema(relativeUri), `loadSchema(${relativeUri})`),
|
|
164
|
-
loader(() => fallbackSchema(relativeUri, this.log), `fallbackSchema(${relativeUri})`),
|
|
165
|
-
];
|
|
166
|
-
}
|
|
167
|
-
|
|
168
|
-
private graphQLLoaders(): Loader<string>[] {
|
|
107
|
+
private graphqlLoaders(): Loader<string>[] {
|
|
169
108
|
return [
|
|
170
109
|
loader(() => this.loadGraphQL(), `loadGraphQL()`),
|
|
171
110
|
loader(() => fallbackGraphQL(this.log), `fallbackSchema()`),
|
|
@@ -235,18 +174,6 @@ async function fallbackResource(name: Resource, log: Logger): Promise<string> {
|
|
|
235
174
|
.then(tap(() => log(`Loaded fallback resource\n\t${name} from\n\t${sourcePath}`)));
|
|
236
175
|
}
|
|
237
176
|
|
|
238
|
-
/** Returns the at-build-time path to the fallback schema file. */
|
|
239
|
-
async function fallbackSchema(
|
|
240
|
-
/** e.g. themes/section.json */
|
|
241
|
-
relativeUri: string,
|
|
242
|
-
log: Logger,
|
|
243
|
-
): Promise<string> {
|
|
244
|
-
const sourcePath = path.resolve(dataRoot(), path.basename(relativeUri));
|
|
245
|
-
return fs
|
|
246
|
-
.readFile(sourcePath, 'utf8')
|
|
247
|
-
.then(tap(() => log(`Loaded fallback schema\n\t${relativeUri} from\n\t${sourcePath}`)));
|
|
248
|
-
}
|
|
249
|
-
|
|
250
177
|
async function fallbackGraphQL(log: Logger): Promise<string> {
|
|
251
178
|
const sourcePath = path.resolve(dataRoot(), `graphql.graphql`);
|
|
252
179
|
return fs
|