-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #14 from adamjosefus/development
Clean up and upgrade dependencies
- Loading branch information
Showing
26 changed files
with
76 additions
and
787 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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, | ||
... | ||
} | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,21 +1,25 @@ | ||
import { join } from "https://deno.land/[email protected]/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/[email protected]/path/mod.ts"; | ||
import { gray, bold } from "https://deno.land/[email protected]/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, | ||
|
@@ -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"); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,10 @@ | ||
import { join } from "https://deno.land/[email protected]/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/[email protected]/path/mod.ts"; | ||
import { gray, bold } from "https://deno.land/[email protected]/fmt/colors.ts"; | ||
|
||
|
||
const name = (os => { | ||
|
@@ -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, | ||
|
@@ -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"); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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/[email protected]/path/mod.ts"; | ||
import { green, red, gray, bold } from "https://deno.land/[email protected]/fmt/colors.ts"; | ||
import { Arguments, ValueException } from "https://deno.land/x/[email protected]/mod.ts"; | ||
import { existsSync } from "./exists.ts"; | ||
import { join, basename, dirname, isAbsolute } from "https://deno.land/[email protected]/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 = { | ||
|
@@ -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(); | ||
|
@@ -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, | ||
|
@@ -169,7 +173,7 @@ const installPackage = async (list: PackageListType, separateGitRoot: string) => | |
].join('')); | ||
|
||
if (message.trim() !== '') { | ||
console.log(Color.gray(`>> ${message}`)); | ||
console.log(gray(`>> ${message}`)); | ||
} | ||
} | ||
|
||
|
@@ -195,7 +199,7 @@ const deletePackage = (list: PackageListType) => { | |
].join('')); | ||
|
||
if (message.trim() !== '') { | ||
console.log(Color.gray(`>> ${message}`)); | ||
console.log(gray(`>> ${message}`)); | ||
} | ||
} | ||
|
||
|
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.