@platformos/platformos-check-node 0.0.9 → 0.0.11
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/dist/backfill-docs/argument-collector.d.ts +2 -2
- package/dist/backfill-docs/argument-collector.js +5 -5
- package/dist/config/load-third-party-checks.js +7 -3
- package/dist/index.d.ts +0 -2
- package/dist/index.js +8 -7
- package/package.json +4 -3
- package/dist/commands/generate-docs.d.ts +0 -24
- package/dist/commands/generate-docs.js +0 -136
- package/dist/commands/index.d.ts +0 -1
- package/dist/commands/index.js +0 -7
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { App } from '@platformos/platformos-check-common';
|
|
2
2
|
import { PartialUsage } from './types';
|
|
3
3
|
/**
|
|
4
|
-
* Collect all partial usages from
|
|
4
|
+
* Collect all partial usages from an app by visiting function, render, and include tags.
|
|
5
5
|
*/
|
|
6
|
-
export declare function collectPartialUsages(
|
|
6
|
+
export declare function collectPartialUsages(app: App, verbose?: boolean, log?: (message: string) => void): Promise<Map<string, PartialUsage>>;
|
|
@@ -10,8 +10,8 @@ const liquid_html_parser_2 = require("@platformos/liquid-html-parser");
|
|
|
10
10
|
*/
|
|
11
11
|
function getPartialName(node) {
|
|
12
12
|
if (node.type === liquid_html_parser_1.NodeTypes.RenderMarkup) {
|
|
13
|
-
if (node.
|
|
14
|
-
return node.
|
|
13
|
+
if (node.partial.type === liquid_html_parser_1.NodeTypes.String) {
|
|
14
|
+
return node.partial.value;
|
|
15
15
|
}
|
|
16
16
|
return undefined;
|
|
17
17
|
}
|
|
@@ -63,11 +63,11 @@ function parseUsageKey(key) {
|
|
|
63
63
|
};
|
|
64
64
|
}
|
|
65
65
|
/**
|
|
66
|
-
* Collect all partial usages from
|
|
66
|
+
* Collect all partial usages from an app by visiting function, render, and include tags.
|
|
67
67
|
*/
|
|
68
|
-
async function collectPartialUsages(
|
|
68
|
+
async function collectPartialUsages(app, verbose = false, log = console.log) {
|
|
69
69
|
const usageMap = new Map();
|
|
70
|
-
for (const sourceCode of
|
|
70
|
+
for (const sourceCode of app) {
|
|
71
71
|
if (sourceCode.type !== platformos_check_common_1.SourceCodeType.LiquidHtml)
|
|
72
72
|
continue;
|
|
73
73
|
if (!(0, liquid_html_parser_2.isLiquidHtmlNode)(sourceCode.ast))
|
|
@@ -1,8 +1,12 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
2
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
6
|
exports.loadThirdPartyChecks = loadThirdPartyChecks;
|
|
4
7
|
exports.findThirdPartyChecks = findThirdPartyChecks;
|
|
5
8
|
const glob_1 = require("glob");
|
|
9
|
+
const normalize_path_1 = __importDefault(require("normalize-path"));
|
|
6
10
|
function loadThirdPartyChecks(
|
|
7
11
|
/**
|
|
8
12
|
* An array of require()-able paths.
|
|
@@ -39,8 +43,8 @@ modulePaths = []) {
|
|
|
39
43
|
}
|
|
40
44
|
async function findThirdPartyChecks(nodeModuleRoot) {
|
|
41
45
|
const paths = [
|
|
42
|
-
globJoin(
|
|
43
|
-
globJoin(
|
|
46
|
+
globJoin((0, normalize_path_1.default)(nodeModuleRoot), '/node_modules/platformos-check-*/'),
|
|
47
|
+
globJoin((0, normalize_path_1.default)(nodeModuleRoot), '/node_modules/@*/platformos-check-*/'),
|
|
44
48
|
];
|
|
45
49
|
const results = await Promise.all(paths.map((path) => (0, glob_1.glob)(path)));
|
|
46
50
|
return results
|
|
@@ -49,7 +53,7 @@ async function findThirdPartyChecks(nodeModuleRoot) {
|
|
|
49
53
|
!/platformos-check-vscode/.test(x));
|
|
50
54
|
}
|
|
51
55
|
function globJoin(...parts) {
|
|
52
|
-
return parts.flatMap((x) =>
|
|
56
|
+
return parts.flatMap((x) => (0, normalize_path_1.default)(x).replace(/\/+$/, '')).join('/');
|
|
53
57
|
}
|
|
54
58
|
function isObjLiteral(thing) {
|
|
55
59
|
return thing !== null && typeof thing === 'object';
|
package/dist/index.d.ts
CHANGED
|
@@ -23,5 +23,3 @@ export declare function getApp(config: Config): Promise<App>;
|
|
|
23
23
|
export declare function getAppFilesPathPattern(rootUri: string): string;
|
|
24
24
|
/** @deprecated Use appCheckRun instead */
|
|
25
25
|
export declare const runCheck: typeof appCheckRun;
|
|
26
|
-
/** @deprecated Use appCheckRun instead */
|
|
27
|
-
export declare const themeCheckRun: typeof appCheckRun;
|
package/dist/index.js
CHANGED
|
@@ -17,7 +17,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
17
17
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
18
18
|
};
|
|
19
19
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
20
|
-
exports.
|
|
20
|
+
exports.runCheck = exports.loadConfig = exports.runBackfillDocsCLI = exports.NodeFileSystem = void 0;
|
|
21
21
|
exports.toSourceCode = toSourceCode;
|
|
22
22
|
exports.check = check;
|
|
23
23
|
exports.checkAndAutofix = checkAndAutofix;
|
|
@@ -32,6 +32,7 @@ const promises_1 = __importDefault(require("node:fs/promises"));
|
|
|
32
32
|
const node_path_1 = __importDefault(require("node:path"));
|
|
33
33
|
const vscode_uri_1 = require("vscode-uri");
|
|
34
34
|
const glob_1 = require("glob");
|
|
35
|
+
const normalize_path_1 = __importDefault(require("normalize-path"));
|
|
35
36
|
const autofix_1 = require("./autofix");
|
|
36
37
|
const config_1 = require("./config");
|
|
37
38
|
const NodeFileSystem_1 = require("./NodeFileSystem");
|
|
@@ -106,7 +107,11 @@ async function getApp(config) {
|
|
|
106
107
|
// as mentioned in the documentation of node-glob
|
|
107
108
|
// the path is normalised and '\' are replaced with '/' and then passed to the glob function
|
|
108
109
|
let normalizedGlob = getAppFilesPathPattern(config.rootUri);
|
|
109
|
-
const paths = await (0, glob_1.glob)(normalizedGlob, { absolute: true }).then((result) => result
|
|
110
|
+
const paths = await (0, glob_1.glob)(normalizedGlob, { absolute: true }).then((result) => result
|
|
111
|
+
// Normalize backslashes to forward slashes so that isKnownLiquidFile() and
|
|
112
|
+
// isIgnored() regex/minimatch patterns (which use forward slashes) work on Windows.
|
|
113
|
+
.map(normalize_path_1.default)
|
|
114
|
+
.filter((filePath) => {
|
|
110
115
|
// Global ignored paths should not be part of the app
|
|
111
116
|
if ((0, platformos_check_common_1.isIgnored)(filePath, config))
|
|
112
117
|
return false;
|
|
@@ -120,12 +125,8 @@ async function getApp(config) {
|
|
|
120
125
|
return sourceCodes.filter((x) => x !== undefined);
|
|
121
126
|
}
|
|
122
127
|
function getAppFilesPathPattern(rootUri) {
|
|
123
|
-
return node_path_1.default
|
|
124
|
-
.normalize(node_path_1.default.join((0, node_url_1.fileURLToPath)(rootUri), '**/*.{liquid,json,graphql,yml,yaml}'))
|
|
125
|
-
.replace(/\\/g, '/');
|
|
128
|
+
return (0, normalize_path_1.default)(node_path_1.default.join((0, node_url_1.fileURLToPath)(rootUri), '**/*.{liquid,json,graphql,yml,yaml}'));
|
|
126
129
|
}
|
|
127
130
|
/** @deprecated Use appCheckRun instead */
|
|
128
131
|
exports.runCheck = appCheckRun;
|
|
129
|
-
/** @deprecated Use appCheckRun instead */
|
|
130
|
-
exports.themeCheckRun = appCheckRun;
|
|
131
132
|
//# sourceMappingURL=index.js.map
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@platformos/platformos-check-node",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.11",
|
|
4
4
|
"main": "dist/index.js",
|
|
5
5
|
"types": "dist/index.d.ts",
|
|
6
6
|
"author": "platformOS",
|
|
@@ -33,9 +33,10 @@
|
|
|
33
33
|
"type-check": "tsc --noEmit"
|
|
34
34
|
},
|
|
35
35
|
"dependencies": {
|
|
36
|
-
"@platformos/platformos-check-common": "0.0.
|
|
37
|
-
"@platformos/platformos-check-docs-updater": "0.0.
|
|
36
|
+
"@platformos/platformos-check-common": "0.0.11",
|
|
37
|
+
"@platformos/platformos-check-docs-updater": "0.0.11",
|
|
38
38
|
"glob": "^13.0.0",
|
|
39
|
+
"normalize-path": "^3.0.0",
|
|
39
40
|
"vscode-uri": "^3.1.0",
|
|
40
41
|
"yaml": "^2.8.2"
|
|
41
42
|
},
|
|
@@ -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
|
package/dist/commands/index.d.ts
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export { generateDocsCommand, generateDocForFile, GenerateDocsOptions, GenerateDocsResult, } from './generate-docs';
|
package/dist/commands/index.js
DELETED
|
@@ -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
|