Skip to content

Commit

Permalink
Merge pull request #14 from adamjosefus/development
Browse files Browse the repository at this point in the history
Clean up and upgrade dependencies
  • Loading branch information
adamjosefus committed Feb 16, 2022
2 parents 5d1f616 + b757ecf commit 69ede9b
Show file tree
Hide file tree
Showing 26 changed files with 76 additions and 787 deletions.
14 changes: 0 additions & 14 deletions .vscode/tasks.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,19 +13,5 @@
"command": "deno run -A ./bin/compile.ts",
"group": "build",
},
{
"label": "📦 PKG: Install",
"group": "build",
"options": { "cwd": "${cwd}", },
"command": "deno",
"args": ["run", "-A", "./main.ts", "--c=./lib/pkg.json", "--install"]
},
{
"label": "📦 PKG: Delete Current",
"group": "build",
"options": { "cwd": "${cwd}", },
"command": "deno",
"args": ["run", "-A", "./main.ts", "--c=./lib/pkg.json", "--delete"]
},
]
}
45 changes: 19 additions & 26 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,68 +1,61 @@
# PKG 📦

Nástroj na správu balíčků (repozitářů), na kterých je závislá vaše aplikace.
> You need have [installed Deno](https://deno.land/#installation).
A tool for managing the packages (repositories) on which your application depends. Easily and locally.

```bash
# Raw Deno
deno run -A main.ts --config=pkg.json --help
deno run -A pkg.ts --config=pkg.json --help


# Compiled Deno
./pkg --help
```

```bash
Verze: 1.1.3

--config, --c
Cesta na konfugurační soubor s balíčky. Výchozí hodnota je "./pkg.json"
Path to the package configuration file.
Default value: "pkg.json"


--install, --i
Naistaluje balíčky z konfiguračního souboru.
Installs packages from the configuration file.
Default value: false


--delete, --uninstall
Deletes packages according to the configuration file.
Default value: false

--delete, --uninstall, --clear, --remove
Smaže balíčky podle konfiguračního souboru.
```


---


## Kompilace spustitelného souboru
Při kompilaci se soubor sám pojmenuje podle operačního systému.
## Compilation to an executable file
During compilation, the file names itself according to the operating system.

```bash
deno run -A ./bin/compile.ts
```
```bash
Compile to /some/path/pkg/pkg.macos
> deno --unstable compile --output=pkg.macos --allow-all ./main.ts
Compile to /your-path/pkg.macos
> deno compile --output=pkg.macos --allow-all ./pkg.ts
> Succeed
```



## Bundle to jednoho javavascript souboru
## Bundle to a single executable js file

```bash
deno run -A ./bin/bundle.ts
```
```bash
Bundle to /some/path/pkg/pkg.bundled.js
> deno bundle ./main.ts ./pkg.bundled.js
Bundle to /your-path/pkg.bundled.js
> deno bundle ./pkg.ts ./pkg.bundled.js
> Succeed
```



# VS Code Settings
Aby výstupný vhled byl nejkrásnější, nastavte ve **VS Code**:
```json
{
...
"terminal.integrated.drawBoldTextInBrightColors": false,
...
}
```
22 changes: 13 additions & 9 deletions bin/bundle.ts
Original file line number Diff line number Diff line change
@@ -1,21 +1,25 @@
import { join } from "https://deno.land/std@0.120.0/path/mod.ts";
import { Color, Style } from "../lib/packages/deno-ascii-office/mod.ts";
/**
* @copyright Copyright (c) 2022 Adam Josefus
*/


import { join } from "https://deno.land/std@0.125.0/path/mod.ts";
import { gray, bold } from "https://deno.land/std@0.125.0/fmt/colors.ts";


const name = 'pkg.bundled.js';
const path = join(Deno.cwd(), name);

const cmd = [
`deno`,
`--unstable`,
`bundle`,
`./main.ts`,
`./pkg.ts`,
`./${name}`
];

console.log("\n");
console.log(Style.bold(`Bundle to %c${path}`));
console.log(Color.gray(`> ${cmd.join(' ')}`));
console.log(bold(`Bundle to ${path}`));
console.log(gray(`> ${cmd.join(' ')}`));

const process = await Deno.run({
cmd: cmd,
Expand All @@ -26,12 +30,12 @@ const process = await Deno.run({
const { success } = await process.status();

if (success) {
console.log(Color.gray(`> Succeed`));
console.log(gray(`> Succeed`));
} else {
const outputBytes = await process.stderrOutput()
const output = (new TextDecoder()).decode(outputBytes);
console.log(Color.gray(`> Failed`));
console.log(Color.gray(`>> ${output}`));
console.log(gray(`> Failed`));
console.log(gray(`>> ${output}`));
}

console.log("\n");
18 changes: 11 additions & 7 deletions bin/compile.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
import { join } from "https://deno.land/std@0.120.0/path/mod.ts";
import { Color, Style } from "../lib/packages/deno-ascii-office/mod.ts";
/**
* @copyright Copyright (c) 2022 Adam Josefus
*/


import { join } from "https://deno.land/std@0.125.0/path/mod.ts";
import { gray, bold } from "https://deno.land/std@0.125.0/fmt/colors.ts";


const name = (os => {
Expand All @@ -18,16 +23,15 @@ const path = join(Deno.cwd(), name);

const cmd = [
`deno`,
`--unstable`,
`compile`,
`--output=${name}`,
`--allow-all`,
`./main.ts`
];

console.log("\n");
console.log(Style.bold(`Compile to %c${path}`));
console.log(Color.gray(`> ${cmd.join(' ')}`));
console.log(bold(`Compile to ${path}`));
console.log(gray(`> ${cmd.join(' ')}`));

const process = await Deno.run({
cmd: cmd,
Expand All @@ -39,9 +43,9 @@ const process = await Deno.run({
const { success } = await process.status();

if (success) {
console.log(Color.gray(`> Succeed`));
console.log(gray(`> Succeed`));
} else {
console.log(Color.gray(`> Failed`));
console.log(gray(`> Failed`));
}

console.log("\n");
5 changes: 5 additions & 0 deletions lib/exists.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
/**
* @copyright Copyright (c) 2022 Adam Josefus
*/


export const exists = async (path: string): Promise<boolean> => {
try {
await Deno.stat(path);
Expand Down
46 changes: 25 additions & 21 deletions lib/pkg.ts → lib/main.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,16 @@
import { Arguments, ValueException } from "./packages/deno-arguments/mod.ts";
import { Color, Style } from "./packages/deno-ascii-office/mod.ts";
/**
* @copyright Copyright (c) 2022 Adam Josefus
*/


import { join, basename, dirname, isAbsolute } from "https://deno.land/std@0.125.0/path/mod.ts";
import { green, red, gray, bold } from "https://deno.land/std@0.125.0/fmt/colors.ts";
import { Arguments, ValueException } from "https://deno.land/x/allo_arguments@v4.0.1/mod.ts";
import { existsSync } from "./exists.ts";
import { join, basename, dirname, isAbsolute } from "https://deno.land/std@0.120.0/path/mod.ts";


const successStyle = (s: string) => Color.green(Style.bold(s));
const errorStyle = (s: string) => Color.red(Style.bold(s));
const successStyle = (s: string) => green(bold(s));
const errorStyle = (s: string) => red(bold(s));


type ConfigFileType = {
Expand All @@ -30,41 +35,39 @@ const getArguments = () => {
const args = new Arguments(
{
name: 'config, c',
description: `Cesta na konfugurační soubor s balíčky. Výchozí hodnota je "./pkg.json"`,
processor: (path: string | null | false): string => {
description: `Path to the package configuration file.`,
convertor: (path: string | null | false): string => {
if (path === null || path === false) throw new ValueException(`Cesta na konfigurační soubor není platná.`);
path = join(Deno.cwd(), path) as string;

if (existsSync(path) === false) {
throw new ValueException(`--config=${path}\nSoubor neexistuje.`);
throw new ValueException(`--config=${path}\nThe file does not exist.`);
}

try {
JSON.parse(Deno.readTextFileSync(path));
} catch (_err) {
throw new ValueException(`JSON konfiguračního souboru je požkozený.`);
throw new ValueException(`The JSON of the configuration file is corrupted.`);
}

return path;
},
fallback: "pkg.json"
default: "pkg.json"
},
{
name: 'install, i',
description: `Naistaluje balíčky z konfiguračního souboru.`,
processor: (v: string | boolean) => v === true || v === 'true',
fallback: false
description: `Installs packages from the configuration file.`,
convertor: (v: string | boolean) => v === true || v === 'true',
default: false
},
{
name: 'delete, uninstall, clear, remove',
description: `Smaže balíčky podle konfiguračního souboru.`,
processor: (v: string | boolean) => v === true || v === 'true',
fallback: false
name: 'delete, uninstall',
description: `Deletes packages according to the configuration file.`,
convertor: (v: string | boolean) => v === true || v === 'true',
default: false
}
);

args.setDescription('Verze: 1.1.3');


if (args.shouldHelp()) {
args.triggerHelpException();
Expand Down Expand Up @@ -111,6 +114,7 @@ const parseConfig = (json: string, root: string, separateGitRoot: string): Packa
}


// deno-lint-ignore no-explicit-any
const runCommand = async (...cmd: any[]) => {
const process = Deno.run({
cmd,
Expand Down Expand Up @@ -169,7 +173,7 @@ const installPackage = async (list: PackageListType, separateGitRoot: string) =>
].join(''));

if (message.trim() !== '') {
console.log(Color.gray(`>> ${message}`));
console.log(gray(`>> ${message}`));
}
}

Expand All @@ -195,7 +199,7 @@ const deletePackage = (list: PackageListType) => {
].join(''));

if (message.trim() !== '') {
console.log(Color.gray(`>> ${message}`));
console.log(gray(`>> ${message}`));
}
}

Expand Down
5 changes: 0 additions & 5 deletions lib/packages/deno-arguments/.vscode/settings.json

This file was deleted.

43 changes: 0 additions & 43 deletions lib/packages/deno-arguments/README.md

This file was deleted.

2 changes: 0 additions & 2 deletions lib/packages/deno-arguments/lib/ArgumentException.ts

This file was deleted.

Loading

0 comments on commit 69ede9b

Please sign in to comment.