@plugjs/tsd 0.2.0

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/README.md ADDED
@@ -0,0 +1,7 @@
1
+ Zip File Plugin for the PlugJS Build System
2
+ ===========================================
3
+
4
+ Prototype build system from [Juit GmbH](https://www.juit.com/)
5
+
6
+ * [Copyright Notice](https://github.com/plugjs/plug/blob/main/NOTICE.md)
7
+ * [License](https://github.com/plugjs/plug/blob/main/LICENSE.md)
package/dist/index.cjs ADDED
@@ -0,0 +1,22 @@
1
+ "use strict";
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
6
+ var __copyProps = (to, from, except, desc) => {
7
+ if (from && typeof from === "object" || typeof from === "function") {
8
+ for (let key of __getOwnPropNames(from))
9
+ if (!__hasOwnProp.call(to, key) && key !== except)
10
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
11
+ }
12
+ return to;
13
+ };
14
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
15
+
16
+ // index.ts
17
+ var src_exports = {};
18
+ module.exports = __toCommonJS(src_exports);
19
+ var import_fork = require("@plugjs/plug/fork");
20
+ var import_paths = require("@plugjs/plug/paths");
21
+ (0, import_fork.installForking)("tsd", (0, import_paths.requireResolve)(__filename, "./tsd"), "Tsd");
22
+ //# sourceMappingURL=index.cjs.map
@@ -0,0 +1,6 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../src/index.ts"],
4
+ "mappings": ";;;;;;;;;;;;;;;;AAAA;AAAA;AAAA,kBAA+B;AAC/B,mBAA+B;AAAA,IAkB/B,4BAAe,WAAO,6BAAe,YAAW,OAAO,GAAG,KAAK;",
5
+ "names": []
6
+ }
@@ -0,0 +1,14 @@
1
+ export interface TsdOptions {
2
+ cwd?: string;
3
+ typingsFile?: string;
4
+ }
5
+ declare module '@plugjs/plug' {
6
+ interface Pipe {
7
+ /**
8
+ * Run all tests from incoming {@link Files} with `Tsd`.
9
+ *
10
+ * @param options Options to comfigure Tsd.
11
+ */
12
+ tsd(options?: TsdOptions): Pipe;
13
+ }
14
+ }
package/dist/index.mjs ADDED
@@ -0,0 +1,5 @@
1
+ // index.ts
2
+ import { installForking } from "@plugjs/plug/fork";
3
+ import { requireResolve } from "@plugjs/plug/paths";
4
+ installForking("tsd", requireResolve(import.meta.url, "./tsd"), "Tsd");
5
+ //# sourceMappingURL=index.mjs.map
@@ -0,0 +1,6 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../src/index.ts"],
4
+ "mappings": ";AAAA,SAAS,sBAAsB;AAC/B,SAAS,sBAAsB;AAkB/B,eAAe,OAAO,eAAe,iBAAW,OAAO,GAAG,KAAK;",
5
+ "names": []
6
+ }
package/dist/tsd.cjs ADDED
@@ -0,0 +1,78 @@
1
+ "use strict";
2
+ var __create = Object.create;
3
+ var __defProp = Object.defineProperty;
4
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
+ var __getOwnPropNames = Object.getOwnPropertyNames;
6
+ var __getProtoOf = Object.getPrototypeOf;
7
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
8
+ var __export = (target, all) => {
9
+ for (var name in all)
10
+ __defProp(target, name, { get: all[name], enumerable: true });
11
+ };
12
+ var __copyProps = (to, from, except, desc) => {
13
+ if (from && typeof from === "object" || typeof from === "function") {
14
+ for (let key of __getOwnPropNames(from))
15
+ if (!__hasOwnProp.call(to, key) && key !== except)
16
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
17
+ }
18
+ return to;
19
+ };
20
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
21
+ // If the importer is in node compatibility mode or this is not an ESM
22
+ // file that has been converted to a CommonJS file using a Babel-
23
+ // compatible transform (i.e. "__esModule" has not been set), then set
24
+ // "default" to the CommonJS "module.exports" for node compatibility.
25
+ isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
26
+ mod
27
+ ));
28
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
29
+
30
+ // tsd.ts
31
+ var tsd_exports = {};
32
+ __export(tsd_exports, {
33
+ Tsd: () => Tsd
34
+ });
35
+ module.exports = __toCommonJS(tsd_exports);
36
+ var import_plug = require("@plugjs/plug");
37
+ var import_logging = require("@plugjs/plug/logging");
38
+ var import_paths = require("@plugjs/plug/paths");
39
+ var tsdLib = __toESM(require("tsd"));
40
+ var tsd = tsdLib.default.default ? tsdLib.default.default : tsdLib.default;
41
+ var Tsd = class {
42
+ constructor(_options = {}) {
43
+ this._options = _options;
44
+ }
45
+ async pipe(files, context) {
46
+ const { cwd: _cwd, typingsFile: _typingsFile } = this._options;
47
+ const cwd = _cwd ? (0, import_plug.resolve)(_cwd) : (
48
+ /* coverage ignore next */
49
+ (0, import_paths.getCurrentWorkingDirectory)()
50
+ );
51
+ const typingsFile = _typingsFile && (0, import_paths.assertRelativeChildPath)(cwd, (0, import_plug.resolve)(_typingsFile));
52
+ const testFiles = [...import_plug.Files.builder(cwd).add(...files.absolutePaths()).build()];
53
+ void 0, context, this._options;
54
+ const diagnostics = await tsd({
55
+ cwd,
56
+ typingsFile,
57
+ testFiles
58
+ });
59
+ const report = context.log.report("Typescript Definitions Test");
60
+ for (const diag of diagnostics) {
61
+ const { fileName, column, line, message, severity } = diag;
62
+ const file = (0, import_paths.resolveAbsolutePath)(cwd, fileName);
63
+ const level = severity === "warning" ? import_logging.WARN : import_logging.ERROR;
64
+ if (level === import_logging.WARN && /__file_marker__/gm.test(message)) {
65
+ report.annotate(import_logging.NOTICE, file, "mark");
66
+ } else {
67
+ report.add({ line, column, file, message, level });
68
+ }
69
+ }
70
+ await report.loadSources();
71
+ report.done(true);
72
+ }
73
+ };
74
+ // Annotate the CommonJS export names for ESM import in node:
75
+ 0 && (module.exports = {
76
+ Tsd
77
+ });
78
+ //# sourceMappingURL=tsd.cjs.map
@@ -0,0 +1,6 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../src/tsd.ts"],
4
+ "mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAGA,kBAA+B;AAC/B,qBAAoC;AACpC,mBAAyF;AACzF,aAAwB;AAMxB,IAAM,MACW,eAAQ,UACN,eAAQ,UAChB;AAIJ,IAAM,MAAN,MAAgC;AAAA,EAErC,YAA6B,WAAuB,CAAC,GAAG;AAA3B;AAAA,EAA4B;AAAA,EAEzD,MAAM,KAAK,OAAc,SAAiC;AACxD,UAAM,EAAE,KAAK,MAAM,aAAa,aAAa,IAAI,KAAK;AAItD,UAAM,MAAM,WAAO,qBAAQ,IAAI;AAAA;AAAA,UAA+B,yCAA2B;AAAA;AACzF,UAAM,cAAc,oBAAgB,sCAAwB,SAAK,qBAAQ,YAAY,CAAC;AAGtF,UAAM,YAAY,CAAE,GAAG,kBAAM,QAAQ,GAAG,EAAE,IAAI,GAAG,MAAM,cAAc,CAAC,EAAE,MAAM,CAAE;AAChF,YAAY,SAAS,KAAK;AAG1B,UAAM,cAAc,MAAM,IAAI;AAAA,MAC5B;AAAA,MACA;AAAA,MACA;AAAA,IACF,CAAC;AAGD,UAAM,SAAS,QAAQ,IAAI,OAAO,6BAA6B;AAC/D,eAAW,QAAQ,aAAa;AAC9B,YAAM,EAAE,UAAU,QAAQ,MAAM,SAAS,SAAS,IAAI;AACtD,YAAM,WAAO,kCAAoB,KAAK,QAAQ;AAC9C,YAAM,QAAQ,aAAa,YAAY,sBAAO;AAE9C,UAAK,UAAU,uBAAU,oBAAoB,KAAK,OAAO,GAAI;AAC3D,eAAO,SAAS,uBAAQ,MAAM,MAAM;AAAA,MACtC,OAAO;AACL,eAAO,IAAI,EAAE,MAAM,QAAQ,MAAM,SAAS,MAAM,CAAC;AAAA,MACnD;AAAA,IACF;AAGA,UAAM,OAAO,YAAY;AACzB,WAAO,KAAK,IAAI;AAAA,EAClB;AACF;",
5
+ "names": []
6
+ }
package/dist/tsd.d.ts ADDED
@@ -0,0 +1,9 @@
1
+ /// <reference path="index.d.ts" />
2
+ import { Files } from '@plugjs/plug';
3
+ import type { Context, PipeParameters, Plug } from '@plugjs/plug/pipe';
4
+ /** Writes some info about the current {@link Files} being passed around. */
5
+ export declare class Tsd implements Plug<void> {
6
+ private readonly _options;
7
+ constructor(...args: PipeParameters<'tsd'>);
8
+ pipe(files: Files, context: Context): Promise<void>;
9
+ }
package/dist/tsd.mjs ADDED
@@ -0,0 +1,43 @@
1
+ // tsd.ts
2
+ import { Files, resolve } from "@plugjs/plug";
3
+ import { ERROR, NOTICE, WARN } from "@plugjs/plug/logging";
4
+ import { assertRelativeChildPath, getCurrentWorkingDirectory, resolveAbsolutePath } from "@plugjs/plug/paths";
5
+ import * as tsdLib from "tsd";
6
+ var tsd = tsdLib.default.default ? tsdLib.default.default : tsdLib.default;
7
+ var Tsd = class {
8
+ constructor(_options = {}) {
9
+ this._options = _options;
10
+ }
11
+ async pipe(files, context) {
12
+ const { cwd: _cwd, typingsFile: _typingsFile } = this._options;
13
+ const cwd = _cwd ? resolve(_cwd) : (
14
+ /* coverage ignore next */
15
+ getCurrentWorkingDirectory()
16
+ );
17
+ const typingsFile = _typingsFile && assertRelativeChildPath(cwd, resolve(_typingsFile));
18
+ const testFiles = [...Files.builder(cwd).add(...files.absolutePaths()).build()];
19
+ void 0, context, this._options;
20
+ const diagnostics = await tsd({
21
+ cwd,
22
+ typingsFile,
23
+ testFiles
24
+ });
25
+ const report = context.log.report("Typescript Definitions Test");
26
+ for (const diag of diagnostics) {
27
+ const { fileName, column, line, message, severity } = diag;
28
+ const file = resolveAbsolutePath(cwd, fileName);
29
+ const level = severity === "warning" ? WARN : ERROR;
30
+ if (level === WARN && /__file_marker__/gm.test(message)) {
31
+ report.annotate(NOTICE, file, "mark");
32
+ } else {
33
+ report.add({ line, column, file, message, level });
34
+ }
35
+ }
36
+ await report.loadSources();
37
+ report.done(true);
38
+ }
39
+ };
40
+ export {
41
+ Tsd
42
+ };
43
+ //# sourceMappingURL=tsd.mjs.map
@@ -0,0 +1,6 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../src/tsd.ts"],
4
+ "mappings": ";AAGA,SAAS,OAAO,eAAe;AAC/B,SAAS,OAAO,QAAQ,YAAY;AACpC,SAAS,yBAAyB,4BAA4B,2BAA2B;AACzF,YAAY,YAAY;AAMxB,IAAM,MACW,eAAQ,UACN,eAAQ,UAChB;AAIJ,IAAM,MAAN,MAAgC;AAAA,EAErC,YAA6B,WAAuB,CAAC,GAAG;AAA3B;AAAA,EAA4B;AAAA,EAEzD,MAAM,KAAK,OAAc,SAAiC;AACxD,UAAM,EAAE,KAAK,MAAM,aAAa,aAAa,IAAI,KAAK;AAItD,UAAM,MAAM,OAAO,QAAQ,IAAI;AAAA;AAAA,MAA+B,2BAA2B;AAAA;AACzF,UAAM,cAAc,gBAAgB,wBAAwB,KAAK,QAAQ,YAAY,CAAC;AAGtF,UAAM,YAAY,CAAE,GAAG,MAAM,QAAQ,GAAG,EAAE,IAAI,GAAG,MAAM,cAAc,CAAC,EAAE,MAAM,CAAE;AAChF,YAAY,SAAS,KAAK;AAG1B,UAAM,cAAc,MAAM,IAAI;AAAA,MAC5B;AAAA,MACA;AAAA,MACA;AAAA,IACF,CAAC;AAGD,UAAM,SAAS,QAAQ,IAAI,OAAO,6BAA6B;AAC/D,eAAW,QAAQ,aAAa;AAC9B,YAAM,EAAE,UAAU,QAAQ,MAAM,SAAS,SAAS,IAAI;AACtD,YAAM,OAAO,oBAAoB,KAAK,QAAQ;AAC9C,YAAM,QAAQ,aAAa,YAAY,OAAO;AAE9C,UAAK,UAAU,QAAU,oBAAoB,KAAK,OAAO,GAAI;AAC3D,eAAO,SAAS,QAAQ,MAAM,MAAM;AAAA,MACtC,OAAO;AACL,eAAO,IAAI,EAAE,MAAM,QAAQ,MAAM,SAAS,MAAM,CAAC;AAAA,MACnD;AAAA,IACF;AAGA,UAAM,OAAO,YAAY;AACzB,WAAO,KAAK,IAAI;AAAA,EAClB;AACF;",
5
+ "names": []
6
+ }
package/package.json ADDED
@@ -0,0 +1,33 @@
1
+ {
2
+ "name": "@plugjs/tsd",
3
+ "version": "0.2.0",
4
+ "type": "commonjs",
5
+ "main": "./dist/index.cjs",
6
+ "module": "./dist/index.mjs",
7
+ "types": "./dist/index.d.ts",
8
+ "exports": {
9
+ ".": {
10
+ "require": {
11
+ "types": "./dist/index.d.ts",
12
+ "default": "./dist/index.cjs"
13
+ },
14
+ "import": {
15
+ "types": "./dist/index.d.ts",
16
+ "default": "./dist/index.mjs"
17
+ }
18
+ }
19
+ },
20
+ "author": "Juit Developers <developers@juit.com>",
21
+ "license": "Apache-2.0",
22
+ "dependencies": {
23
+ "tsd": "^0.25.0"
24
+ },
25
+ "peerDependencies": {
26
+ "@plugjs/plug": "0.2.0"
27
+ },
28
+ "files": [
29
+ "*.md",
30
+ "dist/",
31
+ "src/"
32
+ ]
33
+ }
package/src/index.ts ADDED
@@ -0,0 +1,20 @@
1
+ import { installForking } from '@plugjs/plug/fork'
2
+ import { requireResolve } from '@plugjs/plug/paths'
3
+
4
+ export interface TsdOptions {
5
+ cwd?: string,
6
+ typingsFile?: string,
7
+ }
8
+
9
+ declare module '@plugjs/plug' {
10
+ export interface Pipe {
11
+ /**
12
+ * Run all tests from incoming {@link Files} with `Tsd`.
13
+ *
14
+ * @param options Options to comfigure Tsd.
15
+ */
16
+ tsd(options?: TsdOptions): Pipe
17
+ }
18
+ }
19
+
20
+ installForking('tsd', requireResolve(__fileurl, './tsd'), 'Tsd')
package/src/tsd.ts ADDED
@@ -0,0 +1,60 @@
1
+ // Reference ourselves, so that the constructor's parameters are correct
2
+ /// <reference path="./index.ts" />
3
+
4
+ import { Files, resolve } from '@plugjs/plug'
5
+ import { ERROR, NOTICE, WARN } from '@plugjs/plug/logging'
6
+ import { assertRelativeChildPath, getCurrentWorkingDirectory, resolveAbsolutePath } from '@plugjs/plug/paths'
7
+ import * as tsdLib from 'tsd'
8
+
9
+ import type { Context, PipeParameters, Plug } from '@plugjs/plug/pipe'
10
+ import type { TsdOptions } from './index'
11
+
12
+ // I _hate_ default exports!
13
+ const tsd: typeof tsdLib.default =
14
+ (<any> tsdLib).default.default ?
15
+ (<any> tsdLib).default.default :
16
+ tsdLib.default
17
+
18
+
19
+ /** Writes some info about the current {@link Files} being passed around. */
20
+ export class Tsd implements Plug<void> {
21
+ constructor(...args: PipeParameters<'tsd'>)
22
+ constructor(private readonly _options: TsdOptions = {}) {}
23
+
24
+ async pipe(files: Files, context: Context): Promise<void> {
25
+ const { cwd: _cwd, typingsFile: _typingsFile } = this._options
26
+
27
+ // Resolve the absolute directory, and optionally the typings file relative to it
28
+ const cwd = _cwd ? resolve(_cwd) : /* coverage ignore next */ getCurrentWorkingDirectory()
29
+ const typingsFile = _typingsFile && assertRelativeChildPath(cwd, resolve(_typingsFile))
30
+
31
+ // Convert incoming files, relativizing them to the `cwd` specified in options
32
+ const testFiles = [ ...Files.builder(cwd).add(...files.absolutePaths()).build() ]
33
+ void files, context, this._options
34
+
35
+ // Let TSD do its thing
36
+ const diagnostics = await tsd({
37
+ cwd,
38
+ typingsFile,
39
+ testFiles,
40
+ })
41
+
42
+ // Prepare a report out of the diagnostics
43
+ const report = context.log.report('Typescript Definitions Test')
44
+ for (const diag of diagnostics) {
45
+ const { fileName, column, line, message, severity } = diag
46
+ const file = resolveAbsolutePath(cwd, fileName)
47
+ const level = severity === 'warning' ? WARN : ERROR
48
+
49
+ if ((level === WARN) && (/__file_marker__/gm.test(message))) {
50
+ report.annotate(NOTICE, file, 'mark')
51
+ } else {
52
+ report.add({ line, column, file, message, level })
53
+ }
54
+ }
55
+
56
+ // Load up sources and report!
57
+ await report.loadSources()
58
+ report.done(true)
59
+ }
60
+ }