@markuplint/create-rule-helper
Advanced tools
Comparing version 4.0.0-alpha.3 to 4.0.0-dev.28
import { stat } from 'node:fs/promises'; | ||
export async function fsExists(path) { | ||
const res = await stat(path).catch(e => { | ||
if (e?.code === 'ENOENT') { | ||
const res = await stat(path).catch(error => { | ||
if (error?.code === 'ENOENT') { | ||
return null; | ||
} | ||
throw e; | ||
throw error; | ||
}); | ||
return !!res; | ||
} |
@@ -46,3 +46,3 @@ import fs from 'node:fs/promises'; | ||
} | ||
await fs.writeFile(packageJson, JSON.stringify(packageContent, null, 2), { encoding: 'utf-8' }); | ||
await fs.writeFile(packageJson, JSON.stringify(packageContent, null, 2), { encoding: 'utf8' }); | ||
transferred.push({ | ||
@@ -49,0 +49,0 @@ ext: '.json', |
@@ -6,9 +6,9 @@ import fs from 'node:fs/promises'; | ||
try { | ||
const json = await fs.readFile(filePath, { encoding: 'utf-8' }); | ||
const json = await fs.readFile(filePath, { encoding: 'utf8' }); | ||
const data = JSON.parse(json); | ||
return data?.name ?? null; | ||
} | ||
catch (_) { | ||
catch { | ||
return null; | ||
} | ||
} |
@@ -28,15 +28,15 @@ import { statSync } from 'node:fs'; | ||
} | ||
let contents = await fs.readFile(file.filePath, { encoding: 'utf-8' }); | ||
let contents = await fs.readFile(file.filePath, { encoding: 'utf8' }); | ||
if (options?.replacer) { | ||
Object.entries(options?.replacer).forEach(([before, after]) => { | ||
for (const [before, after] of Object.entries(options?.replacer)) { | ||
if (!after) { | ||
return; | ||
continue; | ||
} | ||
// Hyphenation to camel-case for variables | ||
// `rule-name` => `ruleName` | ||
contents = contents.replace(new RegExp(`__${before}__c`, 'g'), | ||
contents = contents.replaceAll(new RegExp(`__${before}__c`, 'g'), | ||
// Camelize | ||
after.replace(/-+([a-z])/gi, (_, $1) => $1.toUpperCase()).replace(/^[a-z]/, $0 => $0.toLowerCase())); | ||
contents = contents.replace(new RegExp(`__${before}__`, 'g'), after); | ||
}); | ||
after.replaceAll(/-+([a-z])/gi, (_, $1) => $1.toUpperCase()).replace(/^[a-z]/, $0 => $0.toLowerCase())); | ||
contents = contents.replaceAll(new RegExp(`__${before}__`, 'g'), after); | ||
} | ||
} | ||
@@ -62,5 +62,5 @@ // Remove prettier ignore comment | ||
// Insert new line before comments and the export keyword | ||
contents = contents.replace(/(\n)(\s+\/\*\*|export)/g, '$1\n$2'); | ||
contents = contents.replaceAll(/(\n)(\s+\/\*\*|export)/g, '$1\n$2'); | ||
} | ||
const candidateName = options?.replacer?.[newFile.name.replace(/_/g, '')]; | ||
const candidateName = options?.replacer?.[newFile.name.replaceAll('_', '')]; | ||
if (candidateName) { | ||
@@ -85,3 +85,3 @@ newFile.name = candidateName; | ||
} | ||
await fs.writeFile(dest, contents, { encoding: 'utf-8' }); | ||
await fs.writeFile(dest, contents, { encoding: 'utf8' }); | ||
return newFile; | ||
@@ -88,0 +88,0 @@ } |
{ | ||
"name": "@markuplint/create-rule-helper", | ||
"version": "4.0.0-alpha.3", | ||
"version": "4.0.0-dev.28+0131de5e", | ||
"description": "Create rule helper", | ||
@@ -25,14 +25,13 @@ "repository": "git@github.com:markuplint/markuplint.git", | ||
"dependencies": { | ||
"@markuplint/ml-core": "4.0.0-alpha.3", | ||
"@markuplint/ml-core": "4.0.0-dev.28+0131de5e", | ||
"glob": "^10.3.6", | ||
"prettier": "^3.0.3", | ||
"ts-node": "^10.9.1", | ||
"tslib": "^2.6.2", | ||
"typescript": "^5.2.2" | ||
}, | ||
"devDependencies": { | ||
"@types/fs-extra": "^11.0.2", | ||
"@types/fs-extra": "^11.0.3", | ||
"fs-extra": "^11.1.1" | ||
}, | ||
"gitHead": "380836f7adc1ff7e8eaf9d869e68d29eee8f3b7e" | ||
"gitHead": "0131de5ea9dd6d3fd5472d7b414b66644c758881" | ||
} |
Manifest confusion
Supply chain riskThis package has inconsistent metadata. This could be malicious or caused by an error when publishing the package.
Found 1 instance in 1 package
27466
5
1
- Removedtslib@^2.6.2
- Removed@markuplint/config-presets@4.0.0-alpha.3(transitive)
- Removed@markuplint/html-parser@4.0.0-alpha.3(transitive)
- Removed@markuplint/html-spec@4.0.0-alpha.3(transitive)
- Removed@markuplint/i18n@4.0.0-alpha.3(transitive)
- Removed@markuplint/ml-ast@4.0.0-alpha.3(transitive)
- Removed@markuplint/ml-config@4.0.0-alpha.3(transitive)
- Removed@markuplint/ml-core@4.0.0-alpha.3(transitive)
- Removed@markuplint/ml-spec@4.0.0-alpha.3(transitive)
- Removed@markuplint/parser-utils@4.0.0-alpha.3(transitive)
- Removed@markuplint/selector@4.0.0-alpha.3(transitive)
- Removed@markuplint/shared@4.0.0-alpha.3(transitive)
- Removed@markuplint/types@4.0.0-alpha.3(transitive)
- Removed@types/bcp-47@2.0.4(transitive)
- Removed@types/css-tree@2.3.10(transitive)
- Removed@types/debug@4.1.12(transitive)
- Removed@types/ms@2.1.0(transitive)
- Removed@types/mustache@4.2.5(transitive)
- Removed@types/uuid@9.0.8(transitive)
- Removed@types/whatwg-mimetype@3.0.0(transitive)
- Removedbcp-47@2.1.0(transitive)
- Removedcss-tree@2.3.1(transitive)
- Removedcssesc@3.0.0(transitive)
- Removeddebug@4.4.0(transitive)
- Removeddeepmerge@4.3.1(transitive)
- Removeddom-accessibility-api@0.6.3(transitive)
- Removedentities@4.5.0(transitive)
- Removedhtml-entities@2.5.2(transitive)
- Removedis-alphabetical@2.0.1(transitive)
- Removedis-alphanumerical@2.0.1(transitive)
- Removedis-decimal@2.0.1(transitive)
- Removedis-plain-object@5.0.0(transitive)
- Removedleven@4.0.0(transitive)
- Removedmdn-data@2.0.30(transitive)
- Removedms@2.1.3(transitive)
- Removedmustache@4.2.0(transitive)
- Removedparse5@7.1.2(transitive)
- Removedpostcss-selector-parser@6.1.2(transitive)
- Removedsource-map-js@1.2.1(transitive)
- Removedtslib@2.8.1(transitive)
- Removedtype-fest@4.35.0(transitive)
- Removedutil-deprecate@1.0.2(transitive)
- Removeduuid@9.0.1(transitive)
- Removedwhatwg-mimetype@3.0.0(transitive)