@shopify/theme-check-node
Advanced tools
Comparing version 2.9.2 to 3.0.0
@@ -8,3 +8,3 @@ "use strict"; | ||
const updatedSource = (0, theme_check_common_1.applyFixToString)(sourceCode.source, fix); | ||
await (0, promises_1.writeFile)(sourceCode.absolutePath, updatedSource, 'utf8'); | ||
await (0, promises_1.writeFile)(theme_check_common_1.path.fsPath(sourceCode.uri), updatedSource, 'utf8'); | ||
}; | ||
@@ -11,0 +11,0 @@ exports.saveToDiskFixApplicator = saveToDiskFixApplicator; |
@@ -14,5 +14,5 @@ "use strict"; | ||
console.log(JSON.stringify(config, null, 2)); | ||
console.log(JSON.stringify(theme.map((x) => x.absolutePath), null, 2)); | ||
console.log(JSON.stringify(theme.map((x) => x.uri), null, 2)); | ||
} | ||
main(); | ||
//# sourceMappingURL=cli.js.map |
@@ -1,2 +0,3 @@ | ||
import { AbsolutePath, Config } from '@shopify/theme-check-common'; | ||
import { Config } from '@shopify/theme-check-common'; | ||
import { AbsolutePath } from '../temp'; | ||
import { ConfigDescription } from './types'; | ||
@@ -13,4 +14,4 @@ /** | ||
* @param pathLike - resolved textual value of the `root` property from the config files | ||
* @returns {string} resolved absolute path of the root property | ||
* @returns {string} resolved URI of the root property | ||
*/ | ||
export declare function resolveRoot(root: AbsolutePath, pathLike: string | undefined): string; |
@@ -38,3 +38,3 @@ "use strict"; | ||
ignore: configDescription.ignore, | ||
root: resolveRoot(root, configDescription.root), | ||
rootUri: resolveRoot(root, configDescription.root), | ||
}; | ||
@@ -46,7 +46,7 @@ } | ||
* @param pathLike - resolved textual value of the `root` property from the config files | ||
* @returns {string} resolved absolute path of the root property | ||
* @returns {string} resolved URI of the root property | ||
*/ | ||
function resolveRoot(root, pathLike) { | ||
if (pathLike === undefined) { | ||
return root; | ||
return 'file:' + root; | ||
} | ||
@@ -56,3 +56,3 @@ if (node_path_1.default.isAbsolute(pathLike)) { | ||
} | ||
return node_path_1.default.resolve(root, pathLike); | ||
return 'file:' + node_path_1.default.resolve(root, pathLike); | ||
} | ||
@@ -59,0 +59,0 @@ exports.resolveRoot = resolveRoot; |
@@ -1,2 +0,3 @@ | ||
import { AbsolutePath, Config } from '@shopify/theme-check-common'; | ||
import { Config } from '@shopify/theme-check-common'; | ||
import { AbsolutePath } from '../temp'; | ||
import { ModernIdentifier } from './types'; | ||
@@ -3,0 +4,0 @@ /** |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.loadConfig = void 0; | ||
const load_config_description_1 = require("./load-config-description"); | ||
const resolve_1 = require("./resolve"); | ||
const load_config_description_1 = require("./load-config-description"); | ||
const validation_1 = require("./validation"); | ||
@@ -7,0 +7,0 @@ /** |
@@ -1,2 +0,3 @@ | ||
import { AbsolutePath, CheckDefinition, SourceCodeType } from '@shopify/theme-check-common'; | ||
import { CheckDefinition, SourceCodeType } from '@shopify/theme-check-common'; | ||
import { AbsolutePath } from '../temp'; | ||
type ModulePath = string; | ||
@@ -3,0 +4,0 @@ export declare function loadThirdPartyChecks( |
@@ -1,2 +0,2 @@ | ||
import { AbsolutePath } from '@shopify/theme-check-common'; | ||
import { AbsolutePath } from '../../temp'; | ||
import { ConfigFragment } from '../types'; | ||
@@ -3,0 +3,0 @@ /** |
@@ -8,6 +8,6 @@ "use strict"; | ||
const theme_check_common_1 = require("@shopify/theme-check-common"); | ||
const node_fs_1 = require("node:fs"); | ||
const promises_1 = __importDefault(require("node:fs/promises")); | ||
const node_path_1 = __importDefault(require("node:path")); | ||
const yaml_1 = require("yaml"); | ||
const node_path_1 = __importDefault(require("node:path")); | ||
const promises_1 = __importDefault(require("node:fs/promises")); | ||
const node_fs_1 = require("node:fs"); | ||
const types_1 = require("../types"); | ||
@@ -14,0 +14,0 @@ class UnresolvedAliasError extends Error { |
@@ -1,3 +0,3 @@ | ||
import { AbsolutePath } from '@shopify/theme-check-common'; | ||
import { ConfigDescription, ModernIdentifier } from '../types'; | ||
import { AbsolutePath } from '../../temp'; | ||
/** | ||
@@ -4,0 +4,0 @@ * Given a modern identifier or absolute path, fully resolves and flattens |
@@ -1,3 +0,1 @@ | ||
import { Dependencies } from '@shopify/theme-check-common'; | ||
export declare function fileExists(path: string): Promise<boolean>; | ||
export declare const fileSize: NonNullable<Dependencies['fileSize']>; |
@@ -6,3 +6,3 @@ "use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.fileSize = exports.fileExists = void 0; | ||
exports.fileExists = void 0; | ||
const promises_1 = __importDefault(require("node:fs/promises")); | ||
@@ -19,15 +19,2 @@ async function fileExists(path) { | ||
exports.fileExists = fileExists; | ||
const fileSize = async (path) => { | ||
try { | ||
const stats = await promises_1.default.stat(path); | ||
return stats.size; | ||
} | ||
catch (error) { | ||
if (process.env.SHOPIFY_FLAG_VERBOSE || process.argv.includes('--verbose')) { | ||
console.error(`Failed to get file size: ${error}`); | ||
} | ||
return 0; | ||
} | ||
}; | ||
exports.fileSize = fileSize; | ||
//# sourceMappingURL=file-utils.js.map |
import { Config, JSONSourceCode, LiquidSourceCode, Offense, Theme } from '@shopify/theme-check-common'; | ||
import { loadConfig as resolveConfig } from './config'; | ||
import { NodeFileSystem } from './NodeFileSystem'; | ||
export * from '@shopify/theme-check-common'; | ||
export * from './config/types'; | ||
export { PathHandler, findRoot, reusableFindRoot } from './find-root'; | ||
export { NodeFileSystem }; | ||
export declare const loadConfig: typeof resolveConfig; | ||
@@ -7,0 +8,0 @@ export type ThemeCheckRun = { |
@@ -20,3 +20,3 @@ "use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.getTheme = exports.themeCheckRun = exports.checkAndAutofix = exports.check = exports.toSourceCode = exports.loadConfig = exports.reusableFindRoot = exports.findRoot = void 0; | ||
exports.getTheme = exports.themeCheckRun = exports.checkAndAutofix = exports.check = exports.toSourceCode = exports.loadConfig = exports.NodeFileSystem = void 0; | ||
const theme_check_common_1 = require("@shopify/theme-check-common"); | ||
@@ -27,13 +27,11 @@ const theme_check_docs_updater_1 = require("@shopify/theme-check-docs-updater"); | ||
const node_util_1 = require("node:util"); | ||
const vscode_uri_1 = require("vscode-uri"); | ||
const glob = require("glob"); | ||
const autofix_1 = require("./autofix"); | ||
const config_1 = require("./config"); | ||
const file_utils_1 = require("./file-utils"); | ||
const defaultLocale = 'en'; | ||
const NodeFileSystem_1 = require("./NodeFileSystem"); | ||
Object.defineProperty(exports, "NodeFileSystem", { enumerable: true, get: function () { return NodeFileSystem_1.NodeFileSystem; } }); | ||
const asyncGlob = (0, node_util_1.promisify)(glob); | ||
__exportStar(require("@shopify/theme-check-common"), exports); | ||
__exportStar(require("./config/types"), exports); | ||
var find_root_1 = require("./find-root"); | ||
Object.defineProperty(exports, "findRoot", { enumerable: true, get: function () { return find_root_1.findRoot; } }); | ||
Object.defineProperty(exports, "reusableFindRoot", { enumerable: true, get: function () { return find_root_1.reusableFindRoot; } }); | ||
const loadConfig = async (configPath, root) => { | ||
@@ -47,3 +45,3 @@ configPath !== null && configPath !== void 0 ? configPath : (configPath = await (0, config_1.findConfigPath)(root)); | ||
const source = await promises_1.default.readFile(absolutePath, 'utf8'); | ||
return (0, theme_check_common_1.toSourceCode)(absolutePath, source); | ||
return (0, theme_check_common_1.toSourceCode)(theme_check_common_1.path.normalize(vscode_uri_1.URI.file(absolutePath)), source); | ||
} | ||
@@ -66,34 +64,8 @@ catch (e) { | ||
async function themeCheckRun(root, configPath, log = () => { }) { | ||
var _a, _b; | ||
const { theme, config } = await getThemeAndConfig(root, configPath); | ||
const defaultTranslationsFile = theme.find((sc) => sc.absolutePath.endsWith('default.json')); | ||
const defaultTranslations = (0, theme_check_common_1.parseJSON)((_a = defaultTranslationsFile === null || defaultTranslationsFile === void 0 ? void 0 : defaultTranslationsFile.source) !== null && _a !== void 0 ? _a : '{}', {}); | ||
const defaultSchemaTranslationsFile = theme.find((sc) => sc.absolutePath.endsWith('default.schema.json')); | ||
const defaultSchemaTranslations = (0, theme_check_common_1.parseJSON)((_b = defaultSchemaTranslationsFile === null || defaultSchemaTranslationsFile === void 0 ? void 0 : defaultSchemaTranslationsFile.source) !== null && _b !== void 0 ? _b : '{}', {}); | ||
const themeLiquidDocsManager = new theme_check_docs_updater_1.ThemeLiquidDocsManager(log); | ||
const offenses = await (0, theme_check_common_1.check)(theme, config, { | ||
fileExists: file_utils_1.fileExists, | ||
fileSize: file_utils_1.fileSize, | ||
fs: NodeFileSystem_1.NodeFileSystem, | ||
themeDocset: themeLiquidDocsManager, | ||
jsonValidationSet: themeLiquidDocsManager, | ||
getDefaultTranslations: async () => defaultTranslations, | ||
getDefaultLocale: async () => { | ||
var _a; | ||
if (!defaultTranslationsFile) { | ||
return defaultLocale; | ||
} | ||
// assumes the path is normalized and '/' are used as separators | ||
const defaultTranslationsFileLocale = (_a = defaultTranslationsFile.absolutePath.match(/locales\/(.*)\.default\.json$/)) === null || _a === void 0 ? void 0 : _a[1]; | ||
return defaultTranslationsFileLocale || defaultLocale; | ||
}, | ||
getDefaultSchemaTranslations: async () => defaultSchemaTranslations, | ||
getDefaultSchemaLocale: async () => { | ||
var _a; | ||
if (!defaultSchemaTranslationsFile) { | ||
return defaultLocale; | ||
} | ||
// assumes the path is normalized and '/' are used as separators | ||
const defaultTranslationsFileLocale = (_a = defaultSchemaTranslationsFile.absolutePath.match(/locales\/(.*)\.default\.schema\.json$/)) === null || _a === void 0 ? void 0 : _a[1]; | ||
return defaultTranslationsFileLocale || defaultLocale; | ||
}, | ||
}); | ||
@@ -121,3 +93,3 @@ return { | ||
const normalizedGlob = node_path_1.default | ||
.normalize(node_path_1.default.join(config.root, '**/*.{liquid,json}')) | ||
.normalize(node_path_1.default.join(config.rootUri.replace(/^file:/, ''), '**/*.{liquid,json}')) | ||
.replace(/\\/g, '/'); | ||
@@ -124,0 +96,0 @@ const paths = await asyncGlob(normalizedGlob).then((result) => |
@@ -10,6 +10,6 @@ export declare function makeTmpFolder(): Promise<string>; | ||
export interface Workspace { | ||
root: string; | ||
path(relativePath: string): string; | ||
rootUri: string; | ||
uri(relativePath: string): string; | ||
clean(): Promise<any>; | ||
} | ||
export declare function makeTempWorkspace(structure: Tree): Promise<Workspace>; |
@@ -34,2 +34,3 @@ "use strict"; | ||
const node_path_1 = __importDefault(require("node:path")); | ||
const theme_check_common_1 = require("@shopify/theme-check-common"); | ||
async function makeTmpFolder() { | ||
@@ -87,5 +88,6 @@ const tmpDir = await promises_1.default.mkdtemp(node_path_1.default.join(node_os_1.default.tmpdir(), 'test-')); | ||
await createFiles(structure, [root]); | ||
const rootUri = theme_check_common_1.path.normalize('file:' + root); | ||
return { | ||
root, | ||
path: (relativePath) => node_path_1.default.join(root, ...relativePath.split('/')), | ||
rootUri: 'file:' + root, | ||
uri: (relativePath) => theme_check_common_1.path.join(rootUri, ...relativePath.split('/')), | ||
clean: async () => promises_1.default.rm(root, { recursive: true, force: true }), | ||
@@ -92,0 +94,0 @@ }; |
{ | ||
"name": "@shopify/theme-check-node", | ||
"version": "2.9.2", | ||
"version": "3.0.0", | ||
"main": "dist/index.js", | ||
@@ -36,5 +36,6 @@ "types": "dist/index.d.ts", | ||
"dependencies": { | ||
"@shopify/theme-check-common": "2.9.2", | ||
"@shopify/theme-check-docs-updater": "2.9.2", | ||
"@shopify/theme-check-common": "3.0.0", | ||
"@shopify/theme-check-docs-updater": "3.0.0", | ||
"glob": "^8.0.3", | ||
"vscode-uri": "^3.0.7", | ||
"yaml": "^2.3.0" | ||
@@ -41,0 +42,0 @@ }, |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Environment variable access
Supply chain riskPackage accesses environment variables, which may be a sign of credential stuffing or data theft.
Found 1 instance in 1 package
46
5
53233
5
1118
+ Addedvscode-uri@^3.0.7
+ Added@shopify/theme-check-common@3.0.0(transitive)
+ Added@shopify/theme-check-docs-updater@3.0.0(transitive)
- Removed@shopify/theme-check-common@2.9.2(transitive)
- Removed@shopify/theme-check-docs-updater@2.9.2(transitive)