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

Unused dependency configuration #250

Closed
wants to merge 2 commits into from
Closed
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
362 changes: 241 additions & 121 deletions package-lock.json

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@
"@types/request": "^2.47.1",
"@types/ws": "^5.1.2",
"bootstrap": "^3.4.1",
"bufferutil": "3.0.3",
"bufferutil": "3.0.5",
"chokidar": "^2.1.2",
"chokidar-cli": "^1.2.2",
"elm": "0.19.0-bugfix2",
Expand All @@ -72,6 +72,6 @@
"run-sequence": "1.2.2",
"sb-admin-2": "^3.3.8",
"typescript": "^2.9.2",
"utf-8-validate": "3.0.4"
"utf-8-validate": "5.0.2"
}
}
9 changes: 6 additions & 3 deletions ts/bin/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,8 @@ var args = minimist(process.argv.slice(2), {
port: args.port || 3000,
elmFormatPath: elmFormatPath,
format: validFormats.indexOf(args.format) != -1 ? args.format : 'human',
open: args.open || false
open: args.open || false,
extraSourcePaths: args._
};
const info = {
version: elmAnalyseVersion,
Expand All @@ -39,9 +40,9 @@ var args = minimist(process.argv.slice(2), {

if (args.help) {
console.log('Usages:');
console.log(' $ elm-analyse');
console.log(' $ elm-analyse [PATHS ...]');
console.log(' # Analyse the project and log messages to the console\n');
console.log(' $ elm-analyse -s');
console.log(' $ elm-analyse -s [PATHS ...]');
console.log(
' # Analyse the project and start a server. Allows inspection of messages through a browser (Default: http://localhost:3000).\n'
);
Expand All @@ -52,6 +53,8 @@ var args = minimist(process.argv.slice(2), {
console.log(' --open, -o Open default browser when server goes live.');
console.log(' --elm-format-path Path to elm-format. Defaults to `elm-format`.');
console.log(' --format Output format for CLI. Defaults to "human". Options "human"|"json"');
console.log('Arguments: ');
console.log(' PATHS Optional extra source paths. Example: Main.elm');
process.exit(1);
}

Expand Down
1 change: 1 addition & 0 deletions ts/domain.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ interface Config {
open: boolean;
port: number;
elmFormatPath: string;
extraSourcePaths: string[];
}

export interface DependencyPointer {
Expand Down
2 changes: 1 addition & 1 deletion ts/file-loading-ports.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,5 +16,5 @@ export function setup(app: ElmApp, config: Config, directory: string): void {
RawDependencies.setup(app);
DependencyFiles.setup(app, directory, fileReader);
FileLoader.setup(app, config, directory, localCache, fileReader);
Context.setup(app, directory);
Context.setup(config, app, directory);
}
6 changes: 3 additions & 3 deletions ts/ports/context.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import * as fs from 'fs';
import * as fileGatherer from '../util/file-gatherer';
import { ElmApp, Context } from '../domain';
import { Config, ElmApp, Context } from '../domain';

function setup(app: ElmApp, directory: string) {
function setup(config: Config, app: ElmApp, directory: string) {
app.ports.loadContext.subscribe(() => {
const input = fileGatherer.gather(directory);
const input = fileGatherer.gather(config, directory);
var configuration;
try {
configuration = fs.readFileSync('./elm-analyse.json').toString();
Expand Down
2 changes: 1 addition & 1 deletion ts/server/app.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ function start(config: Config, info: Info, project: {}) {

app.get('/api/tree', function(_req, res) {
const directory = process.cwd();
const x = fileGatherer.gather(directory);
const x = fileGatherer.gather(config, directory);
res.send(x.sourceFiles);
});

Expand Down
5 changes: 3 additions & 2 deletions ts/util/file-gatherer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import * as fs from 'fs';
import _ from 'lodash';
import * as find from 'find';
import * as _path from 'path';
import { DependencyPointer } from '../domain';
import { Config, DependencyPointer } from '../domain';

function isRealElmPaths(sourceDir: string, filePath: String): boolean {
const modulePath = filePath.replace(_path.normalize(sourceDir + '/'), '');
Expand Down Expand Up @@ -76,12 +76,13 @@ function getDependencyFiles(directory: string, dep: DependencyPointer) {
});
}

function gather(directory: string): { interfaceFiles: Array<string[]>; sourceFiles: string[] } {
function gather(config: Config, directory: string): { interfaceFiles: Array<string[]>; sourceFiles: string[] } {
const packageFile = require(directory + '/elm.json');

const input = {
interfaceFiles: [],
sourceFiles: targetFilesForPathAndPackage(directory, directory, packageFile)
.concat(_.uniq(config.extraSourcePaths))
};
return input;
}
Expand Down