@w5s/dev 2.2.7 → 2.2.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/index.cjs +332 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.cts +299 -0
- package/dist/index.d.ts +299 -8
- package/dist/index.js +320 -22
- package/dist/index.js.map +1 -1
- package/package.json +13 -4
- package/dist/block.d.ts +0 -45
- package/dist/block.js +0 -110
- package/dist/block.js.map +0 -1
- package/dist/directory.d.ts +0 -39
- package/dist/directory.js +0 -66
- package/dist/directory.js.map +0 -1
- package/dist/eslint.d.ts +0 -15
- package/dist/eslint.js +0 -56
- package/dist/eslint.js.map +0 -1
- package/dist/file.d.ts +0 -51
- package/dist/file.js +0 -81
- package/dist/file.js.map +0 -1
- package/dist/json.d.ts +0 -36
- package/dist/json.js +0 -33
- package/dist/json.js.map +0 -1
- package/dist/project.d.ts +0 -89
- package/dist/project.js +0 -132
- package/dist/project.js.map +0 -1
- package/dist/projectScript.d.ts +0 -22
- package/dist/projectScript.js +0 -24
- package/dist/projectScript.js.map +0 -1
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,iDAA+B;AAC/B,8CAA4B;AAC5B,6CAA2B;AAC3B,4CAA0B;AAC1B,4CAA0B;AAC1B,+CAA6B;AAC7B,qDAAmC"}
|
|
1
|
+
{"version":3,"sources":["../src/directory.ts","../src/eslint.ts","../src/file.ts","../src/block.ts","../src/json.ts","../src/project.ts","../src/projectScript.ts"],"names":["ESLintConfig","exists","access","constants","existsSync","rm","rmSync","Project"],"mappings":";;;;AAGA,eAAe,OAAO,IAAc,EAAA;AAClC,EAAI,IAAA;AACF,IAAM,MAAA,MAAA,CAAO,IAAM,EAAA,SAAA,CAAU,IAAI,CAAA,CAAA;AACjC,IAAO,OAAA,IAAA,CAA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AAA,CAAA;AAAA,GACrE;AAFO,EAAAA,QAAS,CAAA,gBAAA,GAAA,gBAAA,CAAA;AAAA,CAnJD,EAAA,OAAA,KAAA,OAAA,GAAA,EAAA,CAAA,CAAA,CAAA;;;ACDV,IAAM,aAAgB,GAAA;AAAA,EAC3B,KAAO,EAAA,OAAA;AAAA,EACP,KAAO,EAAA,OAAA;AAAA,EACP,YAAc,EAAA,eAAA;AAAA,EACd,QAAU,EAAA,UAAA;AAAA,EACV,OAAS,EAAA,SAAA;AAAA,EACT,IAAM,EAAA,MAAA;AAAA,EACN,MAAQ,EAAA,QAAA;AAAA,EACR,OAAS,EAAA,SAAA;AAAA,EACT,IAAM,EAAA,MAAA;AAAA,EACN,OAAS,EAAA,SAAA;AAAA,EACT,OAAS,EAAA,SAAA;AAAA,EACT,MAAQ,EAAA,QAAA;AAAA,EACR,UAAY,EAAA,YAAA;AAAA,EACZ,IAAM,EAAA,MAAA;AAAA,EACN,QAAU,EAAA,UAAA;AACZ","file":"index.js","sourcesContent":["import { existsSync, mkdirSync, rmSync } from 'node:fs';\nimport { access, constants, mkdir, rm } from 'node:fs/promises';\n\nasync function exists(path: string) {\n try {\n await access(path, constants.F_OK);\n return true;\n } catch {\n return false;\n }\n}\n\nexport interface DirectoryOptions {\n /**\n * Directory path\n */\n readonly path: string;\n /**\n * Directory target state\n */\n readonly state: 'present' | 'absent';\n}\n\n/**\n * Ensure directory is present/absent\n *\n * @example\n * ```ts\n * await directory({\n * path: 'foo/bar',\n * state: 'present',\n * })\n * ```\n *\n * @param options\n */\nexport async function directory(options: DirectoryOptions): Promise<void> {\n const { path, state } = options;\n const isPresent = await exists(path);\n if (state === 'present') {\n if (!isPresent) {\n await mkdir(path, { recursive: true });\n }\n } else if (isPresent) {\n await rm(path, { recursive: true });\n }\n}\n\n/**\n * Ensure directory is present/absent\n *\n * @example\n * ```ts\n * await directorySync({\n * path: 'foo/bar',\n * state: 'present',\n * })\n * ```\n *\n * @param options\n */\nexport function directorySync(options: DirectoryOptions): void {\n const { path, state } = options;\n const isPresent = existsSync(path);\n if (state === 'present') {\n if (!isPresent) {\n mkdirSync(path, { recursive: true });\n }\n } else if (isPresent) {\n rmSync(path, { recursive: true });\n }\n}\n","import type { ESLint, Linter } from 'eslint';\n\nfunction toArray<T>(value: T[] | T | undefined): T[] {\n if (value == null) {\n return [];\n }\n if (Array.isArray(value)) {\n return value;\n }\n return [value];\n}\n\nfunction concatArray<T>(left: T[] | T | undefined, right: T[] | T | undefined): T[] {\n return toArray(left).concat(toArray(right));\n}\n\nexport namespace ESLintConfig {\n /**\n *\n * @param configs\n */\n export function concat(...configs: ESLint.ConfigData[]): ESLint.ConfigData {\n return configs.reduce(\n (returnValue, config) => ({\n ...returnValue,\n ...config,\n env: { ...returnValue.env, ...config.env },\n extends: concatArray(returnValue.extends, config.extends),\n globals: { ...returnValue.globals, ...config.globals },\n overrides: concatArray(returnValue.overrides, config.overrides),\n parserOptions: { ...returnValue.parserOptions, ...config.parserOptions },\n plugins: concatArray(returnValue.plugins, config.plugins),\n rules: { ...returnValue.rules, ...config.rules },\n settings: { ...returnValue.settings, ...config.settings },\n }),\n {\n env: {},\n extends: [],\n globals: {},\n overrides: [],\n parserOptions: {},\n plugins: [],\n rules: {},\n settings: {},\n }\n );\n }\n\n /**\n * Always return 'off'. `_status` is the previous rule value.\n *\n * @param _status\n */\n export function fixme(_status: Linter.RuleLevel | [Linter.RuleLevel, ...any[]] | undefined) {\n return 'off' as const;\n }\n}\n","import { readFile, rm, writeFile, access } from 'node:fs/promises';\nimport { accessSync, constants, readFileSync, rmSync, writeFileSync } from 'node:fs';\n\nasync function exists(path: string) {\n try {\n await access(path, constants.F_OK);\n return true;\n } catch {\n return false;\n }\n}\n\nfunction existsSync(path: string) {\n try {\n accessSync(path, constants.F_OK);\n return true;\n } catch {\n return false;\n }\n}\n\nexport interface FileOptions {\n /**\n * File path\n */\n readonly path: string;\n /**\n * File target state\n */\n readonly state: 'present' | 'absent';\n /**\n * File content mapping function\n *\n * @param content\n */\n readonly update?: (content: string) => string | undefined;\n /**\n * File encoding\n */\n readonly encoding?: BufferEncoding;\n}\n\n/**\n * Ensure file is present/absent with content initialized or modified with `update\n *\n * @example\n * ```ts\n * await file({\n * path: 'foo/bar',\n * state: 'present',\n * update: (content) => content + '_test', // This will append '_test' after current content\n * })\n * ```\n *\n * @param options\n */\nexport async function file(options: FileOptions): Promise<void> {\n const { path, state, update, encoding = 'utf8' } = options;\n if (state === 'present') {\n const isPresent = await exists(path);\n const previousContent = isPresent ? await readFile(path, encoding) : '';\n const newContent = update == null ? '' : update(previousContent);\n if (newContent != null) {\n await writeFile(path, newContent, encoding);\n }\n } else {\n await rm(path, { force: true });\n }\n}\n\n/**\n * Ensure file is present/absent with content initialized or modified with `update\n *\n * @example\n * ```ts\n * fileSync({\n * path: 'foo/bar',\n * state: 'present',\n * update: (content) => content + '_test', // This will append '_test' after current content\n * })\n * ```\n *\n * @param options\n */\nexport function fileSync(options: FileOptions): void {\n const { path, state, update, encoding = 'utf8' } = options;\n if (state === 'present') {\n const isPresent = existsSync(path);\n const previousContent = isPresent ? readFileSync(path, encoding) : '';\n const newContent = update == null ? '' : update(previousContent);\n if (newContent != null) {\n writeFileSync(path, newContent, encoding);\n }\n } else {\n rmSync(path, { force: true });\n }\n}\n","import { type FileOptions, file, fileSync } from './file.js';\n\nexport interface BlockOptions {\n /**\n * The marker builder function that will take either `markerBegin` or `markerEnd`\n *\n * @default '# ${mark} MANAGED BLOCK'\n */\n marker?: (mark: 'Begin' | 'End') => string;\n /**\n * File path\n */\n path: string;\n /**\n * Block content to insert\n */\n block: string;\n /**\n * Insert position\n */\n insertPosition?: ['before', 'BeginningOfFile' | RegExp] | ['after', 'EndOfFile' | RegExp];\n /**\n * Block target state\n */\n state?: 'present' | 'absent';\n}\n\nconst EOF = 'EndOfFile';\nconst BOF = 'BeginningOfFile';\nconst insertAt = (str: string, index: number, toInsert: string) => str.slice(0, index) + toInsert + str.slice(index);\nconst matchLast = (string: string, regexp: RegExp) => {\n const matcher = new RegExp(regexp.source, `${regexp.flags}g`);\n let firstIndex = -1;\n let lastIndex = -1;\n let matches;\n // eslint-disable-next-line @typescript-eslint/no-unnecessary-condition, no-constant-condition\n while (true) {\n matches = matcher.exec(string);\n if (matches == null) {\n break;\n }\n firstIndex = matches.index;\n lastIndex = matcher.lastIndex;\n }\n return { firstIndex, lastIndex };\n};\n\nfunction toFileOptions(options: BlockOptions): FileOptions {\n const {\n marker = (mark) => `# ${mark.toUpperCase()} MANAGED BLOCK`,\n path,\n block: blockName,\n insertPosition = ['after', EOF],\n state = 'present',\n } = options;\n\n const EOL = '\\n';\n const beginBlock = marker('Begin');\n const endBlock = marker('End');\n\n /**\n * @param content\n */\n function findBlock(content: string) {\n const startIndex = content.indexOf(beginBlock);\n const endIndex = content.indexOf(endBlock) + endBlock.length;\n\n return {\n endIndex,\n exists: startIndex >= 0 && endIndex >= 0,\n startIndex,\n };\n }\n\n function apply(fullContent: string, blockContent: string) {\n const found = findBlock(fullContent);\n const remove = state === 'absent';\n const replaceBlock = remove ? '' : beginBlock + EOL + blockContent + EOL + endBlock;\n const [positionDirection, positionAnchor] = insertPosition;\n\n if (found.exists) {\n return fullContent.slice(0, found.startIndex) + replaceBlock + fullContent.slice(found.endIndex);\n }\n if (remove) {\n return fullContent;\n }\n switch (positionDirection) {\n case 'before': {\n if (positionAnchor !== BOF) {\n const { firstIndex } = matchLast(fullContent, positionAnchor);\n if (firstIndex >= 0) {\n return insertAt(fullContent, firstIndex, replaceBlock + EOL);\n }\n }\n\n // Beginning of file\n return replaceBlock + EOL + fullContent;\n }\n case 'after': {\n // insert\n if (positionAnchor !== EOF) {\n const { lastIndex } = matchLast(fullContent, positionAnchor);\n if (lastIndex >= 0) {\n return insertAt(fullContent, lastIndex, EOL + replaceBlock);\n }\n }\n\n // end of file\n return fullContent + EOL + replaceBlock;\n }\n\n default: {\n throw new Error(`Unsupported position ${String(positionDirection)}`);\n }\n }\n }\n\n return {\n path,\n state: 'present',\n update: (sourceContent) => apply(sourceContent, blockName),\n };\n}\n\n/**\n * Replace asynchronously a block in file that follows pattern :\n *\n * marker(markerBegin)\n * ...\n * marker(markerEnd)\n *\n * @param options\n */\nexport function block(options: BlockOptions) {\n return file(toFileOptions(options));\n}\n\n/**\n * Replace synchronously a block in file that follows pattern :\n *\n * marker(markerBegin)\n * ...\n * marker(markerEnd)\n *\n * @param options\n */\nexport function blockSync(options: BlockOptions) {\n return fileSync(toFileOptions(options));\n}\n","import { type FileOptions, file, fileSync } from './file.js';\n\nexport type JSONValue = null | number | string | boolean | JSONValue[] | { [key: string]: JSONValue };\n\nexport interface JSONOption<V = JSONValue> {\n /**\n * File path\n */\n readonly path: string;\n /**\n * File target state\n */\n readonly state: 'present' | 'absent';\n /**\n * File content mapping function\n *\n * @param content\n */\n readonly update?: (content: V | undefined) => V | undefined;\n /**\n * File encoding\n */\n readonly encoding?: BufferEncoding;\n}\n\nfunction toFileOption<Value>({ update, ...otherOptions }: JSONOption<Value>): FileOptions {\n return {\n ...otherOptions,\n\n update:\n update == null\n ? update\n : (content) => {\n const jsonValue = content === '' ? undefined : (JSON.parse(content) as Value);\n\n return JSON.stringify(update(jsonValue));\n },\n };\n}\n\n/**\n * Ensure file is present/absent asynchronously with content value initialized or modified with `update`\n *\n * @param options\n */\nexport async function json<Value>(options: JSONOption<Value>): Promise<void> {\n return file(toFileOption(options));\n}\n\n/**\n * Ensure file is present/absent synchronously with content value initialized or modified with `update`\n *\n * @param options\n */\nexport function jsonSync<Value>(options: JSONOption<Value>): void {\n return fileSync(toFileOption(options));\n}\n","function escapeRegExp(value: string) {\n return value.replaceAll(/[$()*+.?[\\\\\\]^{|}]/g, '\\\\$&'); // $& means the whole matched string\n}\n\nexport namespace Project {\n /**\n * A type of a file extension\n */\n export type Extension = `.${string}`;\n\n /**\n * Object hash of all well-known file extension category to file extensions mapping\n */\n export interface ExtensionRegistry {\n graphql: readonly Extension[];\n jpeg: readonly Extension[];\n javascript: readonly Extension[];\n javascriptreact: readonly Extension[];\n typescript: readonly Extension[];\n typescriptreact: readonly Extension[];\n yaml: readonly Extension[];\n }\n\n /**\n * A list of \"vscode-like\" language identifiers (i.e. \"javascript\", \"javascriptreact\")\n */\n export type LanguageId = keyof ExtensionRegistry;\n\n /**\n * Supported ECMA version\n *\n * @example\n * ```ts\n * Project.ecmaVersion() // 2022\n * ```\n */\n export function ecmaVersion() {\n return 2022 as const;\n }\n\n const registry: ExtensionRegistry = {\n graphql: ['.gql', '.graphql'],\n jpeg: ['.jpg', '.jpeg'],\n javascript: ['.js', '.cjs', '.mjs'],\n javascriptreact: ['.jsx'],\n typescript: ['.ts', '.cts', '.mts'],\n typescriptreact: ['.tsx'],\n yaml: ['.yaml', '.yml'],\n };\n\n /**\n * Return a list of extensions\n *\n * @example\n * ```ts\n * Project.queryExtensions(['javascript']); // ['.js', '.cjs', ...]\n * Project.queryExtensions(['typescript', 'typescriptreact']); // ['.ts', '.mts', ..., '.tsx']\n * ```\n *\n * @param languages\n */\n export function queryExtensions(languages: LanguageId[]): readonly Extension[] {\n return languages\n .reduce<Extension[]>(\n // eslint-disable-next-line @typescript-eslint/no-unnecessary-condition\n (previousValue, currentValue) => previousValue.concat(registry[currentValue] ?? ([] as Extension[])),\n []\n )\n .sort();\n }\n\n /**\n * Supported file extensions\n *\n * @example\n * ```ts\n * Project.sourceExtensions() // ['.ts', '.js', ...]\n * ```\n */\n export function sourceExtensions() {\n return queryExtensions(['javascript', 'javascriptreact', 'typescript', 'typescriptreact']);\n }\n\n const RESOURCE_EXTENSIONS: readonly Extension[] = Object.freeze([\n '.css',\n '.sass',\n '.scss',\n '.less',\n '.gif',\n '.png',\n '.svg',\n ...queryExtensions(['graphql', 'jpeg', 'yaml']),\n ]);\n\n /**\n * Resource file extensions\n *\n * @example\n * ```ts\n * Project.resourceExtensions() // ['.css', '.sass', ...]\n * ```\n */\n export function resourceExtensions() {\n return RESOURCE_EXTENSIONS;\n }\n\n const IGNORED = Object.freeze([\n 'node_modules/',\n 'build/',\n 'cjs/',\n 'coverage/',\n 'dist/',\n 'dts/',\n 'esm/',\n 'lib/',\n 'mjs/',\n 'umd/',\n ]);\n\n /**\n * Files and folders to always ignore\n *\n * @example\n * ```ts\n * IGNORED // ['node_modules/', 'build/', ...]\n * ```\n */\n export function ignored() {\n return IGNORED;\n }\n\n /**\n * Return a RegExp that will match any list of extensions\n *\n * @example\n * ```ts\n * Project.extensionsToMatcher(['.js', '.ts']) // RegExp = /(\\.js|\\.ts)$/\n * ```\n */\n export function extensionsToMatcher(extensions: readonly Extension[]): RegExp {\n return new RegExp(`(${extensions.map(escapeRegExp).join('|')})$`);\n }\n\n /**\n * Return a glob matcher that will match any list of extensions\n *\n * @example\n * ```ts\n * Project.extensionsToGlob(['.js', '.ts']) // '*.+(js|ts)'\n * ```\n */\n export function extensionsToGlob(extensions: readonly Extension[]): string {\n return `*.+(${extensions.map((_) => _.replace(/^\\./, '')).join('|')})`;\n }\n}\n","/**\n * Project common scripts\n */\nexport const ProjectScript = {\n Build: 'build',\n Clean: 'clean',\n CodeAnalysis: 'code-analysis',\n Coverage: 'coverage',\n Develop: 'develop',\n Docs: 'docs',\n Format: 'format',\n Install: 'install',\n Lint: 'lint',\n Prepare: 'prepare',\n Release: 'release',\n Rescue: 'rescue',\n Spellcheck: 'spellcheck',\n Test: 'test',\n Validate: 'validate',\n} as const;\nexport type ProjectScript = (typeof ProjectScript)[keyof typeof ProjectScript];\n"]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@w5s/dev",
|
|
3
|
-
"version": "2.2.
|
|
3
|
+
"version": "2.2.11",
|
|
4
4
|
"description": "Shared development constants and functions",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"config",
|
|
@@ -17,9 +17,18 @@
|
|
|
17
17
|
},
|
|
18
18
|
"license": "MIT",
|
|
19
19
|
"author": "Julien Polo <julien.polo@gmail.com>",
|
|
20
|
-
"type": "
|
|
20
|
+
"type": "module",
|
|
21
21
|
"exports": {
|
|
22
|
-
".":
|
|
22
|
+
".": {
|
|
23
|
+
"require": {
|
|
24
|
+
"types": "./dist/index.d.cts",
|
|
25
|
+
"default": "./dist/index.cjs"
|
|
26
|
+
},
|
|
27
|
+
"import": {
|
|
28
|
+
"types": "./dist/index.d.ts",
|
|
29
|
+
"default": "./dist/index.js"
|
|
30
|
+
}
|
|
31
|
+
},
|
|
23
32
|
"./dist/*": "./dist/*"
|
|
24
33
|
},
|
|
25
34
|
"typings": "./index.d.ts",
|
|
@@ -44,5 +53,5 @@
|
|
|
44
53
|
"publishConfig": {
|
|
45
54
|
"access": "public"
|
|
46
55
|
},
|
|
47
|
-
"gitHead": "
|
|
56
|
+
"gitHead": "966ebbb065df3e68092eb80c3ff2c15858989edb"
|
|
48
57
|
}
|
package/dist/block.d.ts
DELETED
|
@@ -1,45 +0,0 @@
|
|
|
1
|
-
export interface BlockOptions {
|
|
2
|
-
/**
|
|
3
|
-
* The marker builder function that will take either `markerBegin` or `markerEnd`
|
|
4
|
-
*
|
|
5
|
-
* @default '# ${mark} MANAGED BLOCK'
|
|
6
|
-
*/
|
|
7
|
-
marker?: (mark: 'Begin' | 'End') => string;
|
|
8
|
-
/**
|
|
9
|
-
* File path
|
|
10
|
-
*/
|
|
11
|
-
path: string;
|
|
12
|
-
/**
|
|
13
|
-
* Block content to insert
|
|
14
|
-
*/
|
|
15
|
-
block: string;
|
|
16
|
-
/**
|
|
17
|
-
* Insert position
|
|
18
|
-
*/
|
|
19
|
-
insertPosition?: ['before', 'BeginningOfFile' | RegExp] | ['after', 'EndOfFile' | RegExp];
|
|
20
|
-
/**
|
|
21
|
-
* Block target state
|
|
22
|
-
*/
|
|
23
|
-
state?: 'present' | 'absent';
|
|
24
|
-
}
|
|
25
|
-
/**
|
|
26
|
-
* Replace asynchronously a block in file that follows pattern :
|
|
27
|
-
*
|
|
28
|
-
* marker(markerBegin)
|
|
29
|
-
* ...
|
|
30
|
-
* marker(markerEnd)
|
|
31
|
-
*
|
|
32
|
-
* @param options
|
|
33
|
-
*/
|
|
34
|
-
export declare function block(options: BlockOptions): Promise<void>;
|
|
35
|
-
/**
|
|
36
|
-
* Replace synchronously a block in file that follows pattern :
|
|
37
|
-
*
|
|
38
|
-
* marker(markerBegin)
|
|
39
|
-
* ...
|
|
40
|
-
* marker(markerEnd)
|
|
41
|
-
*
|
|
42
|
-
* @param options
|
|
43
|
-
*/
|
|
44
|
-
export declare function blockSync(options: BlockOptions): void;
|
|
45
|
-
//# sourceMappingURL=block.d.ts.map
|
package/dist/block.js
DELETED
|
@@ -1,110 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.block = block;
|
|
4
|
-
exports.blockSync = blockSync;
|
|
5
|
-
const file_js_1 = require("./file.js");
|
|
6
|
-
const EOF = 'EndOfFile';
|
|
7
|
-
const BOF = 'BeginningOfFile';
|
|
8
|
-
const insertAt = (str, index, toInsert) => str.slice(0, index) + toInsert + str.slice(index);
|
|
9
|
-
const matchLast = (string, regexp) => {
|
|
10
|
-
const matcher = new RegExp(regexp.source, `${regexp.flags}g`);
|
|
11
|
-
let firstIndex = -1;
|
|
12
|
-
let lastIndex = -1;
|
|
13
|
-
let matches;
|
|
14
|
-
// eslint-disable-next-line @typescript-eslint/no-unnecessary-condition, no-constant-condition
|
|
15
|
-
while (true) {
|
|
16
|
-
matches = matcher.exec(string);
|
|
17
|
-
if (matches == null) {
|
|
18
|
-
break;
|
|
19
|
-
}
|
|
20
|
-
firstIndex = matches.index;
|
|
21
|
-
lastIndex = matcher.lastIndex;
|
|
22
|
-
}
|
|
23
|
-
return { firstIndex, lastIndex };
|
|
24
|
-
};
|
|
25
|
-
function toFileOptions(options) {
|
|
26
|
-
const { marker = (mark) => `# ${mark.toUpperCase()} MANAGED BLOCK`, path, block: blockName, insertPosition = ['after', EOF], state = 'present', } = options;
|
|
27
|
-
const EOL = '\n';
|
|
28
|
-
const beginBlock = marker('Begin');
|
|
29
|
-
const endBlock = marker('End');
|
|
30
|
-
/**
|
|
31
|
-
* @param content
|
|
32
|
-
*/
|
|
33
|
-
function findBlock(content) {
|
|
34
|
-
const startIndex = content.indexOf(beginBlock);
|
|
35
|
-
const endIndex = content.indexOf(endBlock) + endBlock.length;
|
|
36
|
-
return {
|
|
37
|
-
endIndex,
|
|
38
|
-
exists: startIndex >= 0 && endIndex >= 0,
|
|
39
|
-
startIndex,
|
|
40
|
-
};
|
|
41
|
-
}
|
|
42
|
-
function apply(fullContent, blockContent) {
|
|
43
|
-
const found = findBlock(fullContent);
|
|
44
|
-
const remove = state === 'absent';
|
|
45
|
-
const replaceBlock = remove ? '' : beginBlock + EOL + blockContent + EOL + endBlock;
|
|
46
|
-
const [positionDirection, positionAnchor] = insertPosition;
|
|
47
|
-
if (found.exists) {
|
|
48
|
-
return fullContent.slice(0, found.startIndex) + replaceBlock + fullContent.slice(found.endIndex);
|
|
49
|
-
}
|
|
50
|
-
if (remove) {
|
|
51
|
-
return fullContent;
|
|
52
|
-
}
|
|
53
|
-
switch (positionDirection) {
|
|
54
|
-
case 'before': {
|
|
55
|
-
if (positionAnchor !== BOF) {
|
|
56
|
-
const { firstIndex } = matchLast(fullContent, positionAnchor);
|
|
57
|
-
if (firstIndex >= 0) {
|
|
58
|
-
return insertAt(fullContent, firstIndex, replaceBlock + EOL);
|
|
59
|
-
}
|
|
60
|
-
}
|
|
61
|
-
// Beginning of file
|
|
62
|
-
return replaceBlock + EOL + fullContent;
|
|
63
|
-
}
|
|
64
|
-
case 'after': {
|
|
65
|
-
// insert
|
|
66
|
-
if (positionAnchor !== EOF) {
|
|
67
|
-
const { lastIndex } = matchLast(fullContent, positionAnchor);
|
|
68
|
-
if (lastIndex >= 0) {
|
|
69
|
-
return insertAt(fullContent, lastIndex, EOL + replaceBlock);
|
|
70
|
-
}
|
|
71
|
-
}
|
|
72
|
-
// end of file
|
|
73
|
-
return fullContent + EOL + replaceBlock;
|
|
74
|
-
}
|
|
75
|
-
default: {
|
|
76
|
-
throw new Error(`Unsupported position ${String(positionDirection)}`);
|
|
77
|
-
}
|
|
78
|
-
}
|
|
79
|
-
}
|
|
80
|
-
return {
|
|
81
|
-
path,
|
|
82
|
-
state: 'present',
|
|
83
|
-
update: (sourceContent) => apply(sourceContent, blockName),
|
|
84
|
-
};
|
|
85
|
-
}
|
|
86
|
-
/**
|
|
87
|
-
* Replace asynchronously a block in file that follows pattern :
|
|
88
|
-
*
|
|
89
|
-
* marker(markerBegin)
|
|
90
|
-
* ...
|
|
91
|
-
* marker(markerEnd)
|
|
92
|
-
*
|
|
93
|
-
* @param options
|
|
94
|
-
*/
|
|
95
|
-
function block(options) {
|
|
96
|
-
return (0, file_js_1.file)(toFileOptions(options));
|
|
97
|
-
}
|
|
98
|
-
/**
|
|
99
|
-
* Replace synchronously a block in file that follows pattern :
|
|
100
|
-
*
|
|
101
|
-
* marker(markerBegin)
|
|
102
|
-
* ...
|
|
103
|
-
* marker(markerEnd)
|
|
104
|
-
*
|
|
105
|
-
* @param options
|
|
106
|
-
*/
|
|
107
|
-
function blockSync(options) {
|
|
108
|
-
return (0, file_js_1.fileSync)(toFileOptions(options));
|
|
109
|
-
}
|
|
110
|
-
//# sourceMappingURL=block.js.map
|
package/dist/block.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"block.js","sourceRoot":"","sources":["../src/block.ts"],"names":[],"mappings":";;AAqIA,sBAEC;AAWD,8BAEC;AApJD,uCAA6D;AA2B7D,MAAM,GAAG,GAAG,WAAW,CAAC;AACxB,MAAM,GAAG,GAAG,iBAAiB,CAAC;AAC9B,MAAM,QAAQ,GAAG,CAAC,GAAW,EAAE,KAAa,EAAE,QAAgB,EAAE,EAAE,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC,EAAE,KAAK,CAAC,GAAG,QAAQ,GAAG,GAAG,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC;A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C;oBAC3B,MAAM,EAAE,SAAS,EAAE,GAAG,SAAS,CAAC,WAAW,EAAE,cAAc,CAAC,CAAC;oBAC7D,IAAI,SAAS,IAAI,CAAC,EAAE,CAAC;wBACnB,OAAO,QAAQ,CAAC,WAAW,EAAE,SAAS,EAAE,GAAG,GAAG,YAAY,CAAC,CAAC;oBAC9D,CAAC;gBACH,CAAC;gBAED,cAAc;gBACd,OAAO,WAAW,GAAG,GAAG,GAAG,YAAY,CAAC;YAC1C,CAAC;YAED,OAAO,CAAC,CAAC,CAAC;gBACR,MAAM,IAAI,KAAK,CAAC,wBAAwB,MAAM,CAAC,iBAAiB,CAAC,EAAE,CAAC,CAAC;YACvE,CAAC;QACH,CAAC;IACH,CAAC;IAED,OAAO;QACL,IAAI;QACJ,KAAK,EAAE,SAAS;QAChB,MAAM,EAAE,CAAC,aAAa,EAAE,EAAE,CAAC,KAAK,CAAC,aAAa,EAAE,SAAS,CAAC;KAC3D,CAAC;AACJ,CAAC;AAED;;;;;;;;GAQG;AACH,SAAgB,KAAK,CAAC,OAAqB;IACzC,OAAO,IAAA,cAAI,EAAC,aAAa,CAAC,OAAO,CAAC,CAAC,CAAC;AACtC,CAAC;AAED;;;;;;;;GAQG;AACH,SAAgB,SAAS,CAAC,OAAqB;IAC7C,OAAO,IAAA,kBAAQ,EAAC,aAAa,CAAC,OAAO,CAAC,CAAC,CAAC;AAC1C,CAAC"}
|
package/dist/directory.d.ts
DELETED
|
@@ -1,39 +0,0 @@
|
|
|
1
|
-
export interface DirectoryOptions {
|
|
2
|
-
/**
|
|
3
|
-
* Directory path
|
|
4
|
-
*/
|
|
5
|
-
readonly path: string;
|
|
6
|
-
/**
|
|
7
|
-
* Directory target state
|
|
8
|
-
*/
|
|
9
|
-
readonly state: 'present' | 'absent';
|
|
10
|
-
}
|
|
11
|
-
/**
|
|
12
|
-
* Ensure directory is present/absent
|
|
13
|
-
*
|
|
14
|
-
* @example
|
|
15
|
-
* ```ts
|
|
16
|
-
* await directory({
|
|
17
|
-
* path: 'foo/bar',
|
|
18
|
-
* state: 'present',
|
|
19
|
-
* })
|
|
20
|
-
* ```
|
|
21
|
-
*
|
|
22
|
-
* @param options
|
|
23
|
-
*/
|
|
24
|
-
export declare function directory(options: DirectoryOptions): Promise<void>;
|
|
25
|
-
/**
|
|
26
|
-
* Ensure directory is present/absent
|
|
27
|
-
*
|
|
28
|
-
* @example
|
|
29
|
-
* ```ts
|
|
30
|
-
* await directorySync({
|
|
31
|
-
* path: 'foo/bar',
|
|
32
|
-
* state: 'present',
|
|
33
|
-
* })
|
|
34
|
-
* ```
|
|
35
|
-
*
|
|
36
|
-
* @param options
|
|
37
|
-
*/
|
|
38
|
-
export declare function directorySync(options: DirectoryOptions): void;
|
|
39
|
-
//# sourceMappingURL=directory.d.ts.map
|
package/dist/directory.js
DELETED
|
@@ -1,66 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.directory = directory;
|
|
4
|
-
exports.directorySync = directorySync;
|
|
5
|
-
const node_fs_1 = require("node:fs");
|
|
6
|
-
const promises_1 = require("node:fs/promises");
|
|
7
|
-
async function exists(path) {
|
|
8
|
-
try {
|
|
9
|
-
await (0, promises_1.access)(path, promises_1.constants.F_OK);
|
|
10
|
-
return true;
|
|
11
|
-
}
|
|
12
|
-
catch {
|
|
13
|
-
return false;
|
|
14
|
-
}
|
|
15
|
-
}
|
|
16
|
-
/**
|
|
17
|
-
* Ensure directory is present/absent
|
|
18
|
-
*
|
|
19
|
-
* @example
|
|
20
|
-
* ```ts
|
|
21
|
-
* await directory({
|
|
22
|
-
* path: 'foo/bar',
|
|
23
|
-
* state: 'present',
|
|
24
|
-
* })
|
|
25
|
-
* ```
|
|
26
|
-
*
|
|
27
|
-
* @param options
|
|
28
|
-
*/
|
|
29
|
-
async function directory(options) {
|
|
30
|
-
const { path, state } = options;
|
|
31
|
-
const isPresent = await exists(path);
|
|
32
|
-
if (state === 'present') {
|
|
33
|
-
if (!isPresent) {
|
|
34
|
-
await (0, promises_1.mkdir)(path, { recursive: true });
|
|
35
|
-
}
|
|
36
|
-
}
|
|
37
|
-
else if (isPresent) {
|
|
38
|
-
await (0, promises_1.rm)(path, { recursive: true });
|
|
39
|
-
}
|
|
40
|
-
}
|
|
41
|
-
/**
|
|
42
|
-
* Ensure directory is present/absent
|
|
43
|
-
*
|
|
44
|
-
* @example
|
|
45
|
-
* ```ts
|
|
46
|
-
* await directorySync({
|
|
47
|
-
* path: 'foo/bar',
|
|
48
|
-
* state: 'present',
|
|
49
|
-
* })
|
|
50
|
-
* ```
|
|
51
|
-
*
|
|
52
|
-
* @param options
|
|
53
|
-
*/
|
|
54
|
-
function directorySync(options) {
|
|
55
|
-
const { path, state } = options;
|
|
56
|
-
const isPresent = (0, node_fs_1.existsSync)(path);
|
|
57
|
-
if (state === 'present') {
|
|
58
|
-
if (!isPresent) {
|
|
59
|
-
(0, node_fs_1.mkdirSync)(path, { recursive: true });
|
|
60
|
-
}
|
|
61
|
-
}
|
|
62
|
-
else if (isPresent) {
|
|
63
|
-
(0, node_fs_1.rmSync)(path, { recursive: true });
|
|
64
|
-
}
|
|
65
|
-
}
|
|
66
|
-
//# sourceMappingURL=directory.js.map
|
package/dist/directory.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"directory.js","sourceRoot":"","sources":["../src/directory.ts"],"names":[],"mappings":";;AAoCA,8BAUC;AAeD,sCAUC;AAvED,qCAAwD;AACxD,+CAAgE;AAEhE,KAAK,UAAU,MAAM,CAAC,IAAY;IAChC,IAAI,CAAC;QACH,MAAM,IAAA,iBAAM,EAAC,IAAI,EAAE,oBAAS,CAAC,IAAI,CAAC,CAAC;QACnC,OAAO,IAAI,CAAC;IACd,CAAC;IAAC,MAAM,CAAC;QACP,OAAO,KAAK,CAAC;IACf,CAAC;AACH,CAAC;AAaD;;;;;;;;;;;;GAYG;AACI,KAAK,UAAU,SAAS,CAAC,OAAyB;IACvD,MAAM,EAAE,IAAI,EAAE,KAAK,EAAE,GAAG,OAAO,CAAC;IAChC,MAAM,SAAS,GAAG,MAAM,MAAM,CAAC,IAAI,CAAC,CAAC;IACrC,IAAI,KAAK,KAAK,SAAS,EAAE,CAAC;QACxB,IAAI,CAAC,SAAS,EAAE,CAAC;YACf,MAAM,IAAA,gBAAK,EAAC,IAAI,EAAE,EAAE,SAAS,EAAE,IAAI,EAAE,CAAC,CAAC;QACzC,CAAC;IACH,CAAC;SAAM,IAAI,SAAS,EAAE,CAAC;QACrB,MAAM,IAAA,aAAE,EAAC,IAAI,EAAE,EAAE,SAAS,EAAE,IAAI,EAAE,CAAC,CAAC;IACtC,CAAC;AACH,CAAC;AAED;;;;;;;;;;;;GAYG;AACH,SAAgB,aAAa,CAAC,OAAyB;IACrD,MAAM,EAAE,IAAI,EAAE,KAAK,EAAE,GAAG,OAAO,CAAC;IAChC,MAAM,SAAS,GAAG,IAAA,oBAAU,EAAC,IAAI,CAAC,CAAC;IACnC,IAAI,KAAK,KAAK,SAAS,EAAE,CAAC;QACxB,IAAI,CAAC,SAAS,EAAE,CAAC;YACf,IAAA,mBAAS,EAAC,IAAI,EAAE,EAAE,SAAS,EAAE,IAAI,EAAE,CAAC,CAAC;QACvC,CAAC;IACH,CAAC;SAAM,IAAI,SAAS,EAAE,CAAC;QACrB,IAAA,gBAAM,EAAC,IAAI,EAAE,EAAE,SAAS,EAAE,IAAI,EAAE,CAAC,CAAC;IACpC,CAAC;AACH,CAAC"}
|
package/dist/eslint.d.ts
DELETED
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
import type { ESLint, Linter } from 'eslint';
|
|
2
|
-
export declare namespace ESLintConfig {
|
|
3
|
-
/**
|
|
4
|
-
*
|
|
5
|
-
* @param configs
|
|
6
|
-
*/
|
|
7
|
-
function concat(...configs: ESLint.ConfigData[]): ESLint.ConfigData;
|
|
8
|
-
/**
|
|
9
|
-
* Always return 'off'. `_status` is the previous rule value.
|
|
10
|
-
*
|
|
11
|
-
* @param _status
|
|
12
|
-
*/
|
|
13
|
-
function fixme(_status: Linter.RuleLevel | [Linter.RuleLevel, ...any[]] | undefined): "off";
|
|
14
|
-
}
|
|
15
|
-
//# sourceMappingURL=eslint.d.ts.map
|
package/dist/eslint.js
DELETED
|
@@ -1,56 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.ESLintConfig = void 0;
|
|
4
|
-
function toArray(value) {
|
|
5
|
-
if (value == null) {
|
|
6
|
-
return [];
|
|
7
|
-
}
|
|
8
|
-
if (Array.isArray(value)) {
|
|
9
|
-
return value;
|
|
10
|
-
}
|
|
11
|
-
return [value];
|
|
12
|
-
}
|
|
13
|
-
function concatArray(left, right) {
|
|
14
|
-
return toArray(left).concat(toArray(right));
|
|
15
|
-
}
|
|
16
|
-
var ESLintConfig;
|
|
17
|
-
(function (ESLintConfig) {
|
|
18
|
-
/**
|
|
19
|
-
*
|
|
20
|
-
* @param configs
|
|
21
|
-
*/
|
|
22
|
-
function concat(...configs) {
|
|
23
|
-
return configs.reduce((returnValue, config) => ({
|
|
24
|
-
...returnValue,
|
|
25
|
-
...config,
|
|
26
|
-
env: { ...returnValue.env, ...config.env },
|
|
27
|
-
extends: concatArray(returnValue.extends, config.extends),
|
|
28
|
-
globals: { ...returnValue.globals, ...config.globals },
|
|
29
|
-
overrides: concatArray(returnValue.overrides, config.overrides),
|
|
30
|
-
parserOptions: { ...returnValue.parserOptions, ...config.parserOptions },
|
|
31
|
-
plugins: concatArray(returnValue.plugins, config.plugins),
|
|
32
|
-
rules: { ...returnValue.rules, ...config.rules },
|
|
33
|
-
settings: { ...returnValue.settings, ...config.settings },
|
|
34
|
-
}), {
|
|
35
|
-
env: {},
|
|
36
|
-
extends: [],
|
|
37
|
-
globals: {},
|
|
38
|
-
overrides: [],
|
|
39
|
-
parserOptions: {},
|
|
40
|
-
plugins: [],
|
|
41
|
-
rules: {},
|
|
42
|
-
settings: {},
|
|
43
|
-
});
|
|
44
|
-
}
|
|
45
|
-
ESLintConfig.concat = concat;
|
|
46
|
-
/**
|
|
47
|
-
* Always return 'off'. `_status` is the previous rule value.
|
|
48
|
-
*
|
|
49
|
-
* @param _status
|
|
50
|
-
*/
|
|
51
|
-
function fixme(_status) {
|
|
52
|
-
return 'off';
|
|
53
|
-
}
|
|
54
|
-
ESLintConfig.fixme = fixme;
|
|
55
|
-
})(ESLintConfig || (exports.ESLintConfig = ESLintConfig = {}));
|
|
56
|
-
//# sourceMappingURL=eslint.js.map
|
package/dist/eslint.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"eslint.js","sourceRoot":"","sources":["../src/eslint.ts"],"names":[],"mappings":";;;AAEA,SAAS,OAAO,CAAI,KAA0B;IAC5C,IAAI,KAAK,IAAI,IAAI,EAAE,CAAC;QAClB,OAAO,EAAE,CAAC;IACZ,CAAC;IACD,IAAI,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,EAAE,CAAC;QACzB,OAAO,KAAK,CAAC;IACf,CAAC;IACD,OAAO,CAAC,KAAK,CAAC,CAAC;AACjB,CAAC;AAED,SAAS,WAAW,CAAI,IAAyB,EAAE,KAA0B;IAC3E,OAAO,OAAO,CAAC,IAAI,CAAC,CAAC,MAAM,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC,CAAC;AAC9C,CAAC;AAED,IAAiB,YAAY,CAwC5B;AAxCD,WAAiB,YAAY;IAC3B;;;OAGG;IACH,SAAgB,MAAM,CAAC,GAAG,OAA4B;QACpD,OAAO,OAAO,CAAC,MAAM,CACnB,CAAC,WAAW,EAAE,MAAM,EAAE,EAAE,CAAC,CAAC;YACxB,GAAG,WAAW;YACd,GAAG,MAAM;YACT,GAAG,EAAE,EAAE,GAAG,WAAW,CAAC,GAAG,EAAE,GAAG,MAAM,CAAC,GAAG,EAAE;YAC1C,OAAO,EAAE,WAAW,CAAC,WAAW,CAAC,OAAO,EAAE,MAAM,CAAC,OAAO,CAAC;YACzD,OAAO,EAAE,EAAE,GAAG,WAAW,CAAC,OAAO,EAAE,GAAG,MAAM,CAAC,OAAO,EAAE;YACtD,SAAS,EAAE,WAAW,CAAC,WAAW,CAAC,SAAS,EAAE,MAAM,CAAC,SAAS,CAAC;YAC/D,aAAa,EAAE,EAAE,GAAG,WAAW,CAAC,aAAa,EAAE,GAAG,MAAM,CAAC,aAAa,EAAE;YACxE,OAAO,EAAE,WAAW,CAAC,WAAW,CAAC,OAAO,EAAE,MAAM,CAAC,OAAO,CAAC;YACzD,KAAK,EAAE,EAAE,GAAG,WAAW,CAAC,KAAK,EAAE,GAAG,MAAM,CAAC,KAAK,EAAE;YAChD,QAAQ,EAAE,EAAE,GAAG,WAAW,CAAC,QAAQ,EAAE,GAAG,MAAM,CAAC,QAAQ,EAAE;SAC1D,CAAC,EACF;YACE,GAAG,EAAE,EAAE;YACP,OAAO,EAAE,EAAE;YACX,OAAO,EAAE,EAAE;YACX,SAAS,EAAE,EAAE;YACb,aAAa,EAAE,EAAE;YACjB,OAAO,EAAE,EAAE;YACX,KAAK,EAAE,EAAE;YACT,QAAQ,EAAE,EAAE;SACb,CACF,CAAC;IACJ,CAAC;IAzBe,mBAAM,SAyBrB,CAAA;IAED;;;;OAIG;IACH,SAAgB,KAAK,CAAC,OAAoE;QACxF,OAAO,KAAc,CAAC;IACxB,CAAC;IAFe,kBAAK,QAEpB,CAAA;AACH,CAAC,EAxCgB,YAAY,4BAAZ,YAAY,QAwC5B"}
|
package/dist/file.d.ts
DELETED
|
@@ -1,51 +0,0 @@
|
|
|
1
|
-
export interface FileOptions {
|
|
2
|
-
/**
|
|
3
|
-
* File path
|
|
4
|
-
*/
|
|
5
|
-
readonly path: string;
|
|
6
|
-
/**
|
|
7
|
-
* File target state
|
|
8
|
-
*/
|
|
9
|
-
readonly state: 'present' | 'absent';
|
|
10
|
-
/**
|
|
11
|
-
* File content mapping function
|
|
12
|
-
*
|
|
13
|
-
* @param content
|
|
14
|
-
*/
|
|
15
|
-
readonly update?: (content: string) => string | undefined;
|
|
16
|
-
/**
|
|
17
|
-
* File encoding
|
|
18
|
-
*/
|
|
19
|
-
readonly encoding?: BufferEncoding;
|
|
20
|
-
}
|
|
21
|
-
/**
|
|
22
|
-
* Ensure file is present/absent with content initialized or modified with `update
|
|
23
|
-
*
|
|
24
|
-
* @example
|
|
25
|
-
* ```ts
|
|
26
|
-
* await file({
|
|
27
|
-
* path: 'foo/bar',
|
|
28
|
-
* state: 'present',
|
|
29
|
-
* update: (content) => content + '_test', // This will append '_test' after current content
|
|
30
|
-
* })
|
|
31
|
-
* ```
|
|
32
|
-
*
|
|
33
|
-
* @param options
|
|
34
|
-
*/
|
|
35
|
-
export declare function file(options: FileOptions): Promise<void>;
|
|
36
|
-
/**
|
|
37
|
-
* Ensure file is present/absent with content initialized or modified with `update
|
|
38
|
-
*
|
|
39
|
-
* @example
|
|
40
|
-
* ```ts
|
|
41
|
-
* fileSync({
|
|
42
|
-
* path: 'foo/bar',
|
|
43
|
-
* state: 'present',
|
|
44
|
-
* update: (content) => content + '_test', // This will append '_test' after current content
|
|
45
|
-
* })
|
|
46
|
-
* ```
|
|
47
|
-
*
|
|
48
|
-
* @param options
|
|
49
|
-
*/
|
|
50
|
-
export declare function fileSync(options: FileOptions): void;
|
|
51
|
-
//# sourceMappingURL=file.d.ts.map
|
package/dist/file.js
DELETED
|
@@ -1,81 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.file = file;
|
|
4
|
-
exports.fileSync = fileSync;
|
|
5
|
-
const promises_1 = require("node:fs/promises");
|
|
6
|
-
const node_fs_1 = require("node:fs");
|
|
7
|
-
async function exists(path) {
|
|
8
|
-
try {
|
|
9
|
-
await (0, promises_1.access)(path, node_fs_1.constants.F_OK);
|
|
10
|
-
return true;
|
|
11
|
-
}
|
|
12
|
-
catch {
|
|
13
|
-
return false;
|
|
14
|
-
}
|
|
15
|
-
}
|
|
16
|
-
function existsSync(path) {
|
|
17
|
-
try {
|
|
18
|
-
(0, node_fs_1.accessSync)(path, node_fs_1.constants.F_OK);
|
|
19
|
-
return true;
|
|
20
|
-
}
|
|
21
|
-
catch {
|
|
22
|
-
return false;
|
|
23
|
-
}
|
|
24
|
-
}
|
|
25
|
-
/**
|
|
26
|
-
* Ensure file is present/absent with content initialized or modified with `update
|
|
27
|
-
*
|
|
28
|
-
* @example
|
|
29
|
-
* ```ts
|
|
30
|
-
* await file({
|
|
31
|
-
* path: 'foo/bar',
|
|
32
|
-
* state: 'present',
|
|
33
|
-
* update: (content) => content + '_test', // This will append '_test' after current content
|
|
34
|
-
* })
|
|
35
|
-
* ```
|
|
36
|
-
*
|
|
37
|
-
* @param options
|
|
38
|
-
*/
|
|
39
|
-
async function file(options) {
|
|
40
|
-
const { path, state, update, encoding = 'utf8' } = options;
|
|
41
|
-
if (state === 'present') {
|
|
42
|
-
const isPresent = await exists(path);
|
|
43
|
-
const previousContent = isPresent ? await (0, promises_1.readFile)(path, encoding) : '';
|
|
44
|
-
const newContent = update == null ? '' : update(previousContent);
|
|
45
|
-
if (newContent != null) {
|
|
46
|
-
await (0, promises_1.writeFile)(path, newContent, encoding);
|
|
47
|
-
}
|
|
48
|
-
}
|
|
49
|
-
else {
|
|
50
|
-
await (0, promises_1.rm)(path, { force: true });
|
|
51
|
-
}
|
|
52
|
-
}
|
|
53
|
-
/**
|
|
54
|
-
* Ensure file is present/absent with content initialized or modified with `update
|
|
55
|
-
*
|
|
56
|
-
* @example
|
|
57
|
-
* ```ts
|
|
58
|
-
* fileSync({
|
|
59
|
-
* path: 'foo/bar',
|
|
60
|
-
* state: 'present',
|
|
61
|
-
* update: (content) => content + '_test', // This will append '_test' after current content
|
|
62
|
-
* })
|
|
63
|
-
* ```
|
|
64
|
-
*
|
|
65
|
-
* @param options
|
|
66
|
-
*/
|
|
67
|
-
function fileSync(options) {
|
|
68
|
-
const { path, state, update, encoding = 'utf8' } = options;
|
|
69
|
-
if (state === 'present') {
|
|
70
|
-
const isPresent = existsSync(path);
|
|
71
|
-
const previousContent = isPresent ? (0, node_fs_1.readFileSync)(path, encoding) : '';
|
|
72
|
-
const newContent = update == null ? '' : update(previousContent);
|
|
73
|
-
if (newContent != null) {
|
|
74
|
-
(0, node_fs_1.writeFileSync)(path, newContent, encoding);
|
|
75
|
-
}
|
|
76
|
-
}
|
|
77
|
-
else {
|
|
78
|
-
(0, node_fs_1.rmSync)(path, { force: true });
|
|
79
|
-
}
|
|
80
|
-
}
|
|
81
|
-
//# sourceMappingURL=file.js.map
|
package/dist/file.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"file.js","sourceRoot":"","sources":["../src/file.ts"],"names":[],"mappings":";;AAwDA,oBAYC;AAgBD,4BAYC;AAhGD,+CAAmE;AACnE,qCAAqF;AAErF,KAAK,UAAU,MAAM,CAAC,IAAY;IAChC,IAAI,CAAC;QACH,MAAM,IAAA,iBAAM,EAAC,IAAI,EAAE,mBAAS,CAAC,IAAI,CAAC,CAAC;QACnC,OAAO,IAAI,CAAC;IACd,CAAC;IAAC,MAAM,CAAC;QACP,OAAO,KAAK,CAAC;IACf,CAAC;AACH,CAAC;AAED,SAAS,UAAU,CAAC,IAAY;IAC9B,IAAI,CAAC;QACH,IAAA,oBAAU,EAAC,IAAI,EAAE,mBAAS,CAAC,IAAI,CAAC,CAAC;QACjC,OAAO,IAAI,CAAC;IACd,CAAC;IAAC,MAAM,CAAC;QACP,OAAO,KAAK,CAAC;IACf,CAAC;AACH,CAAC;AAuBD;;;;;;;;;;;;;GAaG;AACI,KAAK,UAAU,IAAI,CAAC,OAAoB;IAC7C,MAAM,EAAE,IAAI,EAAE,KAAK,EAAE,MAAM,EAAE,QAAQ,GAAG,MAAM,EAAE,GAAG,OAAO,CAAC;IAC3D,IAAI,KAAK,KAAK,SAAS,EAAE,CAAC;QACxB,MAAM,SAAS,GAAG,MA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I,EAAE,CAAC,CAAC;IAChC,CAAC;AACH,CAAC"}
|
package/dist/json.d.ts
DELETED
|
@@ -1,36 +0,0 @@
|
|
|
1
|
-
export type JSONValue = null | number | string | boolean | JSONValue[] | {
|
|
2
|
-
[key: string]: JSONValue;
|
|
3
|
-
};
|
|
4
|
-
export interface JSONOption<V = JSONValue> {
|
|
5
|
-
/**
|
|
6
|
-
* File path
|
|
7
|
-
*/
|
|
8
|
-
readonly path: string;
|
|
9
|
-
/**
|
|
10
|
-
* File target state
|
|
11
|
-
*/
|
|
12
|
-
readonly state: 'present' | 'absent';
|
|
13
|
-
/**
|
|
14
|
-
* File content mapping function
|
|
15
|
-
*
|
|
16
|
-
* @param content
|
|
17
|
-
*/
|
|
18
|
-
readonly update?: (content: V | undefined) => V | undefined;
|
|
19
|
-
/**
|
|
20
|
-
* File encoding
|
|
21
|
-
*/
|
|
22
|
-
readonly encoding?: BufferEncoding;
|
|
23
|
-
}
|
|
24
|
-
/**
|
|
25
|
-
* Ensure file is present/absent asynchronously with content value initialized or modified with `update`
|
|
26
|
-
*
|
|
27
|
-
* @param options
|
|
28
|
-
*/
|
|
29
|
-
export declare function json<Value>(options: JSONOption<Value>): Promise<void>;
|
|
30
|
-
/**
|
|
31
|
-
* Ensure file is present/absent synchronously with content value initialized or modified with `update`
|
|
32
|
-
*
|
|
33
|
-
* @param options
|
|
34
|
-
*/
|
|
35
|
-
export declare function jsonSync<Value>(options: JSONOption<Value>): void;
|
|
36
|
-
//# sourceMappingURL=json.d.ts.map
|
package/dist/json.js
DELETED
|
@@ -1,33 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.json = json;
|
|
4
|
-
exports.jsonSync = jsonSync;
|
|
5
|
-
const file_js_1 = require("./file.js");
|
|
6
|
-
function toFileOption({ update, ...otherOptions }) {
|
|
7
|
-
return {
|
|
8
|
-
...otherOptions,
|
|
9
|
-
update: update == null
|
|
10
|
-
? update
|
|
11
|
-
: (content) => {
|
|
12
|
-
const jsonValue = content === '' ? undefined : JSON.parse(content);
|
|
13
|
-
return JSON.stringify(update(jsonValue));
|
|
14
|
-
},
|
|
15
|
-
};
|
|
16
|
-
}
|
|
17
|
-
/**
|
|
18
|
-
* Ensure file is present/absent asynchronously with content value initialized or modified with `update`
|
|
19
|
-
*
|
|
20
|
-
* @param options
|
|
21
|
-
*/
|
|
22
|
-
async function json(options) {
|
|
23
|
-
return (0, file_js_1.file)(toFileOption(options));
|
|
24
|
-
}
|
|
25
|
-
/**
|
|
26
|
-
* Ensure file is present/absent synchronously with content value initialized or modified with `update`
|
|
27
|
-
*
|
|
28
|
-
* @param options
|
|
29
|
-
*/
|
|
30
|
-
function jsonSync(options) {
|
|
31
|
-
return (0, file_js_1.fileSync)(toFileOption(options));
|
|
32
|
-
}
|
|
33
|
-
//# sourceMappingURL=json.js.map
|
package/dist/json.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"json.js","sourceRoot":"","sources":["../src/json.ts"],"names":[],"mappings":";;AA6CA,oBAEC;AAOD,4BAEC;AAxDD,uCAA6D;AAyB7D,SAAS,YAAY,CAAQ,EAAE,MAAM,EAAE,GAAG,YAAY,EAAqB;IACzE,OAAO;QACL,GAAG,YAAY;QAEf,MAAM,EACJ,MAAM,IAAI,IAAI;YACZ,CAAC,CAAC,MAAM;YACR,CAAC,CAAC,CAAC,OAAO,EAAE,EAAE;gBACV,MAAM,SAAS,GAAG,OAAO,KAAK,EAAE,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAE,IAAI,CAAC,KAAK,CAAC,OAAO,CAAW,CAAC;gBAE9E,OAAO,IAAI,CAAC,SAAS,CAAC,MAAM,CAAC,SAAS,CAAC,CAAC,CAAC;YAC3C,CAAC;KACR,CAAC;AACJ,CAAC;AAED;;;;GAIG;AACI,KAAK,UAAU,IAAI,CAAQ,OAA0B;IAC1D,OAAO,IAAA,cAAI,EAAC,YAAY,CAAC,OAAO,CAAC,CAAC,CAAC;AACrC,CAAC;AAED;;;;GAIG;AACH,SAAgB,QAAQ,CAAQ,OAA0B;IACxD,OAAO,IAAA,kBAAQ,EAAC,YAAY,CAAC,OAAO,CAAC,CAAC,CAAC;AACzC,CAAC"}
|