@openfn/describe-package
Advanced tools
Comparing version 0.0.17 to 0.0.18
@@ -0,1 +1,8 @@ | ||
var __defProp = Object.defineProperty; | ||
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value; | ||
var __publicField = (obj, key, value) => { | ||
__defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value); | ||
return value; | ||
}; | ||
// src/typescript/project.ts | ||
@@ -67,3 +74,3 @@ import ts2 from "typescript"; | ||
import ts from "typescript"; | ||
var WrappedSymbol = class _WrappedSymbol { | ||
var WrappedSymbol = class { | ||
typeChecker; | ||
@@ -92,3 +99,3 @@ symbol; | ||
exports.push( | ||
new _WrappedSymbol(this.typeChecker, sym).aliasedSymbolIfNecessary | ||
new WrappedSymbol(this.typeChecker, sym).aliasedSymbolIfNecessary | ||
); | ||
@@ -104,3 +111,3 @@ }); | ||
); | ||
return new _WrappedSymbol(this.typeChecker, newSymbol); | ||
return new WrappedSymbol(this.typeChecker, newSymbol); | ||
} | ||
@@ -118,6 +125,5 @@ return this; | ||
get parameters() { | ||
if (this.symbol.valueDeclaration && // @ts-ignore | ||
this.symbol.valueDeclaration.parameters) { | ||
if (this.symbol.valueDeclaration && this.symbol.valueDeclaration.parameters) { | ||
return this.symbol.valueDeclaration.parameters.map( | ||
(param) => new _WrappedSymbol(this.typeChecker, param.symbol) | ||
(param) => new WrappedSymbol(this.typeChecker, param.symbol) | ||
); | ||
@@ -133,3 +139,2 @@ } | ||
} | ||
// A function is private unless it has a public tag | ||
get isPublic() { | ||
@@ -156,9 +161,2 @@ return this.jsDocTags.some( | ||
} | ||
// public get typeString(): NodeObject { | ||
// const type = this.typeChecker.getDeclaredTypeOfSymbol( | ||
// this.symbol.declarations[0] | ||
// ); | ||
// console.log(' > ', type.intrinsicName); | ||
// return this.typeChecker.typeToString(type); | ||
// } | ||
}; | ||
@@ -168,3 +166,3 @@ | ||
var NO_SYMBOLS_FOUND = "Expected a symbol for location of SourceFile"; | ||
var Project = class _Project { | ||
var _Project = class { | ||
fsMap; | ||
@@ -188,13 +186,2 @@ env; | ||
} | ||
/** | ||
* Add the adaptors type definition to the compilers filesystem map | ||
* @param moduleName the name of the module that will be imported, | ||
* i.e. the adaptors name `@openfn/language-http`. | ||
* @param dts the .d.ts file as a string | ||
*/ | ||
// addTypeDefinition(moduleName: string, dts: string) { | ||
// const typedModulePath = moduleName.replace('@', '').replace('/', '__'); | ||
// this.fsMap.set(`/node_modules/@types/${typedModulePath}/index.d.ts`, dts); | ||
// this.env.createFile(`${typedModulePath}.d.ts`, dts); | ||
// } | ||
addTypeDefinition(moduleName, dts, fileName = "index.d.ts") { | ||
@@ -205,8 +192,2 @@ const typedModulePath = moduleName.replace("@", "").replace("/", "__"); | ||
} | ||
// addAdaptorFSMap(adaptorPackagePath: string) { | ||
// addAdaptorFSMap(this.fsMap, adaptorPackagePath) | ||
// } | ||
// wrap(func: (sf: ts.SourceFile, ...args: any[]) => ts.SourceFile, ...args: any[]) { | ||
// return func(this.sourceFile, ...args) | ||
// } | ||
get program() { | ||
@@ -224,9 +205,2 @@ return this.env.languageService.getProgram(); | ||
} | ||
/** | ||
* Add a file to the environment. | ||
* | ||
* Note that files added via the constructor are not considered part of the | ||
* 'project', rather files available for reading during diagnostics and | ||
* compilation. To add packages or type definitions use `addFile`. | ||
*/ | ||
createFile(expression, filename = "index.ts") { | ||
@@ -236,8 +210,2 @@ this.env.createFile(filename, expression); | ||
} | ||
/** | ||
* Add a file to the system. | ||
* | ||
* Differs from `createFile` in that these files are not considered part of | ||
* the project - but part of the file system. | ||
*/ | ||
addToFS(mapOrContent, path) { | ||
@@ -252,10 +220,2 @@ if (path) { | ||
} | ||
// useTransform(func: () => ts.TransformerFactory<ts.SourceFile>) { | ||
// this.transformers.push(func) | ||
// } | ||
/** | ||
* Return a list of symbols that have been marked for export. | ||
* In the case of aliases (`export {a, b}`), these aliases are followed | ||
* to their original symbol. | ||
*/ | ||
getSymbol(sourceFile) { | ||
@@ -302,3 +262,2 @@ const sfSymbol = this.typeChecker.getSymbolAtLocation(sourceFile); | ||
), | ||
// [transformer(this.program, {})], | ||
after: [], | ||
@@ -309,28 +268,18 @@ afterDeclarations: [] | ||
} | ||
static compilerOpts = { | ||
allowJs: true, | ||
experimentalDecorators: true, | ||
module: ts2.ModuleKind.ES2020, | ||
moduleResolution: ts2.ModuleResolutionKind.NodeJs, | ||
noEmitOnError: false, | ||
noUnusedLocals: true, | ||
noUnusedParameters: true, | ||
stripInternal: true, | ||
declaration: false, | ||
baseUrl: "/", | ||
// outDir: "/dist", | ||
lib: ["ES2020"], | ||
target: ts2.ScriptTarget.ES2020 | ||
}; | ||
// transform(): ts.TransformationResult<ts.Node> { | ||
// const transformedSourceFile = ts.transform( | ||
// this.sourceFile, | ||
// [transformer(this.program, this.transformOptions)], | ||
// BaseCompiler.compilerOpts | ||
// ) | ||
// return transformedSourceFile | ||
// // const printer = ts.createPrinter({ newLine: ts.NewLineKind.LineFeed }); | ||
// // return printer.printFile(transformedSourceFile[0]); | ||
// } | ||
}; | ||
var Project = _Project; | ||
__publicField(Project, "compilerOpts", { | ||
allowJs: true, | ||
experimentalDecorators: true, | ||
module: ts2.ModuleKind.ES2020, | ||
moduleResolution: ts2.ModuleResolutionKind.NodeJs, | ||
noEmitOnError: false, | ||
noUnusedLocals: true, | ||
noUnusedParameters: true, | ||
stripInternal: true, | ||
declaration: false, | ||
baseUrl: "/", | ||
lib: ["ES2020"], | ||
target: ts2.ScriptTarget.ES2020 | ||
}); | ||
@@ -502,3 +451,3 @@ // src/describe-project.ts | ||
import urlJoin from "url-join"; | ||
var Pack = class _Pack { | ||
var Pack = class { | ||
path; | ||
@@ -522,7 +471,2 @@ _packageJson; | ||
} | ||
/** | ||
* The file contents of the package according to the source. | ||
* | ||
* _Different to `fsMap`, which includes the `root`._ | ||
*/ | ||
get fileListing() { | ||
@@ -534,18 +478,5 @@ if (!this._fileListing) { | ||
} | ||
/** | ||
* The absolute name and version of the package. | ||
* | ||
* i.e. `@<org>/<package>@<version>` | ||
* | ||
* This may differ from the `path` passed in during creation. | ||
* For example, if the package path was `mypackage@latest` and the latest | ||
* version is `1.2.3` as stated by the `package.json` the resulting | ||
* specifier will be `mypackage@1.2.3`. | ||
*/ | ||
get specifier() { | ||
return `${this.packageJson.name}@${this.packageJson.version}`; | ||
} | ||
/** | ||
* The version of the package specified in the `package.json` | ||
*/ | ||
get version() { | ||
@@ -561,6 +492,2 @@ return this.packageJson.version; | ||
} | ||
/** | ||
* Get the "types" property from `package.json`, and ensure it's path is | ||
* relative to `/`. | ||
*/ | ||
get types() { | ||
@@ -582,3 +509,3 @@ if (!this.packageJson.types) | ||
static async fetch(specifier) { | ||
const pack = new _Pack({ | ||
const pack = new Pack({ | ||
path: specifier, | ||
@@ -585,0 +512,0 @@ packageJson: JSON.parse(await fetchFile(specifier + "/package.json")), |
{ | ||
"name": "@openfn/describe-package", | ||
"version": "0.0.17", | ||
"version": "0.0.18", | ||
"description": "Utilities to inspect an npm package.", | ||
@@ -40,3 +40,3 @@ "author": "Open Function Group <admin@openfn.org>", | ||
"tsm": "^2.2.1", | ||
"tsup": "^7.1.0" | ||
"tsup": "^6.2.3" | ||
}, | ||
@@ -43,0 +43,0 @@ "files": [ |
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
3607613
17149