@platformos/platformos-check-node 0.0.5 → 0.0.7

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.
@@ -1,13 +1,8 @@
1
1
  "use strict";
2
- var __importDefault = (this && this.__importDefault) || function (mod) {
3
- return (mod && mod.__esModule) ? mod : { "default": mod };
4
- };
5
2
  Object.defineProperty(exports, "__esModule", { value: true });
6
3
  exports.loadThirdPartyChecks = loadThirdPartyChecks;
7
4
  exports.findThirdPartyChecks = findThirdPartyChecks;
8
- const glob_1 = __importDefault(require("glob"));
9
- const node_util_1 = require("node:util");
10
- const asyncGlob = (0, node_util_1.promisify)(glob_1.default);
5
+ const glob_1 = require("glob");
11
6
  function loadThirdPartyChecks(
12
7
  /**
13
8
  * An array of require()-able paths.
@@ -47,7 +42,7 @@ async function findThirdPartyChecks(nodeModuleRoot) {
47
42
  globJoin(nodeModuleRoot.replace(/\\/g, '/'), '/node_modules/theme-check-*/'),
48
43
  globJoin(nodeModuleRoot.replace(/\\/g, '/'), '/node_modules/@*/theme-check-*/'),
49
44
  ];
50
- const results = await Promise.all(paths.map((path) => asyncGlob(path)));
45
+ const results = await Promise.all(paths.map((path) => (0, glob_1.glob)(path)));
51
46
  return results
52
47
  .flat()
53
48
  .filter((x) => !/\@shopify\/theme-check-(node|common|browser|docs-updater)/.test(x) &&
package/dist/index.js CHANGED
@@ -30,15 +30,13 @@ const platformos_check_docs_updater_1 = require("@platformos/platformos-check-do
30
30
  const liquid_html_parser_1 = require("@platformos/liquid-html-parser");
31
31
  const promises_1 = __importDefault(require("node:fs/promises"));
32
32
  const node_path_1 = __importDefault(require("node:path"));
33
- const node_util_1 = require("node:util");
34
33
  const vscode_uri_1 = require("vscode-uri");
35
- const glob = require("glob");
34
+ const glob_1 = require("glob");
36
35
  const autofix_1 = require("./autofix");
37
36
  const config_1 = require("./config");
38
37
  const NodeFileSystem_1 = require("./NodeFileSystem");
39
38
  Object.defineProperty(exports, "NodeFileSystem", { enumerable: true, get: function () { return NodeFileSystem_1.NodeFileSystem; } });
40
39
  const node_url_1 = require("node:url");
41
- const asyncGlob = (0, node_util_1.promisify)(glob);
42
40
  __exportStar(require("@platformos/platformos-check-common"), exports);
43
41
  __exportStar(require("./config/types"), exports);
44
42
  var backfill_docs_1 = require("./backfill-docs");
@@ -146,7 +144,7 @@ async function getTheme(config) {
146
144
  // as mentioned in the documentation of node-glob
147
145
  // the path is normalised and '\' are replaced with '/' and then passed to the glob function
148
146
  let normalizedGlob = getThemeFilesPathPattern(config.rootUri);
149
- const paths = await asyncGlob(normalizedGlob, { absolute: true }).then((result) =>
147
+ const paths = await (0, glob_1.glob)(normalizedGlob, { absolute: true }).then((result) =>
150
148
  // Global ignored paths should not be part of the theme
151
149
  result.filter((filePath) => !(0, platformos_check_common_1.isIgnored)(filePath, config)));
152
150
  const sourceCodes = await Promise.all(paths.map(toSourceCode));
@@ -1,37 +1,4 @@
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 () {
19
- var ownKeys = function(o) {
20
- ownKeys = Object.getOwnPropertyNames || function (o) {
21
- var ar = [];
22
- for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
23
- return ar;
24
- };
25
- return ownKeys(o);
26
- };
27
- return function (mod) {
28
- if (mod && mod.__esModule) return mod;
29
- var result = {};
30
- if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
31
- __setModuleDefault(result, mod);
32
- return result;
33
- };
34
- })();
35
2
  var __importDefault = (this && this.__importDefault) || function (mod) {
36
3
  return (mod && mod.__esModule) ? mod : { "default": mod };
37
4
  };
@@ -42,7 +9,6 @@ exports.removeTmpFolder = removeTmpFolder;
42
9
  exports.createMockConfigFile = createMockConfigFile;
43
10
  exports.createMockNodeModule = createMockNodeModule;
44
11
  exports.makeTempWorkspace = makeTempWorkspace;
45
- const mktemp = __importStar(require("mktemp"));
46
12
  const promises_1 = __importDefault(require("node:fs/promises"));
47
13
  const node_os_1 = __importDefault(require("node:os"));
48
14
  const node_path_1 = __importDefault(require("node:path"));
@@ -91,7 +57,7 @@ async function createMockNodeModule(tempDir, moduleName, moduleContent = exports
91
57
  return nodeModuleRoot;
92
58
  }
93
59
  async function makeTempWorkspace(structure) {
94
- const root = await mktemp.createDir(node_path_1.default.join(__dirname, '..', '.XXXXX'));
60
+ const root = await promises_1.default.mkdtemp(node_path_1.default.join(__dirname, '..', '.'));
95
61
  if (!root)
96
62
  throw new Error('Could not create temp dir for temp workspace');
97
63
  await createFiles(structure, [root]);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@platformos/platformos-check-node",
3
- "version": "0.0.5",
3
+ "version": "0.0.7",
4
4
  "main": "dist/index.js",
5
5
  "types": "dist/index.d.ts",
6
6
  "author": "platformOS",
@@ -33,13 +33,11 @@
33
33
  "type-check": "tsc --noEmit"
34
34
  },
35
35
  "dependencies": {
36
- "@platformos/platformos-check-common": "0.0.5",
37
- "@platformos/platformos-check-docs-updater": "0.0.5",
38
- "glob": "^8.0.3",
39
- "vscode-uri": "^3.0.7",
40
- "yaml": "^2.3.0"
36
+ "@platformos/platformos-check-common": "0.0.7",
37
+ "@platformos/platformos-check-docs-updater": "0.0.7",
38
+ "glob": "^13.0.0",
39
+ "vscode-uri": "^3.1.0",
40
+ "yaml": "^2.8.2"
41
41
  },
42
- "devDependencies": {
43
- "@types/glob": "^8.0.0"
44
- }
42
+ "devDependencies": {}
45
43
  }
@@ -1,24 +0,0 @@
1
- export interface GenerateDocsOptions {
2
- dryRun?: boolean;
3
- output?: 'inline' | 'stdout' | 'json';
4
- }
5
- export interface GenerateDocsResult {
6
- uri: string;
7
- relativePath: string;
8
- parameters: Array<{
9
- name: string;
10
- type: string | null;
11
- isOptional: boolean;
12
- }>;
13
- docBlockText: string;
14
- hasExistingDocBlock: boolean;
15
- updated: boolean;
16
- }
17
- /**
18
- * Generate doc blocks for all partials and blocks in a theme.
19
- */
20
- export declare function generateDocsCommand(root: string, options?: GenerateDocsOptions): Promise<GenerateDocsResult[]>;
21
- /**
22
- * Generate doc block for a single file.
23
- */
24
- export declare function generateDocForFile(absolutePath: string, options?: GenerateDocsOptions): Promise<GenerateDocsResult | null>;
@@ -1,136 +0,0 @@
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
- exports.generateDocsCommand = generateDocsCommand;
7
- exports.generateDocForFile = generateDocForFile;
8
- const platformos_check_common_1 = require("@platformos/platformos-check-common");
9
- const platformos_check_docs_updater_1 = require("@platformos/platformos-check-docs-updater");
10
- const liquid_html_parser_1 = require("@platformos/liquid-html-parser");
11
- const promises_1 = __importDefault(require("node:fs/promises"));
12
- const node_path_1 = __importDefault(require("node:path"));
13
- const node_util_1 = require("node:util");
14
- const vscode_uri_1 = require("vscode-uri");
15
- const glob = require("glob");
16
- const asyncGlob = (0, node_util_1.promisify)(glob);
17
- /**
18
- * Generate doc blocks for all partials and blocks in a theme.
19
- */
20
- async function generateDocsCommand(root, options = {}) {
21
- const { dryRun = false, output = 'inline' } = options;
22
- const rootUri = platformos_check_common_1.path.normalize(vscode_uri_1.URI.file(root));
23
- const themeLiquidDocsManager = new platformos_check_docs_updater_1.ThemeLiquidDocsManager(console.error.bind(console));
24
- // Find all liquid files that support doc blocks (partials and blocks)
25
- const partialsGlob = node_path_1.default
26
- .normalize(node_path_1.default.join(root, 'app/views/partials/**/*.liquid'))
27
- .replace(/\\/g, '/');
28
- const blocksGlob = node_path_1.default
29
- .normalize(node_path_1.default.join(root, 'blocks/**/*.liquid'))
30
- .replace(/\\/g, '/');
31
- const [partialPaths, blockPaths] = await Promise.all([
32
- asyncGlob(partialsGlob, { absolute: true }),
33
- asyncGlob(blocksGlob, { absolute: true }),
34
- ]);
35
- const allPaths = [...partialPaths, ...blockPaths];
36
- const results = [];
37
- for (const absolutePath of allPaths) {
38
- const uri = platformos_check_common_1.path.normalize(vscode_uri_1.URI.file(absolutePath));
39
- // Double-check this file supports doc blocks
40
- if (!(0, platformos_check_common_1.filePathSupportsLiquidDoc)(uri))
41
- continue;
42
- // Read and parse the file
43
- const source = await promises_1.default.readFile(absolutePath, 'utf8');
44
- const sourceCode = (0, platformos_check_common_1.toSourceCode)(uri, source);
45
- if (!sourceCode || sourceCode.type !== platformos_check_common_1.SourceCodeType.LiquidHtml)
46
- continue;
47
- const ast = sourceCode.ast;
48
- if (!(0, liquid_html_parser_1.isLiquidHtmlNode)(ast))
49
- continue;
50
- // Generate doc block
51
- const docResult = await (0, platformos_check_common_1.generateDocBlock)(ast, uri, themeLiquidDocsManager);
52
- const relativePath = node_path_1.default.relative(root, absolutePath);
53
- const result = {
54
- uri,
55
- relativePath,
56
- parameters: docResult.parameters,
57
- docBlockText: docResult.docBlockText,
58
- hasExistingDocBlock: docResult.hasExistingDocBlock,
59
- updated: false,
60
- };
61
- // Skip files that already have doc blocks
62
- if (docResult.hasExistingDocBlock) {
63
- results.push(result);
64
- continue;
65
- }
66
- // Skip files with no detected parameters
67
- if (docResult.parameters.length === 0) {
68
- results.push(result);
69
- continue;
70
- }
71
- // If not dry run and output is inline, write the doc block to the file
72
- if (!dryRun && output === 'inline') {
73
- const newSource = docResult.docBlockText + '\n\n' + source;
74
- await promises_1.default.writeFile(absolutePath, newSource, 'utf8');
75
- result.updated = true;
76
- }
77
- results.push(result);
78
- }
79
- // Output based on mode
80
- if (output === 'stdout') {
81
- for (const result of results) {
82
- if (result.hasExistingDocBlock) {
83
- console.log(`[SKIP] ${result.relativePath} - already has doc block`);
84
- }
85
- else if (result.parameters.length === 0) {
86
- console.log(`[SKIP] ${result.relativePath} - no parameters detected`);
87
- }
88
- else if (dryRun) {
89
- console.log(`[DRY-RUN] ${result.relativePath}`);
90
- console.log(result.docBlockText);
91
- console.log('');
92
- }
93
- else {
94
- console.log(`[UPDATED] ${result.relativePath}`);
95
- }
96
- }
97
- }
98
- else if (output === 'json') {
99
- console.log(JSON.stringify(results, null, 2));
100
- }
101
- return results;
102
- }
103
- /**
104
- * Generate doc block for a single file.
105
- */
106
- async function generateDocForFile(absolutePath, options = {}) {
107
- const { dryRun = false } = options;
108
- const uri = platformos_check_common_1.path.normalize(vscode_uri_1.URI.file(absolutePath));
109
- if (!(0, platformos_check_common_1.filePathSupportsLiquidDoc)(uri)) {
110
- return null;
111
- }
112
- const themeLiquidDocsManager = new platformos_check_docs_updater_1.ThemeLiquidDocsManager(console.error.bind(console));
113
- const source = await promises_1.default.readFile(absolutePath, 'utf8');
114
- const sourceCode = (0, platformos_check_common_1.toSourceCode)(uri, source);
115
- if (!sourceCode || sourceCode.type !== platformos_check_common_1.SourceCodeType.LiquidHtml)
116
- return null;
117
- const ast = sourceCode.ast;
118
- if (!(0, liquid_html_parser_1.isLiquidHtmlNode)(ast))
119
- return null;
120
- const docResult = await (0, platformos_check_common_1.generateDocBlock)(ast, uri, themeLiquidDocsManager);
121
- const result = {
122
- uri,
123
- relativePath: absolutePath,
124
- parameters: docResult.parameters,
125
- docBlockText: docResult.docBlockText,
126
- hasExistingDocBlock: docResult.hasExistingDocBlock,
127
- updated: false,
128
- };
129
- if (!docResult.hasExistingDocBlock && docResult.parameters.length > 0 && !dryRun) {
130
- const newSource = docResult.docBlockText + '\n\n' + source;
131
- await promises_1.default.writeFile(absolutePath, newSource, 'utf8');
132
- result.updated = true;
133
- }
134
- return result;
135
- }
136
- //# sourceMappingURL=generate-docs.js.map
@@ -1 +0,0 @@
1
- export { generateDocsCommand, generateDocForFile, GenerateDocsOptions, GenerateDocsResult, } from './generate-docs';
@@ -1,7 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.generateDocForFile = exports.generateDocsCommand = void 0;
4
- var generate_docs_1 = require("./generate-docs");
5
- Object.defineProperty(exports, "generateDocsCommand", { enumerable: true, get: function () { return generate_docs_1.generateDocsCommand; } });
6
- Object.defineProperty(exports, "generateDocForFile", { enumerable: true, get: function () { return generate_docs_1.generateDocForFile; } });
7
- //# sourceMappingURL=index.js.map