@ember-template-lint/todo-utils
Advanced tools
Comparing version 2.3.0 to 3.0.0
@@ -0,1 +1,10 @@ | ||
## v3.0.0 (2020-11-04) | ||
#### :boom: Breaking Change | ||
* [#24](https://github.com/ember-template-lint/ember-template-lint-todo-utils/pull/24) Aligning APIs for consistency ([@scalvert](https://github.com/scalvert)) | ||
#### Committers: 1 | ||
- Steve Calvert ([@scalvert](https://github.com/scalvert)) | ||
## v2.3.0 (2020-10-26) | ||
@@ -2,0 +11,0 @@ |
export { _buildTodoDatum, buildTodoData } from './builders'; | ||
export { ensureTodoDir, getTodoStorageDirPath, getTodoBatches, todoDirExists, todoDirFor, todoFileNameFor, todoFilePathFor, readTodos, readTodosForFilePath, writeTodos, } from './io'; | ||
export { ensureTodoStorageDir, getTodoStorageDirPath, getTodoBatches, todoStorageDirExists, todoDirFor, todoFileNameFor, todoFilePathFor, readTodos, readTodosForFilePath, writeTodos, } from './io'; | ||
export * from './types'; | ||
//# sourceMappingURL=index.d.ts.map |
@@ -8,6 +8,6 @@ "use strict"; | ||
var io_1 = require("./io"); | ||
Object.defineProperty(exports, "ensureTodoDir", { enumerable: true, get: function () { return io_1.ensureTodoDir; } }); | ||
Object.defineProperty(exports, "ensureTodoStorageDir", { enumerable: true, get: function () { return io_1.ensureTodoStorageDir; } }); | ||
Object.defineProperty(exports, "getTodoStorageDirPath", { enumerable: true, get: function () { return io_1.getTodoStorageDirPath; } }); | ||
Object.defineProperty(exports, "getTodoBatches", { enumerable: true, get: function () { return io_1.getTodoBatches; } }); | ||
Object.defineProperty(exports, "todoDirExists", { enumerable: true, get: function () { return io_1.todoDirExists; } }); | ||
Object.defineProperty(exports, "todoStorageDirExists", { enumerable: true, get: function () { return io_1.todoStorageDirExists; } }); | ||
Object.defineProperty(exports, "todoDirFor", { enumerable: true, get: function () { return io_1.todoDirFor; } }); | ||
@@ -14,0 +14,0 @@ Object.defineProperty(exports, "todoFileNameFor", { enumerable: true, get: function () { return io_1.todoFileNameFor; } }); |
import { FilePath, LintResult, TodoData } from './types'; | ||
export declare function todoDirExists(baseDir: string): Promise<boolean>; | ||
/** | ||
* Determines if the .lint-todo storage directory exists. | ||
* | ||
* @param baseDir The base directory that contains the .lint-todo storage directory. | ||
*/ | ||
export declare function todoStorageDirExists(baseDir: string): boolean; | ||
/** | ||
* Creates, or ensures the creation of, the .lint-todo directory. | ||
@@ -8,3 +13,3 @@ * | ||
*/ | ||
export declare function ensureTodoDir(baseDir: string): Promise<string>; | ||
export declare function ensureTodoStorageDir(baseDir: string): Promise<string>; | ||
/** | ||
@@ -51,5 +56,5 @@ * @param baseDir The base directory that contains the .lint-todo storage directory. | ||
* | ||
* @param todoStorageDir The .lint-todo storage directory. | ||
* @param baseDir The base directory that contains the .lint-todo storage directory. | ||
*/ | ||
export declare function readTodos(todoStorageDir: string): Promise<Map<FilePath, TodoData>>; | ||
export declare function readTodos(baseDir: string): Promise<Map<FilePath, TodoData>>; | ||
/** | ||
@@ -61,3 +66,3 @@ * Reads todo files in the .lint-todo directory for a specific filePath. | ||
*/ | ||
export declare function readTodosForFilePath(todoStorageDir: string, filePath: string): Promise<Map<FilePath, TodoData>>; | ||
export declare function readTodosForFilePath(baseDir: string, filePath: string): Promise<Map<FilePath, TodoData>>; | ||
/** | ||
@@ -64,0 +69,0 @@ * Gets 3 maps containing todo items to add, remove, or those that are stable (not to be modified). |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.getTodoBatches = exports.readTodosForFilePath = exports.readTodos = exports.writeTodos = exports.todoFileNameFor = exports.todoDirFor = exports.todoFilePathFor = exports.getTodoStorageDirPath = exports.ensureTodoDir = exports.todoDirExists = void 0; | ||
exports.getTodoBatches = exports.readTodosForFilePath = exports.readTodos = exports.writeTodos = exports.todoFileNameFor = exports.todoDirFor = exports.todoFilePathFor = exports.getTodoStorageDirPath = exports.ensureTodoStorageDir = exports.todoStorageDirExists = void 0; | ||
const crypto_1 = require("crypto"); | ||
const path_1 = require("path"); | ||
const util_1 = require("util"); | ||
const fs_1 = require("fs"); | ||
const fs_extra_1 = require("fs-extra"); | ||
const builders_1 = require("./builders"); | ||
const exists = util_1.promisify(fs_1.access); | ||
async function todoDirExists(baseDir) { | ||
try { | ||
await exists(getTodoStorageDirPath(baseDir)); | ||
return true; | ||
} | ||
catch (error) { | ||
if (error.code === 'ENOENT') { | ||
return false; | ||
} | ||
throw error; | ||
} | ||
/** | ||
* Determines if the .lint-todo storage directory exists. | ||
* | ||
* @param baseDir The base directory that contains the .lint-todo storage directory. | ||
*/ | ||
function todoStorageDirExists(baseDir) { | ||
return fs_extra_1.existsSync(getTodoStorageDirPath(baseDir)); | ||
} | ||
exports.todoDirExists = todoDirExists; | ||
exports.todoStorageDirExists = todoStorageDirExists; | ||
/** | ||
@@ -29,3 +22,3 @@ * Creates, or ensures the creation of, the .lint-todo directory. | ||
*/ | ||
async function ensureTodoDir(baseDir) { | ||
async function ensureTodoStorageDir(baseDir) { | ||
const path = getTodoStorageDirPath(baseDir); | ||
@@ -35,3 +28,3 @@ await fs_extra_1.ensureDir(path); | ||
} | ||
exports.ensureTodoDir = ensureTodoDir; | ||
exports.ensureTodoStorageDir = ensureTodoStorageDir; | ||
/** | ||
@@ -88,6 +81,6 @@ * @param baseDir The base directory that contains the .lint-todo storage directory. | ||
async function writeTodos(baseDir, lintResults, filePath) { | ||
const todoStorageDir = await ensureTodoDir(baseDir); | ||
const todoStorageDir = await ensureTodoStorageDir(baseDir); | ||
const existing = filePath | ||
? await readTodosForFilePath(todoStorageDir, filePath) | ||
: await readTodos(todoStorageDir); | ||
? await readTodosForFilePath(baseDir, filePath) | ||
: await readTodos(baseDir); | ||
const [add, remove] = await getTodoBatches(builders_1.buildTodoData(baseDir, lintResults), existing); | ||
@@ -101,6 +94,7 @@ await _generateFiles(todoStorageDir, add, remove); | ||
* | ||
* @param todoStorageDir The .lint-todo storage directory. | ||
* @param baseDir The base directory that contains the .lint-todo storage directory. | ||
*/ | ||
async function readTodos(todoStorageDir) { | ||
async function readTodos(baseDir) { | ||
const map = new Map(); | ||
const todoStorageDir = await ensureTodoStorageDir(baseDir); | ||
const todoFileDirs = await fs_extra_1.readdir(todoStorageDir); | ||
@@ -123,4 +117,5 @@ for (const todoFileDir of todoFileDirs) { | ||
*/ | ||
async function readTodosForFilePath(todoStorageDir, filePath) { | ||
async function readTodosForFilePath(baseDir, filePath) { | ||
const map = new Map(); | ||
const todoStorageDir = await ensureTodoStorageDir(baseDir); | ||
const todoFileDir = todoDirFor(filePath); | ||
@@ -127,0 +122,0 @@ const todoFilePathDir = path_1.join(todoStorageDir, todoFileDir); |
{ | ||
"name": "@ember-template-lint/todo-utils", | ||
"version": "2.3.0", | ||
"version": "3.0.0", | ||
"repository": "https://github.com/ember-template-lint/ember-template-lint-todo-utils.git", | ||
@@ -15,3 +15,3 @@ "license": "MIT", | ||
"prepare": "yarn build", | ||
"test": "jest --passWithNoTests --no-cache" | ||
"test": "jest --no-cache" | ||
}, | ||
@@ -18,0 +18,0 @@ "dependencies": { |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
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
Filesystem access
Supply chain riskAccesses the file system, and could potentially read sensitive data.
Found 1 instance in 1 package
37180
2