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

chore: Doc, output and code improvements #74

Merged
merged 46 commits into from
Nov 1, 2020
Merged
Show file tree
Hide file tree
Changes from 7 commits
Commits
Show all changes
46 commits
Select commit Hold shift + click to select a range
19f20d1
Re-use logic from services
Oct 20, 2020
5512a81
Move options to commands directory
Oct 20, 2020
b51dc9b
Improve mod.ts logic using services
Oct 20, 2020
d05ea2a
Add pre release workflow to bump versions
Oct 20, 2020
e68d4bf
Update readme for new help message
Oct 20, 2020
bfa68e4
deno fmt
Oct 20, 2020
c0f29c5
Fix tests
Oct 20, 2020
62852a4
deno fmt
crookse Oct 21, 2020
d0d2145
use CommandService
crookse Oct 21, 2020
07b7adc
fix import
crookse Oct 21, 2020
adffbec
Use logging service for improved output
Oct 21, 2020
7b5c61c
Merge branch 'improvements' of https://github.com/drashland/dmm into …
Oct 21, 2020
98e3c37
Improve bump versions script
Oct 21, 2020
0c10ea3
fix tests
Oct 21, 2020
613dd21
deno fmt
Oct 21, 2020
ad39adc
deno lint
Oct 21, 2020
098bb27
Tidied up README
Oct 21, 2020
9352591
Re-use logic from services to update version strings following bumper
Oct 21, 2020
a7dcc8f
deno fmt
Oct 21, 2020
2de6614
Correct updating test deps
Oct 21, 2020
9d382e9
deno fmt
Oct 21, 2020
dd3925d
refactor based on services
crookse Oct 21, 2020
8b8d84f
put pre-release stuff in
crookse Oct 21, 2020
874f6b2
fix method call
crookse Oct 21, 2020
2efef4f
add yml files
crookse Oct 21, 2020
a096569
use thisModulesLatestVersion
crookse Oct 21, 2020
4d59609
test bumper script process
crookse Oct 22, 2020
e5fc526
Merge pull request #75 from drashland/refactor-based-on-services
crookse Oct 22, 2020
5c210bb
Merge branch 'master' into improvements
crookse Oct 22, 2020
fa794d4
make changes based on cli service changes
crookse Oct 22, 2020
59f3fef
use display instead of show
crookse Oct 22, 2020
48d9573
state Bump Versions in CI
crookse Oct 23, 2020
80f6373
Update dependencies
github-actions[bot] Oct 28, 2020
dc9679f
Merge branch 'master' into improvements
crookse Oct 30, 2020
12e0750
use Deno.test() instead of Rhum v2
crookse Oct 30, 2020
c5f4219
deno fmt
crookse Oct 30, 2020
5a1c027
fix error test
crookse Oct 30, 2020
0836d4a
fixing tests; fixing commands based on tests
crookse Oct 30, 2020
2022fab
fixing tests
crookse Oct 30, 2020
8b8fbef
improve README; make it more digestible
crookse Oct 30, 2020
d1a005b
shorten terminal commands; add raw github url to --allow-net flag
crookse Oct 30, 2020
46b6a88
deno fmt
crookse Oct 30, 2020
180ce48
Merge branch 'improvements' of github.com:drashland/dmm into improvem…
crookse Oct 30, 2020
812ec60
no message
crookse Oct 31, 2020
b7c42a2
fix readme
crookse Oct 31, 2020
c545f09
Merge pull request #76 from drashland/update-dependencies
crookse Oct 31, 2020
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
45 changes: 45 additions & 0 deletions .github/workflows/pre_release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
name: pre-release

on:
create

jobs:

# Make a PR to master from a new branch with changes, and delete the created one
update-versions:

# Only run when a release-v* branch is created, and not by drashbot
if: contains(github.ref, 'release-v') && !contains(github.event.sender.login, 'drashbot')

strategy:
matrix:
deno: ["1.4.2"]

runs-on: ubuntu-latest

steps:

- name: Checkout master
uses: actions/checkout@v2
with:
ref: master

- name: Delete Remote Release Branch
run: git push --delete origin ${{ github.ref }}

- name: Install Deno
uses: denolib/setup-deno@v2
with:
deno-version: ${{ matrix.deno }}

- name: Bump Versions
run: deno run -A ./console/bump_versions.ts --version=${{ github.ref }} # version passed so we know what the new release version will be

- name: Create Pull Request
uses: peter-evans/create-pull-request@v2
with:
token: ${{ secrets.CI_USER_PAT }}
commit-message: bump versions
title: bump versions
body: This was auto-generated by GitHub Actions.
branch: release # Can change it to ${{ github.ref }} to be the branch name, but then we need to figure out how to stop this worjflow running when it creates another "release-vx.x.x" branch
59 changes: 36 additions & 23 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,6 @@ $ dmm ...

*Through the URL*

If you are using this method, be sure to use the latest version of dmm in the command below
```
$ deno run --allow-net='cdn.deno.land,api.deno.land' --allow-read='.' --allow-write='deps.ts' https://deno.land/x/dmm@v1.1.5/mod.ts ...
```
Expand Down Expand Up @@ -151,40 +150,54 @@ export { fs, colors }
Should you need any more information, use the `--help` option:

```
$ dmm --help
A module manager for Deno.

A module manager for Deno.
USAGE

USAGE:
deno run --allow-read --allow-net [--allow-write] https://deno.land/x/dmm@v1.1.5/mod.ts [ARGS] [MODULES]
deno install --allow-net='cdn.deno.land,api.deno.land' --allow-read='.' --allow-write='deps.ts' https://deno.land/x/dmm@v1.1.5/mod.ts
dmm [command]

dmm [ARGS] [MODULES]

ARGUMENTS:
The check and update arguments cannot be used together.
COMMANDS

check
Checks the specified modules for newer version. Will check all if modules are omitted.
check [modules]
Checks the specified modules for newer version. Will check all if modules are
omitted.

update
Updates the specified modules to the newest version. Will update all if modules are omitted.
update [modules]
Updates the specified modules to the newest version. Will update all if modules
are omitted.

info
Shows information about the given module, be it std or 3rd party. The 3rd party module must be referenced at https://deno.land/x/
info
Shows information about the given module, be it std or 3rd party. The 3rd party
module must be referenced at https://deno.land/x/

OPTIONS:
--help
Prints help message
Prints the help message

--version
Prints dmm version
Prints the current dmm version

help
Prints the help message

version
Prints the current dmm version


EXAMPLE USAGE

Install dmm
deno install --allow-net='cdn.deno.land,api.deno.land' --allow-read='.' --allow-write='deps.ts' https://deno.land/x/dmm@v1.1.5/mod.ts

Check a single module
dmm check fs

EXAMPLE USAGE:
Assume you are importing an out of date version of `fs` from `std`. See [here](#quick-start) for adding further restrictions.
deno run --allow-net --allow-read https://deno.land/x/dmm@v1.1.5/mod.ts check fs
deno run --allow-net --allow-read --allow-write https://deno.land/x/dmm@v1.1.5/mod.ts update fs
deno run --allow-net https://deno.land/x/dmm@v1.1.5/mod.ts info http
dmm info http
Update a single module
dmm update fs

Get information about a module
dmm info http
```

# How it Works
Expand Down
22 changes: 22 additions & 0 deletions console/bump_versions.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
import { bumpVersions } from "https://raw.githubusercontent.com/drashland/services/master/console/bump_versions.ts";

const branch: string = Deno.args[0].split("=")[1]; // ["--version", "release-vX.X.X"]
const version = branch.substring(branch.indexOf("v") + 1); // 1.0.5

bumpVersions([
{
filename: "./egg.json",
replaceTheRegex: /"version": "[0-9\.]+[0-9\.]+[0-9\.]"/,
replaceWith: `"version": "${version}"`,
},
{
filename: "./README.md",
replaceTheRegex: /dmm@v[0-9\.]+[0-9\.]+[0-9\.]/g,
replaceWith: `dmm@v${version}`,
},
{
filename: "./src/commands/version.ts",
replaceTheRegex: /version = "[0-9\.]+[0-9\.]+[0-9\.]"/,
replaceWith: `version = "${version}"`,
},
]);
8 changes: 7 additions & 1 deletion deps.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,10 @@
import * as colours from "https://deno.land/std@0.74.0/fmt/colors.ts";
export { colours };

export { createHelpMenu } from "https://raw.githubusercontent.com/drashland/services/master/cli/help_menu_service.ts";
export { CommandService } from "https://raw.githubusercontent.com/drashland/services/master/cli/command_service.ts";
export {
logDebug,
logError,
logInfo,
} from "https://raw.githubusercontent.com/drashland/services/master/cli/logger_service.ts";
export { assertEquals } from "https://deno.land/std@0.74.0/testing/asserts.ts";
90 changes: 38 additions & 52 deletions mod.ts
Original file line number Diff line number Diff line change
@@ -1,56 +1,42 @@
import { colours } from "./deps.ts";
import { helpMessage } from "./src/options/help.ts";
import { versionMessage } from "./src/options/version.ts";
import { colours, CommandService, logError } from "./deps.ts";
import { helpMessage } from "./src/commands/help.ts";
import { versionMessage } from "./src/commands/version.ts";
import { info } from "./src/commands/info.ts";
import { check } from "./src/commands/check.ts";
import { update } from "./src/commands/update.ts";

async function run(
purpose: string,
modulesForPurpose: string[],
): Promise<void> {
if (purpose === "check") {
await check(modulesForPurpose);
} else if (purpose === "info") {
await info(modulesForPurpose);
} else if (purpose === "update") {
await update(modulesForPurpose);
} else {
console.error(
colours.red("Specify either `check`, `info` or `update`. See --help"),
);
Deno.exit(1);
}
}

// Gather args
const args: string[] = Deno.args;
if (!args.length) {
console.error(colours.red("Invalid arguments. See --help"));
Deno.exit(1);
}

// Support --help usage
const wantsHelp: boolean = args.filter((arg) => arg === "--help").length === 1;
if (wantsHelp) {
console.info(helpMessage);
Deno.exit();
}

// Support --version usage
const wantsVersion: boolean =
args.filter((arg) => arg === "--version").length === 1;
if (wantsVersion) {
console.info(versionMessage);
Deno.exit();
}

// Gather facts
console.info("Gathering facts...");
const purposeAndModules: string[] = args.filter((arg) =>
arg.indexOf("--") === -1
);
const purpose: string = purposeAndModules[0];
const modulesForPurpose: string[] = purposeAndModules.slice(1);

await run(purpose, modulesForPurpose);
const args = Deno.args.slice().filter((arg: string, i: number) => {
return i !== 0;
});

const c = new CommandService(Deno.args);

c.addCommand("--help", async () => {
console.log(helpMessage);
});

c.addCommand("--version", () => {
console.log(versionMessage);
});

c.addCommand("info", async () => {
await info(args);
});

c.addCommand("help", () => {
console.log(helpMessage);
});

c.addCommand("update", async () => {
await update(args);
});

c.addCommand("version", () => {
console.log(versionMessage);
});

c.addCommand("check", async () => {
await check(args);
});

c.executeCommand();
46 changes: 46 additions & 0 deletions src/commands/help.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
import { createHelpMenu } from "../../deps.ts";
import { version } from "./version.ts";

export const helpMessage = createHelpMenu({
description: `A module manager for Deno.`,
usage: [
`deno install --allow-net='cdn.deno.land,api.deno.land' --allow-read='.' --allow-write='deps.ts' https://deno.land/x/dmm@v${version}/mod.ts`,
`dmm [command]`,
],
commands: {
"check [modules]":
"Checks the specified modules for newer version. Will check all if modules are omitted.",
"update [modules]":
"Updates the specified modules to the newest version. Will update all if modules are omitted.",
"info":
"Shows information about the given module, be it std or 3rd party. The 3rd party module must be referenced at https://deno.land/x/",
"help, --help": "Prints the help message",
"version, --version": "Prints the current dmm version",
},
example_usage: [
{
description: "Install dmm",
examples: [
`deno install --allow-net='cdn.deno.land,api.deno.land' --allow-read='.' --allow-write='deps.ts' https://deno.land/x/dmm@v${version}/mod.ts`,
],
},
{
description: "Check a single module",
examples: [
`dmm check fs`,
],
},
{
description: "Update a single module",
examples: [
`dmm update fs`,
],
},
{
description: "Get information about a module",
examples: [
"dmm info http",
],
},
],
});
File renamed without changes.
55 changes: 0 additions & 55 deletions src/options/help.ts

This file was deleted.