@platformos/platformos-check-node 0.0.11 → 0.0.13

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/configs/all.yml CHANGED
@@ -42,10 +42,19 @@ MetadataParamsCheck:
42
42
  MissingAsset:
43
43
  enabled: true
44
44
  severity: 0
45
+ MissingPage:
46
+ enabled: true
47
+ severity: 1
45
48
  MissingPartial:
46
49
  enabled: true
47
50
  severity: 0
48
51
  ignoreMissing: []
52
+ MissingRenderPartialArguments:
53
+ enabled: true
54
+ severity: 0
55
+ NestedGraphQLQuery:
56
+ enabled: true
57
+ severity: 1
49
58
  OrphanedPartial:
50
59
  enabled: true
51
60
  severity: 1
@@ -42,10 +42,19 @@ MetadataParamsCheck:
42
42
  MissingAsset:
43
43
  enabled: true
44
44
  severity: 0
45
+ MissingPage:
46
+ enabled: true
47
+ severity: 1
45
48
  MissingPartial:
46
49
  enabled: true
47
50
  severity: 0
48
51
  ignoreMissing: []
52
+ MissingRenderPartialArguments:
53
+ enabled: true
54
+ severity: 0
55
+ NestedGraphQLQuery:
56
+ enabled: true
57
+ severity: 1
49
58
  OrphanedPartial:
50
59
  enabled: true
51
60
  severity: 1
@@ -28,6 +28,8 @@ function getPartialName(node) {
28
28
  * When the same argument has different types across calls, use 'object'.
29
29
  */
30
30
  function mergeArgument(existingArgs, arg) {
31
+ if (arg.value.type === liquid_html_parser_1.NodeTypes.NamedArgument)
32
+ return;
31
33
  const inferredType = (0, platformos_check_common_1.inferArgumentType)(arg.value);
32
34
  const existing = existingArgs.get(arg.name);
33
35
  if (existing) {
@@ -1,4 +1,4 @@
1
- import { BasicParamTypes } from '@platformos/platformos-check-common';
1
+ import { InferredParamType } from '@platformos/platformos-check-common';
2
2
  /**
3
3
  * Generate a single @param line for a doc tag.
4
4
  *
@@ -7,7 +7,7 @@ import { BasicParamTypes } from '@platformos/platformos-check-common';
7
7
  * @param isOptional - Whether to mark as optional with brackets
8
8
  * @returns A formatted @param line like "@param {string} [name]" or "@param {string} name"
9
9
  */
10
- export declare function generateParamLine(name: string, type: BasicParamTypes, isOptional?: boolean): string;
10
+ export declare function generateParamLine(name: string, type: InferredParamType, isOptional?: boolean): string;
11
11
  /**
12
12
  * Generate a complete doc tag with param lines.
13
13
  *
@@ -1,8 +1,8 @@
1
- import { BasicParamTypes } from '@platformos/platformos-check-common';
1
+ import { InferredParamType } from '@platformos/platformos-check-common';
2
2
  export type TagType = 'function' | 'render' | 'include';
3
3
  export interface ArgumentInfo {
4
4
  name: string;
5
- inferredType: BasicParamTypes;
5
+ inferredType: InferredParamType;
6
6
  usageCount: number;
7
7
  }
8
8
  export interface PartialUsage {
package/dist/cli.js CHANGED
@@ -4,24 +4,65 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
4
4
  };
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
6
  const index_1 = require("./index");
7
+ const platformos_check_common_1 = require("@platformos/platformos-check-common");
7
8
  const backfill_docs_1 = require("./backfill-docs");
8
9
  const node_path_1 = __importDefault(require("node:path"));
10
+ const validCheckNames = new Set(platformos_check_common_1.allChecks.map((c) => c.meta.code));
11
+ function parseCheckArgs(args) {
12
+ const checks = [];
13
+ const positional = [];
14
+ for (let i = 0; i < args.length; i++) {
15
+ if (args[i] === '--check' || args[i] === '-c') {
16
+ i++;
17
+ if (i < args.length)
18
+ checks.push(args[i]);
19
+ }
20
+ else {
21
+ positional.push(args[i]);
22
+ }
23
+ }
24
+ return {
25
+ root: node_path_1.default.resolve(positional[0] || '.'),
26
+ configPath: positional[1] ? node_path_1.default.resolve(positional[1]) : undefined,
27
+ checks: checks.length > 0 ? checks : undefined,
28
+ };
29
+ }
9
30
  async function runCheck(args) {
10
- const root = node_path_1.default.resolve(args[0] || '.');
11
- const configPath = args[1] ? node_path_1.default.resolve(args[1]) : undefined;
31
+ const { root, configPath, checks } = parseCheckArgs(args);
32
+ if (checks) {
33
+ const unknown = checks.filter((name) => !validCheckNames.has(name));
34
+ if (unknown.length > 0) {
35
+ const available = Array.from(validCheckNames).sort().join(', ');
36
+ console.error(`Unknown check${unknown.length > 1 ? 's' : ''}: ${unknown.join(', ')}`);
37
+ console.error(`Available checks: ${available}`);
38
+ process.exit(1);
39
+ }
40
+ }
12
41
  const { app, config, offenses } = await (0, index_1.appCheckRun)(root, configPath, console.error.bind(console));
13
- console.log(JSON.stringify(offenses, null, 2));
14
- console.log(JSON.stringify(config, null, 2));
15
- console.log(JSON.stringify(app.map((x) => x.uri), null, 2));
42
+ const filtered = checks ? offenses.filter((o) => checks.includes(o.check)) : offenses;
43
+ console.log(JSON.stringify(filtered, null, 2));
44
+ if (!checks) {
45
+ console.log(JSON.stringify(config, null, 2));
46
+ console.log(JSON.stringify(app.map((x) => x.uri), null, 2));
47
+ }
16
48
  }
17
49
  function printUsage() {
18
50
  console.log(`
19
- Usage: platformos-check [command] [options]
51
+ Usage: platformos-check [command] [options] [path] [configPath]
20
52
 
21
53
  Commands:
22
- <path> Run platformos checks on the specified path (default)
54
+ <path> Run platformos checks on the specified path (default: .)
23
55
  backfill-docs Backfill doc tags in partial files based on usage
24
56
 
57
+ Options:
58
+ --check, -c <name> Only show offenses from the named check (repeatable)
59
+ --help, -h Show this help message
60
+
61
+ Examples:
62
+ platformos-check .
63
+ platformos-check . --check MissingPage
64
+ platformos-check . -c MissingPage -c UnknownFilter
65
+
25
66
  Run 'platformos-check <command> --help' for more information on a command.
26
67
  `);
27
68
  }
@@ -0,0 +1,24 @@
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>;
@@ -0,0 +1,136 @@
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
@@ -0,0 +1 @@
1
+ export { generateDocsCommand, generateDocForFile, GenerateDocsOptions, GenerateDocsResult, } from './generate-docs';
@@ -0,0 +1,7 @@
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
@@ -115,6 +115,11 @@ pathLike) {
115
115
  if (pathLike.startsWith('platformos-check:')) {
116
116
  return pathLike;
117
117
  }
118
+ // Support legacy shorthand YAML-symbol style: ':nothing', ':recommended', ':all'
119
+ const expanded = `platformos-check${pathLike}`;
120
+ if (pathLike.startsWith(':') && types_1.ModernIdentifiers.includes(expanded)) {
121
+ return expanded;
122
+ }
118
123
  return resolvePath(root, pathLike);
119
124
  }
120
125
  /**
package/dist/index.d.ts CHANGED
@@ -5,6 +5,7 @@ export * from '@platformos/platformos-check-common';
5
5
  export * from './config/types';
6
6
  export { NodeFileSystem };
7
7
  export { runBackfillDocsCLI } from './backfill-docs';
8
+ export declare function updateDocs(log?: (msg: string) => void): Promise<void>;
8
9
  export declare const loadConfig: typeof resolveConfig;
9
10
  export type AppCheckRun = {
10
11
  app: App;
package/dist/index.js CHANGED
@@ -18,6 +18,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
18
18
  };
19
19
  Object.defineProperty(exports, "__esModule", { value: true });
20
20
  exports.runCheck = exports.loadConfig = exports.runBackfillDocsCLI = exports.NodeFileSystem = void 0;
21
+ exports.updateDocs = updateDocs;
21
22
  exports.toSourceCode = toSourceCode;
22
23
  exports.check = check;
23
24
  exports.checkAndAutofix = checkAndAutofix;
@@ -42,6 +43,9 @@ __exportStar(require("@platformos/platformos-check-common"), exports);
42
43
  __exportStar(require("./config/types"), exports);
43
44
  var backfill_docs_1 = require("./backfill-docs");
44
45
  Object.defineProperty(exports, "runBackfillDocsCLI", { enumerable: true, get: function () { return backfill_docs_1.runBackfillDocsCLI; } });
46
+ async function updateDocs(log = () => { }) {
47
+ await (0, platformos_check_docs_updater_1.downloadPlatformOSLiquidDocs)(platformos_check_docs_updater_1.root, log);
48
+ }
45
49
  const loadConfig = async (configPath, root) => {
46
50
  configPath ??= await (0, config_1.findConfigPath)(root);
47
51
  return (0, config_1.loadConfig)(configPath, root);
@@ -119,6 +123,10 @@ async function getApp(config) {
119
123
  // Generator templates, build artifacts, etc. are excluded.
120
124
  if (filePath.endsWith('.liquid') && !(0, platformos_check_common_1.isKnownLiquidFile)(filePath))
121
125
  return false;
126
+ // Only lint .graphql files that belong to a recognized platformOS GraphQL directory.
127
+ // Schema files, generator templates (e.g. ERB .graphql), etc. are excluded.
128
+ if (filePath.endsWith('.graphql') && !(0, platformos_check_common_1.isKnownGraphQLFile)(filePath))
129
+ return false;
122
130
  return true;
123
131
  }));
124
132
  const sourceCodes = await Promise.all(paths.map(toSourceCode));
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@platformos/platformos-check-node",
3
- "version": "0.0.11",
3
+ "version": "0.0.13",
4
4
  "main": "dist/index.js",
5
5
  "types": "dist/index.d.ts",
6
6
  "author": "platformOS",
@@ -33,8 +33,8 @@
33
33
  "type-check": "tsc --noEmit"
34
34
  },
35
35
  "dependencies": {
36
- "@platformos/platformos-check-common": "0.0.11",
37
- "@platformos/platformos-check-docs-updater": "0.0.11",
36
+ "@platformos/platformos-check-common": "0.0.13",
37
+ "@platformos/platformos-check-docs-updater": "0.0.13",
38
38
  "glob": "^13.0.0",
39
39
  "normalize-path": "^3.0.0",
40
40
  "vscode-uri": "^3.1.0",