Comparing version 1.2.1 to 1.3.0
"use strict"; | ||
var __importDefault = (this && this.__importDefault) || function (mod) { | ||
return (mod && mod.__esModule) ? mod : { "default": mod }; | ||
}; | ||
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) { | ||
if (k2 === undefined) k2 = k; | ||
var desc = Object.getOwnPropertyDescriptor(m, k); | ||
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) { | ||
desc = { enumerable: true, get: function() { return m[k]; } }; | ||
} | ||
Object.defineProperty(o, k2, desc); | ||
}) : (function(o, m, k, k2) { | ||
if (k2 === undefined) k2 = k; | ||
o[k2] = m[k]; | ||
})); | ||
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) { | ||
Object.defineProperty(o, "default", { enumerable: true, value: v }); | ||
}) : function(o, v) { | ||
o["default"] = v; | ||
}); | ||
var __importStar = (this && this.__importStar) || function (mod) { | ||
if (mod && mod.__esModule) return mod; | ||
var result = {}; | ||
if (mod != null) for (var k in mod) if (Object.hasOwnProperty.call(mod, k)) result[k] = mod[k]; | ||
result["default"] = mod; | ||
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k); | ||
__setModuleDefault(result, mod); | ||
return result; | ||
}; | ||
var __importDefault = (this && this.__importDefault) || function (mod) { | ||
return (mod && mod.__esModule) ? mod : { "default": mod }; | ||
}; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.startApp = void 0; | ||
const typescript_1 = __importDefault(require("typescript")); | ||
@@ -20,9 +37,9 @@ const path_1 = __importDefault(require("path")); | ||
/** | ||
* @param tsFilesPath files to be checked | ||
* @param sourceFilesPath files to be checked | ||
* @param tsConfOptions with tsconf | ||
*/ | ||
function checkFilesWithTSOptions(tsFilesPath, tsConfOptions) { | ||
function checkFilesWithTSOptions(sourceFilesPath, tsConfOptions) { | ||
// Obey 'node_modules/' files | ||
const nodeModulesRE = new RegExp(/node_modules/); | ||
const absolutePathsWithoutNodeModules = tsFilesPath | ||
const absolutePathsWithoutNodeModules = sourceFilesPath | ||
.filter(f => !nodeModulesRE.test(f)) | ||
@@ -38,3 +55,3 @@ .map(f => path_1.default.resolve(f)); | ||
const filename = dg.file.fileName; | ||
if (tsFilesPath.includes(filename)) { | ||
if (sourceFilesPath.includes(filename)) { | ||
// File is included in inputFiles | ||
@@ -90,3 +107,3 @@ if (filename in errorFiles) { | ||
} | ||
// TODO: Remove this function and use ts.sys.readDirectory(path, [".ts"]) | ||
// TODO: Remove this function and use ts.sys.readDirectory(path, [".ts"]) instead | ||
function globFiles(dir, includeJSFiles) { | ||
@@ -106,5 +123,5 @@ const files = typescript_1.default.sys.readDirectory(dir, includeJSFiles ? [".ts", ".js"] : [".ts"]); | ||
} | ||
function updateTSConf(tsconfPath, conf, filenames) { | ||
function updateTSConf(tsconfPath, conf, sourceFilesPath) { | ||
const absDirName = path_1.default.dirname(tsconfPath); | ||
if (!fs_1.existsSync(tsconfPath)) { | ||
if (!(0, fs_1.existsSync)(tsconfPath)) { | ||
utils_1.reporters.throwError(errors_1.EError.TSCONF_NOT_EXISTS, `Provided path '${tsconfPath}' for tsconf doesn't exists`); | ||
@@ -115,3 +132,3 @@ } | ||
} | ||
filenames.forEach(absPath => { | ||
sourceFilesPath.forEach(absPath => { | ||
const relPath = path_1.default.relative(absDirName, absPath); | ||
@@ -122,3 +139,3 @@ if (!conf.files.includes(relPath)) { | ||
}); | ||
fs_2.writeFileSync(tsconfPath, JSON.stringify(conf, null, 2)); | ||
(0, fs_2.writeFileSync)(tsconfPath, JSON.stringify(conf, null, 2)); | ||
} | ||
@@ -125,0 +142,0 @@ function startApp(conf) { |
@@ -13,3 +13,3 @@ #!/usr/bin/env node | ||
const errors_1 = require("./errors"); | ||
const conf = yargs_parser_1.default(process.argv.slice(2)); | ||
const conf = (0, yargs_parser_1.default)(process.argv.slice(2)); | ||
if (conf.h || conf.help || conf._.length === 0) { | ||
@@ -38,3 +38,3 @@ process.stdout.write("Usage: tscfc --project TSCONFIG_PATH SRC_PATH\n"); | ||
else { | ||
app_1.startApp({ | ||
(0, app_1.startApp)({ | ||
shouldShowRemainings: conf.remaining || conf.r || false, | ||
@@ -41,0 +41,0 @@ shouldUpdateFiles: conf.update || conf.u || false, |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.EError = void 0; | ||
var EError; | ||
@@ -4,0 +5,0 @@ (function (EError) { |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.reporters = exports.colors = void 0; | ||
exports.colors = { | ||
@@ -4,0 +5,0 @@ red: (str) => `\u001b[31m${str}\u001b[39m`, |
{ | ||
"name": "tscfc", | ||
"version": "1.2.1", | ||
"version": "1.3.0", | ||
"description": "", | ||
@@ -13,8 +13,8 @@ "main": "index.js", | ||
"dependencies": { | ||
"@types/glob": "^7.1.1", | ||
"@types/node": "^12.7.1", | ||
"@types/yargs-parser": "^13.1.0", | ||
"glob": "^7.1.4", | ||
"typescript": "^3.5.3", | ||
"yargs-parser": "^14.0.0" | ||
"@types/glob": "^8.0.0", | ||
"@types/node": "^18.8.3", | ||
"@types/yargs-parser": "^21.0.0", | ||
"glob": "^8.0.3", | ||
"typescript": "^4.8.4", | ||
"yargs-parser": "^21.1.1" | ||
}, | ||
@@ -24,3 +24,3 @@ "devDependencies": {}, | ||
"build": "tsc", | ||
"test": "node ./dist/cli.js --verbose --project ./test/tsconfig.strict.json ./test/" | ||
"test": "npm run build && node ./dist/cli.js --verbose --project ./test/tsconfig.strict.json ./test/" | ||
}, | ||
@@ -27,0 +27,0 @@ "keywords": [], |
@@ -10,3 +10,3 @@ # Tsconf Files Checker | ||
- 2. Command `tscfc --update` will automatically include those files to tsconf | ||
- 3. After that, each `tscfc --update` checks files against tsconf files (from step 2.) and tells user if someone is broken | ||
- 3. After that, each `tscfc --update` checks files against tsconf files (from step 2.) and show user if anything is broken | ||
- 3.1. If there are no broken files, then Ok. User's changes didn't affect any files in tsconf | ||
@@ -22,2 +22,4 @@ - 3.2. If there are files without error, tscfc will add them to tsconf. | ||
## Example | ||
Run from terminal: | ||
@@ -37,1 +39,29 @@ | ||
*Note: In order to check javascript files, please include `allowJS: true` to tsconfig.* | ||
## Recommended Settings | ||
If you want to incrementally enforce some rules (e.g. noImplicitAny, strictNullChecks) create | ||
`tsconfig.strict.json` alongside with your `tsconfig.json`. Then add to `tsconfig.strict.json`: | ||
```json | ||
{ | ||
"extends": "./tsconfig.json", | ||
"compilerOptions": { | ||
"noImplicitAny": true, | ||
"strictNullChecks": true | ||
} | ||
} | ||
``` | ||
in package json add `pretest` script, which will automatically runs | ||
before your test, to check if you broke something or not, even before test. | ||
```json | ||
{ | ||
//... | ||
"scripts": { | ||
"pretest": "tscfc --project ./tsconfig.strict.json ./src" | ||
} | ||
//... | ||
} | ||
``` |
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
65
22191
17
380
+ Added@types/glob@8.1.0(transitive)
+ Added@types/node@18.19.68(transitive)
+ Added@types/yargs-parser@21.0.3(transitive)
+ Addedbrace-expansion@2.0.1(transitive)
+ Addedglob@8.1.0(transitive)
+ Addedminimatch@5.1.6(transitive)
+ Addedtypescript@4.9.5(transitive)
+ Addedundici-types@5.26.5(transitive)
+ Addedyargs-parser@21.1.1(transitive)
- Removed@types/glob@7.2.0(transitive)
- Removed@types/node@12.20.55(transitive)
- Removed@types/yargs-parser@13.1.0(transitive)
- Removedbrace-expansion@1.1.11(transitive)
- Removedcamelcase@5.3.1(transitive)
- Removedconcat-map@0.0.1(transitive)
- Removeddecamelize@1.2.0(transitive)
- Removedglob@7.2.3(transitive)
- Removedminimatch@3.1.2(transitive)
- Removedpath-is-absolute@1.0.1(transitive)
- Removedtypescript@3.9.10(transitive)
- Removedyargs-parser@14.0.0(transitive)
Updated@types/glob@^8.0.0
Updated@types/node@^18.8.3
Updated@types/yargs-parser@^21.0.0
Updatedglob@^8.0.3
Updatedtypescript@^4.8.4
Updatedyargs-parser@^21.1.1