@platformos/platformos-check-docs-updater 0.0.7 → 0.0.9

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 (37) hide show
  1. package/CHANGELOG.md +16 -0
  2. package/data/manifest_platformos.json +5 -0
  3. package/data/platformos_system_translations.json +3 -0
  4. package/dist/index.d.ts +2 -2
  5. package/dist/index.js +8 -8
  6. package/dist/index.js.map +1 -1
  7. package/dist/platformOSLiquidDocsDownloader.d.ts +14 -0
  8. package/dist/platformOSLiquidDocsDownloader.js +100 -0
  9. package/dist/platformOSLiquidDocsDownloader.js.map +1 -0
  10. package/dist/platformOSLiquidDocsManager.d.ts +26 -0
  11. package/dist/platformOSLiquidDocsManager.js +139 -0
  12. package/dist/platformOSLiquidDocsManager.js.map +1 -0
  13. package/dist/themeLiquidDocsDownloader.js +2 -1
  14. package/dist/themeLiquidDocsDownloader.js.map +1 -1
  15. package/dist/tsconfig.tsbuildinfo +1 -1
  16. package/package.json +3 -3
  17. package/scripts/cli.js +2 -2
  18. package/src/index.ts +3 -3
  19. package/src/platformOSLiquidDocsDownloader.ts +118 -0
  20. package/src/{themeLiquidDocsManager.spec.ts → platformOSLiquidDocsManager.spec.ts} +11 -24
  21. package/src/{themeLiquidDocsManager.ts → platformOSLiquidDocsManager.ts} +11 -84
  22. package/data/app_block_entry.json +0 -13
  23. package/data/default_setting_values.json +0 -24
  24. package/data/local_block_entry.json +0 -25
  25. package/data/manifest_theme.json +0 -19
  26. package/data/manifest_theme_app_extension.json +0 -10
  27. package/data/preset.json +0 -72
  28. package/data/preset_blocks.json +0 -91
  29. package/data/section.json +0 -208
  30. package/data/setting.json +0 -1368
  31. package/data/settings.json +0 -10
  32. package/data/shopify_system_translations.json +0 -2461
  33. package/data/targetted_block_entry.json +0 -15
  34. package/data/theme_block.json +0 -91
  35. package/data/theme_block_entry.json +0 -14
  36. package/data/theme_settings.json +0 -83
  37. package/src/themeLiquidDocsDownloader.ts +0 -191
@@ -1,15 +0,0 @@
1
- {
2
- "$schema": "http://json-schema.org/draft-07/schema#",
3
- "$comment": "A targetted private or public theme block from the blocks/ folder.",
4
- "type": "object",
5
- "required": ["type"],
6
- "additionalProperties": false,
7
- "properties": {
8
- "type": {
9
- "type": "string",
10
- "pattern": "^[a-zA-Z0-9_-]+$",
11
- "description": "The name of a theme block found in the blocks/ folder of the theme.",
12
- "markdownDescription": "The name of a theme block found in the `blocks/` folder of the theme.\n\n---\n\n[Shopify reference](https://shopify.dev/docs/themes/architecture/blocks/theme-blocks/schema#blocks)"
13
- }
14
- }
15
- }
@@ -1,91 +0,0 @@
1
- {
2
- "$schema": "http://json-schema.org/draft-07/schema#",
3
- "title": "Shopify Liquid Theme Block Schema",
4
- "type": "object",
5
- "additionalProperties": false,
6
- "properties": {
7
- "name": {
8
- "type": "string",
9
- "description": "The name attribute determines the block title that's shown in the theme editor.",
10
- "markdownDescription": "The `name` attribute determines the block title that's shown in the theme editor.\n\n---\n\n[Shopify reference](https://shopify.dev/docs/themes/architecture/blocks/theme-blocks/schema#name)"
11
- },
12
-
13
- "settings": {
14
- "$ref": "./settings.json"
15
- },
16
-
17
- "blocks": {
18
- "type": "array",
19
- "description": "Theme blocks can accept other app and theme blocks as children using the blocks attribute of their schema.",
20
- "markdownDescription": "Theme blocks can accept other app and theme blocks as children using the `blocks` attribute of their schema.\n\n---\n\n[Shopify reference](https://shopify.dev/docs/themes/architecture/blocks/theme-blocks/schema#blocks)",
21
- "items": {
22
- "type": "object",
23
- "additionalProperties": false,
24
- "required": ["type"],
25
- "properties": {
26
- "type": {
27
- "type": "string",
28
- "description": "The type of block that can be added to this block.",
29
- "markdownDescription": "The type of block that can be added to this block.\n\n---\n\n[Shopify reference](https://shopify.dev/docs/themes/architecture/blocks/theme-blocks/schema#blocks)"
30
- }
31
- },
32
- "$comment": "The allOf rule here exists because that's how we do discriminated unions in JSON schemas. If a rule matches, that rule will be used to document the type property. Otherwise we fallback to the docs above.",
33
- "allOf": [
34
- {
35
- "if": { "required": ["type"], "properties": { "type": { "const": "@theme" } } },
36
- "then": { "$ref": "./theme_block_entry.json" }
37
- },
38
- {
39
- "if": { "required": ["type"], "properties": { "type": { "const": "@app" } } },
40
- "then": { "$ref": "./app_block_entry.json" }
41
- },
42
- {
43
- "if": {
44
- "required": ["type"],
45
- "properties": {
46
- "type": {
47
- "type": "string",
48
- "not": { "enum": ["@app", "@theme"] }
49
- }
50
- }
51
- },
52
- "then": { "$ref": "./targetted_block_entry.json" }
53
- }
54
- ]
55
- }
56
- },
57
-
58
- "presets": {
59
- "type": "array",
60
- "description": "Presets are default configurations of blocks that enable merchants to easily add a block to a JSON template through the theme editor.",
61
- "markdownDescription": "Presets are default configurations of blocks that enable merchants to easily add a block to a JSON template through the theme editor.\n\n---\n\n[Shopify reference](https://shopify.dev/docs/themes/architecture/blocks/theme-blocks/schema#presets)",
62
- "items": {
63
- "$ref": "./preset.json"
64
- }
65
- },
66
-
67
- "tag": {
68
- "description": "The HTML element that is used to wrap the rendered block. Accepts any string up to 50 characters. Can be used to render custom HTML elements. Use null to render without a wrapping element.",
69
- "markdownDescription": "The HTML element that is used to wrap the rendered block. Accepts any string up to 50 characters. Can be used to render custom HTML elements.\n\nUse `null` to render without a wrapping element.\n\n---\n\n[Shopify reference](https://shopify.dev/docs/themes/architecture/blocks/theme-blocks/schema#tag)",
70
- "oneOf": [
71
- {
72
- "description": "If you don't want to use a <div>, then you can specify which kind of HTML element to use.",
73
- "markdownDescription": "If you don't want to use a `<div>`, then you can specify which kind of HTML element to use.\n\n---\n\n[Shopify reference](https://shopify.dev/docs/themes/architecture/blocks/theme-blocks/schema#tag)",
74
- "type": "string",
75
- "maxLength": 50
76
- },
77
- {
78
- "description": "Used to render the block without a wrapping element.",
79
- "markdownDescription": "Used to render the block without a wrapping element.\n\n---\n\n[Shopify reference](https://shopify.dev/docs/themes/architecture/blocks/theme-blocks/schema#rendering-blocks-without-a-wrapper)",
80
- "type": "null"
81
- }
82
- ]
83
- },
84
-
85
- "class": {
86
- "type": "string",
87
- "description": "When Shopify renders a block, it's wrapped in an HTML element with the shopify-block class. You can append other classes by using the class attribute.",
88
- "markdownDescription": "When Shopify renders a block, it's wrapped in an HTML element with the `shopify-block` class. You can append other classes by using the class attribute.\n\n---\n\n[Shopify reference](https://shopify.dev/docs/themes/architecture/blocks/theme-blocks/schema#class)"
89
- }
90
- }
91
- }
@@ -1,14 +0,0 @@
1
- {
2
- "$schema": "http://json-schema.org/draft-07/schema#",
3
- "$comment": "A @theme block entry",
4
- "type": "object",
5
- "additionalProperties": false,
6
- "required": ["type"],
7
- "properties": {
8
- "type": {
9
- "const": "@theme",
10
- "description": "The \"@theme\" type denotes that this container accepts theme blocks that live in the blocks/ folder of the theme.",
11
- "markdownDescription": "The `@theme` type denotes that this container accepts theme blocks that live in the `blocks/` folder of the theme.\n\n---\n\n[Shopify reference](https://shopify.dev/docs/themes/architecture/blocks/theme-blocks/schema#blocks)"
12
- }
13
- }
14
- }
@@ -1,83 +0,0 @@
1
- {
2
- "$schema": "http://json-schema.org/draft-07/schema#",
3
- "title": "JSON schema for config/settings_schema.json files.",
4
- "description": "The settings that merchants can configure in the theme editor.",
5
- "markdownDescription": "The settings that merchants can configure in the theme editor.\n\n---\n\n[Shopify reference](https://shopify.dev/docs/themes/architecture/config/settings-schema-json)",
6
- "type": "array",
7
- "items": {
8
- "anyOf": [
9
- {
10
- "title": "Theme metadata",
11
- "markdownDescription": "Additional metadata for your theme that shows up in the Theme actions menu of the theme editor.\n\n---\n\n[Shopify reference](https://shopify.dev/docs/themes/architecture/config/settings-schema-json#add-theme-metadata)",
12
- "type": "object",
13
- "properties": {
14
- "name": {
15
- "description": "You may use the 'theme_info' object for theme metadata.",
16
- "markdownDescription": "[Shopify reference](https://shopify.dev/docs/themes/architecture/config/settings-schema-json#add-theme-metadata)",
17
- "const": "theme_info"
18
- },
19
- "theme_name": {
20
- "type": "string",
21
- "description": "The name of the theme."
22
- },
23
- "theme_author": {
24
- "type": "string",
25
- "description": "The author of the theme."
26
- },
27
- "theme_version": {
28
- "type": "string",
29
- "description": "The version number of the theme."
30
- },
31
- "theme_documentation_url": {
32
- "type": "string",
33
- "format": "uri",
34
- "description": "A URL where merchants can find documentation for the theme."
35
- },
36
- "theme_support_email": {
37
- "type": "string",
38
- "format": "email",
39
- "description": "An email address that merchants can contact for support for the theme."
40
- },
41
- "theme_support_url": {
42
- "type": "string",
43
- "format": "uri",
44
- "description": "A URL where merchants can find support for the theme."
45
- }
46
- },
47
- "required": [
48
- "name",
49
- "theme_name",
50
- "theme_author",
51
- "theme_version",
52
- "theme_documentation_url"
53
- ],
54
- "oneOf": [
55
- {
56
- "required": ["theme_support_email"],
57
- "not": { "required": ["theme_support_url"] }
58
- },
59
- {
60
- "required": ["theme_support_url"],
61
- "not": { "required": ["theme_support_email"] }
62
- }
63
- ]
64
- },
65
- {
66
- "type": "object",
67
- "properties": {
68
- "name": {
69
- "type": "string",
70
- "description": "The name of the category of settings.",
71
- "markdownDescription": "The name of the category of settings.\n\n---\n\n[Shopify reference](https://shopify.dev/docs/themes/architecture/config/settings-schema-json#schema)",
72
- "not": {
73
- "const": "theme_info"
74
- }
75
- },
76
- "settings": {
77
- "$ref": "./settings.json"
78
- }
79
- }
80
- }
81
- ]
82
- }
83
- }
@@ -1,191 +0,0 @@
1
- import { Mode } from '@platformos/platformos-check-common';
2
- import envPaths from 'env-paths';
3
- import fs from 'node:fs/promises';
4
- import path from 'node:path';
5
- import { Logger, noop, tap } from './utils';
6
- import he from 'he';
7
- const paths = envPaths('theme-liquid-docs');
8
- export const root = paths.cache;
9
-
10
- export const ThemeLiquidDocsRootFallback =
11
- 'https://raw.githubusercontent.com/Shopify/theme-liquid-docs/main';
12
- export const ThemeLiquidDocsRoot = 'https://documentation.platformos.com/api/liquid';
13
- export const ThemeCustomSchemas = ['tags', 'latest', 'objects', 'filters'];
14
- export const ThemeGraphQLSchema = 'https://documentation.platformos.com/api/graphql/schema';
15
-
16
- export type Resource = (typeof Resources)[number];
17
- export const Resources = [
18
- 'filters',
19
- 'objects',
20
- 'tags',
21
- 'shopify_system_translations',
22
- 'manifest_theme',
23
- 'manifest_theme_app_extension',
24
- ] as const;
25
-
26
- export const Manifests = {
27
- app: 'manifest_theme_app_extension',
28
- theme: 'manifest_theme',
29
- } as const satisfies Record<Mode, Resource>;
30
-
31
- const THEME_LIQUID_DOCS: Record<Resource | 'latest', string> = {
32
- filters: 'filters.json',
33
- objects: 'objects.json',
34
- tags: 'tags.json',
35
- latest: 'latest.json',
36
- shopify_system_translations: 'data/shopify_system_translations.json',
37
- manifest_theme: 'schemas/manifest_theme.json',
38
- manifest_theme_app_extension: 'schemas/manifest_theme_app_extension.json',
39
- };
40
-
41
- export async function downloadSchema(
42
- relativeUri: string,
43
- destination: string = root,
44
- log: Logger = noop,
45
- ) {
46
- const remotePath = schemaUrl(relativeUri);
47
- const localPath = schemaPath(relativeUri, destination);
48
- const text = await download(remotePath, log);
49
- await fs.writeFile(localPath, text, 'utf8');
50
- return text;
51
- }
52
-
53
- export async function downloadResource(
54
- resource: Resource | 'latest',
55
- destination: string = root,
56
- log: Logger = noop,
57
- ) {
58
- const remotePath = resourceUrl(resource);
59
- const localPath = resourcePath(resource, destination);
60
- const text = await download(remotePath, log);
61
- await fs.writeFile(localPath, text, 'utf8');
62
- return text;
63
- }
64
-
65
- export async function downloadGraphQLSchema(destination: string = root, log: Logger = noop) {
66
- const localPath = graphQLPath(destination);
67
- const text = await download(ThemeGraphQLSchema, log);
68
- await fs.writeFile(localPath, he.decode(text), 'utf8');
69
- return text;
70
- }
71
-
72
- export function graphQLPath(destination: string = root) {
73
- return path.join(destination, `graphql.graphql`);
74
- }
75
-
76
- export async function download(path: string, log: Logger) {
77
- if (path.startsWith('file:')) {
78
- return await fs
79
- .readFile(path.replace(/^file:/, ''), 'utf8')
80
- .then(tap(() => log(`Using local file: ${path}`)))
81
- .catch((error) => {
82
- log(`Failed to read local file: ${path}`);
83
- throw error;
84
- });
85
- } else {
86
- log(path);
87
- const res = await fetch(path);
88
- return res.text();
89
- }
90
- }
91
-
92
- export function resourcePath(resource: Resource | 'latest', destination: string = root) {
93
- return path.join(destination, `${resource}.json`);
94
- }
95
-
96
- export function resourceUrl(resource: Resource | 'latest') {
97
- let resourceRoot = `${ThemeLiquidDocsRootFallback}`;
98
-
99
- if (ThemeCustomSchemas.includes(resource)) {
100
- resourceRoot = ThemeLiquidDocsRoot;
101
- }
102
- const relativePath = THEME_LIQUID_DOCS[resource];
103
- return `${resourceRoot}/${relativePath}`;
104
- }
105
-
106
- export function schemaPath(relativeUri: string, destination: string = root) {
107
- return path.resolve(destination, path.basename(relativeUri));
108
- }
109
-
110
- export function schemaUrl(relativeUri: string) {
111
- const schemaRoot = process.env.SHOPIFY_TLD_ROOT
112
- ? `file:${process.env.SHOPIFY_TLD_ROOT}`
113
- : ThemeLiquidDocsRootFallback;
114
- return `${schemaRoot}/schemas/${relativeUri}`;
115
- }
116
-
117
- export async function exists(path: string) {
118
- try {
119
- await fs.stat(path);
120
- return true;
121
- } catch (e) {
122
- return false;
123
- }
124
- }
125
-
126
- export async function downloadThemeLiquidDocs(destination: string, log: Logger) {
127
- if (!(await exists(destination))) {
128
- await fs.mkdir(destination);
129
- }
130
-
131
- const resources = ['latest'].concat(Resources) as (Resource | 'latest')[];
132
- const resourceContents = await Promise.all(
133
- resources.map((file) => {
134
- return downloadResource(file, destination, log)
135
- .then(
136
- tap(() =>
137
- log(
138
- `Successfully downloaded latest resource:\n\t${resourceUrl(file)}\n\t> ${resourcePath(
139
- file,
140
- destination,
141
- )}`,
142
- ),
143
- ),
144
- )
145
- .catch((error) => {
146
- log(
147
- `Failed to download latest resource:\n\t${resourceUrl(file)} to\n\t${resourcePath(
148
- file,
149
- destination,
150
- )}\n${error}`,
151
- );
152
- throw error;
153
- });
154
- }),
155
- );
156
-
157
- const manifests = Object.values(Manifests)
158
- .map((resource) => resources.indexOf(resource))
159
- .map((index) => resourceContents[index])
160
- .map((manifest) => JSON.parse(manifest));
161
-
162
- const relativeUris = manifests.flatMap((manifest) =>
163
- manifest.schemas.map((schema: { uri: string }) => schema.uri),
164
- );
165
-
166
- await Promise.all(
167
- unique(relativeUris).map((uri) =>
168
- downloadSchema(uri, destination, log)
169
- .then(
170
- tap(() =>
171
- log(
172
- `Successfully downloaded schema:\n\t${schemaUrl(uri)}\n\t> ${schemaPath(
173
- uri,
174
- destination,
175
- )}`,
176
- ),
177
- ),
178
- )
179
- .catch((error) => {
180
- log(`Failed to download schema: ${uri}, ${error}`);
181
- throw error;
182
- }),
183
- ),
184
- );
185
-
186
- await downloadGraphQLSchema(destination, log);
187
- }
188
-
189
- function unique<T>(array: T[]): T[] {
190
- return [...new Set(array).values()];
191
- }