@nitpicker/core 0.6.4 → 0.6.5-alpha.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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nitpicker/core",
3
- "version": "0.6.4",
3
+ "version": "0.6.5-alpha.0",
4
4
  "description": "Plugin-based page analysis engine for Nitpicker",
5
5
  "author": "D-ZERO",
6
6
  "license": "Apache-2.0",
@@ -29,11 +29,11 @@
29
29
  "dependencies": {
30
30
  "@d-zero/dealer": "1.7.0",
31
31
  "@d-zero/shared": "0.20.1",
32
- "@nitpicker/crawler": "0.6.3",
33
- "@nitpicker/types": "0.6.3",
32
+ "@nitpicker/crawler": "0.6.5-alpha.0",
33
+ "@nitpicker/types": "0.6.5-alpha.0",
34
34
  "ansi-colors": "4.1.3",
35
35
  "cosmiconfig": "9.0.0",
36
36
  "jsdom": "28.1.0"
37
37
  },
38
- "gitHead": "840d4c33a2d0ea9469d511b4f74a69f7fb38ee2b"
38
+ "gitHead": "e084aba5a0887a80059ff8aa0608f61a58cc9288"
39
39
  }
@@ -1,12 +0,0 @@
1
- /**
2
- * Walks up from the current module's directory to locate the parent
3
- * `@nitpicker` directory in the file system.
4
- *
5
- * This is used by plugin discovery and label resolution to find
6
- * where `@nitpicker/*` packages are installed on disk. The traversal
7
- * starts from `import.meta.url` of the calling module (i.e. this file,
8
- * which lives inside `@nitpicker/core`) and walks up until it finds
9
- * a directory named `@nitpicker`.
10
- * @returns Absolute path to the `@nitpicker` directory, or `null` if not found.
11
- */
12
- export declare function findNitpickerModulesDir(): string | null;
@@ -1,23 +0,0 @@
1
- import path from 'node:path';
2
- /**
3
- * Walks up from the current module's directory to locate the parent
4
- * `@nitpicker` directory in the file system.
5
- *
6
- * This is used by plugin discovery and label resolution to find
7
- * where `@nitpicker/*` packages are installed on disk. The traversal
8
- * starts from `import.meta.url` of the calling module (i.e. this file,
9
- * which lives inside `@nitpicker/core`) and walks up until it finds
10
- * a directory named `@nitpicker`.
11
- * @returns Absolute path to the `@nitpicker` directory, or `null` if not found.
12
- */
13
- export function findNitpickerModulesDir() {
14
- const __filename = new URL(import.meta.url).pathname;
15
- let dir = path.dirname(__filename);
16
- while (dir !== path.dirname(dir)) {
17
- if (path.basename(dir) === '@nitpicker') {
18
- return dir;
19
- }
20
- dir = path.dirname(dir);
21
- }
22
- return null;
23
- }
@@ -1,9 +0,0 @@
1
- import type { StartAction } from '../types.js';
2
- declare const _default: {
3
- audit: {
4
- start: import("typescript-fsa").ActionCreator<StartAction>;
5
- log: import("typescript-fsa").ActionCreator<string>;
6
- finish: import("typescript-fsa").ActionCreator<void>;
7
- };
8
- };
9
- export default _default;
@@ -1,9 +0,0 @@
1
- import { actionCreatorFactory } from 'typescript-fsa';
2
- const auditActionCreator = actionCreatorFactory('@@hook/audit');
3
- export default {
4
- audit: {
5
- start: auditActionCreator('START'),
6
- log: auditActionCreator('LOG'),
7
- finish: auditActionCreator('FINISH'),
8
- },
9
- };
@@ -1 +0,0 @@
1
- export {};
@@ -1,34 +0,0 @@
1
- // Run on child_process
2
- import { Archive } from '@nitpicker/crawler';
3
- import { isType } from 'typescript-fsa';
4
- import actions from './actions.js';
5
- const crateTable = (headers, data, options) => ({
6
- headers,
7
- data,
8
- options,
9
- });
10
- process.on('message', async (action) => {
11
- if (isType(action, actions.audit.start)) {
12
- const mod = await import(action.payload.hookModulePath);
13
- const pluginHook = mod.default;
14
- const hook = await pluginHook(action.payload.settings || {}, action.payload.configFilePath);
15
- if (hook.audit) {
16
- const archive = await Archive.connect(action.payload.archiveTempDir, action.payload.hookModuleName);
17
- const pluginReport = await hook.audit(archive, (log) => {
18
- if (process.send) {
19
- process.send(actions.audit.log(log));
20
- }
21
- }, action.payload.configFilePath, crateTable);
22
- if (pluginReport) {
23
- const data = {
24
- name: action.payload.hookModuleName,
25
- ...pluginReport,
26
- };
27
- await archive.setData('reports', data);
28
- }
29
- }
30
- if (process.send) {
31
- process.send(actions.audit.finish());
32
- }
33
- }
34
- });
@@ -1 +0,0 @@
1
- export { definePlugin } from './define-plugin.js';
@@ -1 +0,0 @@
1
- export { definePlugin } from './define-plugin.js';
@@ -1,10 +0,0 @@
1
- import type { StartAction } from '../types.js';
2
- import type { ProcessLogger } from '@nitpicker/types';
3
- import actions from './actions.js';
4
- /**
5
- *
6
- * @param phase
7
- * @param startActionParam
8
- * @param log
9
- */
10
- export declare function runner(phase: keyof typeof actions, startActionParam: StartAction, log: ProcessLogger): Promise<void>;
@@ -1,32 +0,0 @@
1
- import childProcess from 'node:child_process';
2
- import path from 'node:path';
3
- import { isType } from 'typescript-fsa';
4
- import actions from './actions.js';
5
- const __filename = new URL(import.meta.url).pathname;
6
- const __dirname = path.dirname(__filename);
7
- /**
8
- *
9
- * @param phase
10
- * @param startActionParam
11
- * @param log
12
- */
13
- export function runner(phase, startActionParam, log) {
14
- log('Fork process');
15
- const child = childProcess.fork(path.join(__dirname, 'child-process'));
16
- const actionOnPhase = actions[phase];
17
- const session = new Promise((resolve) => {
18
- child.on('message', (action) => {
19
- if (isType(action, actionOnPhase.log)) {
20
- log(action.payload);
21
- }
22
- if (isType(action, actionOnPhase.finish)) {
23
- child.disconnect();
24
- log('Finished');
25
- resolve();
26
- }
27
- });
28
- });
29
- child.send(actionOnPhase.start(startActionParam));
30
- log('Started');
31
- return session;
32
- }
package/lib/index.d.ts DELETED
@@ -1,5 +0,0 @@
1
- export { Nitpicker } from './nitpicker.js';
2
- export { definePlugin } from './hooks/index.js';
3
- export { readPluginLabels } from './read-plugin-labels.js';
4
- export { runInWorker } from './worker/run-in-worker.js';
5
- export * from './types.js';
package/lib/index.js DELETED
@@ -1,5 +0,0 @@
1
- export { Nitpicker } from './nitpicker.js';
2
- export { definePlugin } from './hooks/index.js';
3
- export { readPluginLabels } from './read-plugin-labels.js';
4
- export { runInWorker } from './worker/run-in-worker.js';
5
- export * from './types.js';
package/lib/utils.d.ts DELETED
@@ -1,36 +0,0 @@
1
- type SequentialEachChunkCallback<R, T> = (item: T, i: number) => Promise<R>;
2
- /**
3
- * Sequential processing each chunk
4
- *
5
- * 1. Split an array
6
- * ┌───────── array ────────┐
7
- * chunk1 │ chunk2 | chunk3
8
- * ├item ├item ├item
9
- * ├item ├item ├item
10
- * └item └item └item
11
- *
12
- * 2. Runs parallel and sequential
13
- * chunk1 ┬ callback(item) ┐
14
- * │ ├ callback(item) │ Promise.all
15
- * │ └ callback(item) ┘
16
- * │
17
- * (Sequential)
18
- * │
19
- * chunk2 ┬ callback(item) ┐
20
- * │ ├ callback(item) │ Promise.all
21
- * │ └ callback(item) ┘
22
- * │
23
- * (Sequential)
24
- * │
25
- * chunk3 ┬ callback(item) ┐
26
- * │ ├ callback(item) │ Promise.all
27
- * │ └ callback(item) ┘
28
- * │
29
- * (Done)
30
- * @param array
31
- * @param split
32
- * @param callback
33
- * @returns
34
- */
35
- export declare function sequentialEachChunk<R, T>(array: T[], split: number, callback: SequentialEachChunkCallback<R, T>): Promise<R[]>;
36
- export {};
package/lib/utils.js DELETED
@@ -1,43 +0,0 @@
1
- /**
2
- * Sequential processing each chunk
3
- *
4
- * 1. Split an array
5
- * ┌───────── array ────────┐
6
- * chunk1 │ chunk2 | chunk3
7
- * ├item ├item ├item
8
- * ├item ├item ├item
9
- * └item └item └item
10
- *
11
- * 2. Runs parallel and sequential
12
- * chunk1 ┬ callback(item) ┐
13
- * │ ├ callback(item) │ Promise.all
14
- * │ └ callback(item) ┘
15
- * │
16
- * (Sequential)
17
- * │
18
- * chunk2 ┬ callback(item) ┐
19
- * │ ├ callback(item) │ Promise.all
20
- * │ └ callback(item) ┘
21
- * │
22
- * (Sequential)
23
- * │
24
- * chunk3 ┬ callback(item) ┐
25
- * │ ├ callback(item) │ Promise.all
26
- * │ └ callback(item) ┘
27
- * │
28
- * (Done)
29
- * @param array
30
- * @param split
31
- * @param callback
32
- * @returns
33
- */
34
- export async function sequentialEachChunk(array, split, callback) {
35
- array = [...array];
36
- const result = [];
37
- do {
38
- const chunk = array.splice(0, split);
39
- const segRes = await Promise.all(chunk.map((item, i) => callback(item, i + result.length)));
40
- result.push(...segRes);
41
- } while (array.length > 0);
42
- return result;
43
- }