Skip to content

Commit

Permalink
Merge pull request #124 from nestdotland/dev
Browse files Browse the repository at this point in the history
  • Loading branch information
maximousblk authored May 24, 2021
2 parents b971caa + ccd0162 commit a4f07a5
Show file tree
Hide file tree
Showing 4 changed files with 71 additions and 66 deletions.
22 changes: 11 additions & 11 deletions deps.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,37 +9,37 @@ export {
join,
relative,
resolve,
} from "https://x.nest.land/std@0.93.0/path/mod.ts";
} from "https://x.nest.land/std@0.97.0/path/mod.ts";

export {
exists,
existsSync,
expandGlob,
expandGlobSync,
walkSync,
} from "https://x.nest.land/std@0.93.0/fs/mod.ts";
} from "https://x.nest.land/std@0.97.0/fs/mod.ts";

export * as log from "https://x.nest.land/std@0.93.0/log/mod.ts";
export * as log from "https://x.nest.land/std@0.97.0/log/mod.ts";

export { LogRecord } from "https://x.nest.land/std@0.93.0/log/logger.ts";
export { LogRecord } from "https://x.nest.land/std@0.97.0/log/logger.ts";

export type { LevelName } from "https://x.nest.land/std@0.93.0/log/levels.ts";
export { LogLevels } from "https://x.nest.land/std@0.93.0/log/levels.ts";
export type { LevelName } from "https://x.nest.land/std@0.97.0/log/levels.ts";
export { LogLevels } from "https://x.nest.land/std@0.97.0/log/levels.ts";

export { BaseHandler } from "https://x.nest.land/std@0.93.0/log/handlers.ts";
export { BaseHandler } from "https://x.nest.land/std@0.97.0/log/handlers.ts";

export * from "https://x.nest.land/std@0.93.0/fmt/colors.ts";
export * from "https://x.nest.land/std@0.97.0/fmt/colors.ts";

export {
assert,
assertEquals,
assertMatch,
} from "https://x.nest.land/std@0.93.0/testing/asserts.ts";
} from "https://x.nest.land/std@0.97.0/testing/asserts.ts";

export {
parse as parseYaml,
stringify as stringifyYaml,
} from "https://x.nest.land/std@0.93.0/encoding/yaml.ts";
} from "https://x.nest.land/std@0.97.0/encoding/yaml.ts";

/**************** cliffy ****************/
export {
Expand All @@ -61,7 +61,7 @@ export {
export type { ITypeInfo } from "https://x.nest.land/[email protected]/flags/types.ts";

/**************** semver ****************/
export * as semver from "https://deno.land/x/semver@v1.0.0/mod.ts";
export * as semver from "https://deno.land/x/semver@v1.3.0/mod.ts";

/**************** base64 ****************/
export * as base64 from "https://denopkg.com/chiefbiiko/[email protected]/mod.ts";
Expand Down
109 changes: 57 additions & 52 deletions src/commands/init.ts
Original file line number Diff line number Diff line change
Expand Up @@ -49,21 +49,24 @@ export async function init(options: Options) {

const entry: string | undefined = await Input.prompt({
message: "Entry file:",
default: currentConfig.entry,
}) || undefined;
default: currentConfig.entry ?? "./mod.ts",
});

const description: string | undefined = await Input.prompt({
message: "Description:",
default: currentConfig.description || existing?.description,
}) || undefined;
default: currentConfig.description ?? existing?.description ?? "",
});

const homepage: string | undefined = await Input.prompt({
message: "Module homepage:",
default: currentConfig.homepage || existing?.repository,
validate: (value) => value === "" || validateURL(value),
}) || undefined;
let releaseType: string | undefined = await Select.prompt({
message: "Semver increment:",
default: currentConfig.homepage ?? existing?.repository ?? "",
validate: (value: string) => value === "" || validateURL(value),
});

let releaseType: string | null | undefined = await Select.prompt({
message: "Automatic semver increment:",
options: [
{ name: "none", value: "none" },
{ name: "disabled", value: "none" },
Select.separator("--------"),
{ name: "patch", value: "patch" },
{ name: "minor", value: "minor" },
Expand All @@ -75,97 +78,99 @@ export async function init(options: Options) {
{ name: "premajor", value: "premajor" },
{ name: "prerelease", value: "prerelease" },
],
default: "none",
keys: {
previous: ["up", "8", "u"],
next: ["down", "2", "d"],
previous: ["up", "8", "u", "k"],
next: ["down", "2", "d", "j"],
},
});
if (releaseType === "none") releaseType = undefined;
if (releaseType === "none") releaseType = null;

const version: string | undefined = await Input.prompt({
message: "Version:",
default: existing?.getLatestVersion(),
validate: (value) => value === "" || validateVersion(value),
}) || undefined;
default: currentConfig.version ?? existing?.getLatestVersion() ?? "",
validate: (value: string) => value === "" || validateVersion(value),
});

const unstable: boolean | undefined = await Confirm.prompt({
message: "Is this an unstable version?",
default: currentConfig.unstable ?? false,
}) || undefined;
});

const unlisted: boolean | undefined = await Confirm.prompt({
message: "Should this module be hidden in the gallery?",
default: currentConfig.unlisted ?? false,
}) || undefined;
});

let files: string[] | undefined = await List.prompt({
message: "Files and relative directories to publish, separated by a comma:",
default: currentConfig.files,
default: currentConfig.files ?? [],
});
if (files.length === 1 && files[0] === "") files = undefined;
if (files?.length === 1 && files[0] === "") files = [];

let ignore: string[] | undefined = await List.prompt({
message: "Files and relative directories to ignore, separated by a comma:",
default: currentConfig.ignore,
default: currentConfig.ignore ?? [],
});
if (ignore.length === 1 && ignore[0] === "") ignore = undefined;
if (ignore?.length === 1 && ignore[0] === "") ignore = [];

const check: boolean | undefined = await Confirm.prompt({
message: "Perform all checks before publication?",
default: currentConfig.check ?? true,
default: currentConfig.check ?? false,
});
const noCheck = !check;

let checkFormat: boolean | string | undefined =
noCheck && await Confirm.prompt({
let checkFormat: boolean | string | undefined = noCheck &&
(await Confirm.prompt({
message: "Check source files formatting before publication?",
default: (!!currentConfig.checkFormat) ?? false,
})
? await Input.prompt({
message: "Formatting command (leave blank for default):",
default: typeof currentConfig.checkFormat === "string"
? currentConfig.checkFormat
: undefined,
})
: false;
default: !!currentConfig.checkFormat ?? false,
}))
? await Input.prompt({
message: "Formatting command (leave blank for default):",
default: typeof currentConfig.checkFormat === "string"
? currentConfig.checkFormat
: undefined,
})
: false;
if (checkFormat === "") checkFormat = true;

let checkTests: boolean | string | undefined =
noCheck && await Confirm.prompt({
let checkTests: boolean | string | undefined = noCheck &&
(await Confirm.prompt({
message: "Test your code before publication?",
default: (!!currentConfig.checkTests) ?? false,
})
? await Input.prompt({
message: "Testing command (leave blank for default):",
default: typeof currentConfig.checkTests === "string"
? currentConfig.checkTests
: undefined,
})
: false;
default: !!currentConfig.checkTests ?? false,
}))
? await Input.prompt({
message: "Testing command (leave blank for default):",
default: typeof currentConfig.checkTests === "string"
? currentConfig.checkTests
: undefined,
})
: false;
if (checkTests === "") checkTests = true;

const checkInstallation: boolean | undefined = noCheck &&
await Confirm.prompt({
(await Confirm.prompt({
message: "Install module and check for missing files before publication?",
default: currentConfig.checkInstallation ?? false,
});
}));

const format = await Select.prompt({
message: "Config format: ",
default: (configPath ? configFormat(configPath) : ConfigFormat.JSON)
.toUpperCase(),
default: configPath
? configFormat(configPath).toUpperCase()
: ConfigFormat.JSON,
options: [
{ name: "YAML", value: ConfigFormat.YAML },
{ name: "JSON", value: ConfigFormat.JSON },
],
keys: {
previous: ["up", "8", "u"],
next: ["down", "2", "d"],
previous: ["up", "8", "u", "k"],
next: ["down", "2", "d", "j"],
},
});

const config: Partial<Config> = {
"$schema": `https://x.nest.land/eggs@${eggsVersion}/src/schema.json`,
$schema: `https://x.nest.land/eggs@${eggsVersion}/src/schema.json`,
name,
entry,
description,
Expand Down
2 changes: 1 addition & 1 deletion src/version.ts
Original file line number Diff line number Diff line change
@@ -1 +1 @@
export const version = "0.3.6";
export const version = "0.3.7";
4 changes: 2 additions & 2 deletions test/deps.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,6 @@
export {
assert,
assertEquals,
} from "https://x.nest.land/std@0.69.0/testing/asserts.ts";
} from "https://x.nest.land/std@0.97.0/testing/asserts.ts";

export { expandGlob } from "https://x.nest.land/std@0.69.0/fs/mod.ts";
export { expandGlob } from "https://x.nest.land/std@0.97.0/fs/mod.ts";

0 comments on commit a4f07a5

Please sign in to comment.