Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Sort requires #290

Merged
merged 3 commits into from
Oct 31, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 9 additions & 10 deletions lib/anonymize.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,18 +4,11 @@ so that the CLI tests (in the `test/` folder) have the same output on different
machines, and also the same output when only the CLI version changes.
*/

const path = require('node:path');

/**
* @import {Options} from "./types/options"
* @import {Path} from "./types/path"
* @import {Options} from './types/options';
* @import {Path} from './types/path';
*/

module.exports = {
pathsAndVersions,
path: anonymizePath,
version
};
const path = require('node:path');

/**
* Strip the version and paths out of the given string.
Expand Down Expand Up @@ -75,3 +68,9 @@ function version(options) {

return options.packageJsonVersion;
}

module.exports = {
pathsAndVersions,
path: anonymizePath,
version
};
33 changes: 17 additions & 16 deletions lib/app-wrapper.js
Original file line number Diff line number Diff line change
@@ -1,25 +1,13 @@
const path = require('node:path');
const {Worker} = require('node:worker_threads');
const ElmCommunication = require('./elm-communication');
const loadCompiledElmApp = require('./load-compiled-app');

/**
* @import {Options} from './types/options'
* @import {CallbackFn, Listened, Port} from './types/promisify-port'
* @import {Flags} from './types/flags'
* @import {App} from './types/app'
*/

module.exports = {
init,
stop: () => {
if (worker) {
worker.terminate();
worker = null;
listeners = initializeListeners();
}
}
};
const path = require('node:path');
const {Worker} = require('node:worker_threads');
const ElmCommunication = require('./elm-communication');
const loadCompiledElmApp = require('./load-compiled-app');

/**
* @param {Options} options
Expand Down Expand Up @@ -157,3 +145,16 @@ function initWithoutWorker(elmModulePath, flags) {
});
return app;
}

function stop() {
if (worker) {
worker.terminate();
worker = null;
listeners = initializeListeners();
}
}

module.exports = {
init,
stop
};
39 changes: 19 additions & 20 deletions lib/autofix.js
Original file line number Diff line number Diff line change
@@ -1,30 +1,25 @@
/**
* @import {App, AutofixRequest} from './types/app';
* @import {File} from './types/content';
* @import {VersionString} from './types/version';
* @import {Options} from './types/options';
* @import {Path} from './types/path';
* @import {FilesProposedByCurrentFix} from './types/state';
*/
const fs = require('node:fs');
const path = require('node:path');
const chalk = require('chalk');
const prompts = require('prompts');
const spawn = require('cross-spawn');
const FS = require('./fs-wrapper');
const AppState = require('./state');
const prompts = require('prompts');
const exit = require('../vendor/exit');
const ErrorMessage = require('./error-message');
const FS = require('./fs-wrapper');
const {backwardsCompatiblePath, pathKey} = require('./npx');
const ProjectDependencies = require('./project-dependencies');
const promisifyPort = require('./promisify-port');
const StyledMessage = require('./styled-message');
const {startReview} = require('./run-review');
const ProjectDependencies = require('./project-dependencies');
const exit = require('../vendor/exit');
const {backwardsCompatiblePath, pathKey} = require('./npx');

/**
* @import {App, AutofixRequest} from "./types/app"
* @import {File} from "./types/content"
* @import {VersionString} from "./types/version"
* @import {Options} from "./types/options"
* @import {Path} from "./types/path"
* @import {FilesProposedByCurrentFix} from "./types/state"
*/

module.exports = {
subscribe
};
const AppState = require('./state');
const StyledMessage = require('./styled-message');

/**
* Subscribe to fix requests to prompt the user.
Expand Down Expand Up @@ -237,3 +232,7 @@ ${result.stderr.toString()}`,
source: fs.readFileSync(filePath, 'utf8')
};
}

module.exports = {
subscribe
};
12 changes: 6 additions & 6 deletions lib/benchmark.js
Original file line number Diff line number Diff line change
@@ -1,12 +1,7 @@
/**
* @import {OptionsBase} from "./types/options"
* @import {OptionsBase} from './types/options';
*/

module.exports = {
start,
end
};

/**
* Start a benchmark labelled with the given name.
*
Expand All @@ -32,3 +27,8 @@ function end(options, name) {
console.timeEnd(name);
}
}

module.exports = {
start,
end
};
35 changes: 17 additions & 18 deletions lib/build.js
Original file line number Diff line number Diff line change
@@ -1,31 +1,30 @@
const fs = require('graceful-fs');
/**
* @import {AppHash, BuildResult} from './types/build';
* @import {ApplicationElmJson} from './types/content';
* @import {VersionString} from './types/version';
* @import {Options, Template} from './types/options';
* @import {Path} from './types/path';
* @import {CompileOptions} from '../vendor/types/node-elm-compiler';
*/
const path = require('node:path');
const crypto = require('node:crypto');
const chalk = require('chalk');
const wrap = require('wrap-ansi');
const {hashElement} = require('folder-hash');
const fs = require('graceful-fs');
const wrap = require('wrap-ansi');
const exit = require('../vendor/exit');
const elmCompiler = require('../vendor/node-elm-compiler');
const {getElmBinary} = require('./elm-binary');
const Debug = require('./debug');
const FS = require('./fs-wrapper');
const Spinner = require('./spinner');
const Anonymize = require('./anonymize');
const Benchmark = require('./benchmark');
const OptimizeJs = require('./optimize-js');
const MinVersion = require('./min-version');
const Debug = require('./debug');
const {getElmBinary} = require('./elm-binary');
const ErrorMessage = require('./error-message');
const FS = require('./fs-wrapper');
const MinVersion = require('./min-version');
const OptimizeJs = require('./optimize-js');
const RemoteTemplate = require('./remote-template');
const Spinner = require('./spinner');
const TemplateDependencies = require('./template-dependencies');
const exit = require('../vendor/exit');

/**
* @import {AppHash, BuildResult} from "./types/build"
* @import {ApplicationElmJson} from "./types/content"
* @import {VersionString} from "./types/version"
* @import {Options, Template} from "./types/options"
* @import {Path} from "./types/path"
* @import {CompileOptions} from "../vendor/types/node-elm-compiler"
*/

const templateSrc = path.join(__dirname, '../template/src');
const parseElmFolder = path.join(__dirname, '../parseElm');
Expand Down
7 changes: 3 additions & 4 deletions lib/cache.js
Original file line number Diff line number Diff line change
@@ -1,11 +1,10 @@
/**
* @import {Path} from './types/path';
*/
const path = require('node:path');
const FS = require('./fs-wrapper');
const AppState = require('./state');

/**
* @import {Path} from "./types/path"
*/

/**
* @template {object} T
* @param {Path} folder
Expand Down
8 changes: 4 additions & 4 deletions lib/debug.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,6 @@ const AppState = require('./state');

const options = AppState.getOptions();

module.exports = {
log
};

/**
* @param {string} message
*/
Expand All @@ -14,3 +10,7 @@ function log(message) {
console.log(message);
}
}

module.exports = {
log
};
15 changes: 7 additions & 8 deletions lib/dependency-provider.js
Original file line number Diff line number Diff line change
@@ -1,15 +1,14 @@
const fs = require('graceful-fs');
/**
* @import {Options} from './types/options';
* @import {Path} from './types/path';
* @import {VersionString} from './types/version';
*/
const path = require('node:path');
const wasm = require('elm-solve-deps-wasm');
const fs = require('graceful-fs');
const FS = require('./fs-wrapper');
const SyncGet = require('./sync-get');
const ProjectJsonFiles = require('./project-json-files');

/**
* @import {Options} from "./types/options"
* @import {Path} from "./types/path"
* @import {VersionString} from "./types/version"
*/
const SyncGet = require('./sync-get');

/** @type {boolean} */
let wasmWasInitialized = false;
Expand Down
7 changes: 3 additions & 4 deletions lib/elm-app-worker.js
Original file line number Diff line number Diff line change
@@ -1,12 +1,11 @@
/**
* @import {MessagePort} from 'worker_threads';
*/
const {parentPort, workerData} = require('node:worker_threads');
const ElmCommunication = require('./elm-communication');
const loadCompiledElmApp = require('./load-compiled-app');
const ResultCache = require('./result-cache');

/**
* @import {MessagePort} from "worker_threads"
*/

const elmModule = loadCompiledElmApp(workerData.elmModulePath);

const app = elmModule.Elm.Elm.Review.Main.init({
Expand Down
13 changes: 6 additions & 7 deletions lib/elm-binary.js
Original file line number Diff line number Diff line change
@@ -1,16 +1,15 @@
/**
* @import {Options} from './types/options';
* @import {Path} from './types/path';
* @import {VersionString} from './types/version';
*/
const path = require('node:path');
const chalk = require('chalk');
const which = require('which');
const spawn = require('cross-spawn');
const which = require('which');
const ErrorMessage = require('./error-message');
const {backwardsCompatiblePath} = require('./npx');

/**
* @import {Options} from "./types/options"
* @import {Path} from "./types/path"
* @import {VersionString} from "./types/version"
*/

/**
* Get the path to the Elm binary
*
Expand Down
15 changes: 7 additions & 8 deletions lib/elm-communication.js
Original file line number Diff line number Diff line change
@@ -1,13 +1,8 @@
const Debug = require('./debug');
const Benchmark = require('./benchmark');

/**
* @import {Flags} from "./types/flags"
* @import {Flags} from './types/flags';
*/

module.exports = {
create
};
const Benchmark = require('./benchmark');
const Debug = require('./debug');

let hasWrittenThings = false;

Expand Down Expand Up @@ -77,3 +72,7 @@ function create(options) {
}
);
}

module.exports = {
create
};
25 changes: 12 additions & 13 deletions lib/elm-files.js
Original file line number Diff line number Diff line change
@@ -1,22 +1,21 @@
/**
* @import {ElmFile, Source, Readme, ElmJson, ElmJsonData, SourceDirectories} from './types/content';
* @import {ReviewOptions} from './types/options';
* @import {Path} from './types/path';
*/
const path = require('node:path');
const {glob} = require('glob');
const chalk = require('chalk');
const Hash = require('./hash');
const {glob} = require('glob');
const Anonymize = require('./anonymize');
const Benchmark = require('./benchmark');
const Cache = require('./cache');
const Debug = require('./debug');
const ErrorMessage = require('./error-message');
const FS = require('./fs-wrapper');
const Benchmark = require('./benchmark');
const Anonymize = require('./anonymize');
const Hash = require('./hash');
const OsHelpers = require('./os-helpers');
const elmParser = require('./parse-elm');
const AppState = require('./state');
const OsHelpers = require('./os-helpers');
const ErrorMessage = require('./error-message');
const Cache = require('./cache');

/**
* @import {ElmFile, Source, Readme, ElmJson, ElmJsonData, SourceDirectories} from "./types/content"
* @import {ReviewOptions} from "./types/options"
* @import {Path} from "./types/path"
*/

const defaultGlob = '**/*.elm$';

Expand Down
9 changes: 4 additions & 5 deletions lib/error-message.js
Original file line number Diff line number Diff line change
@@ -1,12 +1,11 @@
/**
* @import {Options} from './types/options';
* @import {Path} from './types/path';
*/
const chalk = require('chalk');
const stripAnsi = require('strip-ansi');
const Anonymize = require('./anonymize');

/**
* @import {Options} from "./types/options"
* @import {Path} from "./types/path"
*/

class CustomError extends Error {
/**
* @param {string} title
Expand Down
Loading
Loading