vcpm 0.2.2 → 0.3.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -1,25 +1,106 @@
1
+ ![logo.png](logo.png)
2
+
1
3
  # VCPM - Voxel Core Project Manager
2
4
 
3
- CLI util for managing voxel core content packs, with vcpm we can start new project and build it for release
5
+ CLI util for managing voxel core content packs, with vcpm we can start
6
+ new project and build it for release
4
7
 
5
- ## Instalation
8
+ [![oclif](https://img.shields.io/badge/cli-oclif-brightgreen.svg)](https://oclif.io)
9
+ [![Version](https://img.shields.io/npm/v/vcpm.svg)](https://npmjs.org/package/vcpm)
10
+ [![Downloads/week](https://img.shields.io/npm/dw/vcpm.svg)](https://npmjs.org/package/vcpm)
6
11
 
7
- ```
12
+ - [Installation](#installation)
13
+ - [Usage](#usage)
14
+ - [Commands](#commands)
15
+ - [Support OS](#support-os)
16
+
17
+ ## Installation
18
+
19
+ ```bash
8
20
  npm i -g vcpm
9
21
  ```
10
22
 
11
23
  ## Usage
12
24
 
13
- ### Build
25
+ ### Run command
26
+
27
+ ```Bash
28
+ vcpm COMMAND
14
29
  ```
15
- vcpm build
30
+
31
+ ### Check version
32
+
33
+ ```Bash
34
+ vcpm --version | -v
16
35
  ```
17
- Creates a zip archive for production use, removing in production build all files and folders which starts on dot, and remove type declarations folder.
18
36
 
19
- ### Development Build
37
+ ### Help with command
38
+
39
+ ```Bash
40
+ vcpm COMMAND --help
20
41
  ```
21
- vcpm build -d | -dev
42
+
43
+ ## Commands
44
+
45
+ - [`vcpm build`](#vcpm-build)
46
+ - [`vcpm autocomplete`](#vcpm-autocomplete)
47
+
48
+ ### `vcpm build`
49
+
50
+ Build project
51
+
52
+ ```Bash
53
+ USAGE
54
+ $ vcpm build [-d]
55
+
56
+ FLAGS
57
+ -d, --dev build in development mode
58
+
59
+ DESCRIPTION
60
+ build project
61
+ ```
62
+
63
+ _See code: [src/commands/build/index.ts](https://github.com/TraumDE/vcpm/blob/main/src/commands/build/index.ts)_
64
+
65
+ ### `vcpm autocomplete`
66
+
67
+ Display autocomplete installation instructions.
68
+
69
+ ```Bash
70
+ USAGE
71
+ $ vcpm autocomplete [SHELL] [-r]
72
+
73
+ ARGUMENTS
74
+ [SHELL] (zsh|bash|powershell) Shell type
75
+
76
+ FLAGS
77
+ -r, --refresh-cache Refresh cache (ignores displaying instructions)
78
+
79
+ DESCRIPTION
80
+ Display autocomplete installation instructions.
81
+
82
+ EXAMPLES
83
+ $ vcpm autocomplete
84
+
85
+ $ vcpm autocomplete bash
86
+
87
+ $ vcpm autocomplete zsh
88
+
89
+ $ vcpm autocomplete powershell
90
+
91
+ $ vcpm autocomplete --refresh-cache
22
92
  ```
23
- Creates a zip archive for development use, without removing any files or folders.
24
93
 
25
- Archive format [pack_id]\_[version].zip
94
+ ## Support OS
95
+
96
+ ### Windows
97
+
98
+ - Windows 11 ❓ - 0.2.2 (need update)
99
+
100
+ ### Linux
101
+
102
+ - Arch Linux ✅ - 0.3.0
103
+
104
+ ### MacOS
105
+
106
+ No tests on MacOS
package/bin/dev.cmd ADDED
@@ -0,0 +1,3 @@
1
+ @echo off
2
+
3
+ node --loader ts-node/esm --no-warnings=ExperimentalWarning "%~dp0\dev" %*
package/bin/dev.js ADDED
@@ -0,0 +1,5 @@
1
+ #!/usr/bin/env -S node --loader ts-node/esm --disable-warning=ExperimentalWarning
2
+
3
+ import {execute} from '@oclif/core'
4
+
5
+ await execute({development: true, dir: import.meta.url})
package/bin/run.cmd ADDED
@@ -0,0 +1,3 @@
1
+ @echo off
2
+
3
+ node "%~dp0\run" %*
package/bin/run.js ADDED
@@ -0,0 +1,5 @@
1
+ #!/usr/bin/env node
2
+
3
+ import {execute} from '@oclif/core'
4
+
5
+ await execute({dir: import.meta.url})
@@ -0,0 +1,11 @@
1
+ import { Command } from '@oclif/core';
2
+ export declare class Build extends Command {
3
+ static description: string;
4
+ static flags: {
5
+ dev: import("@oclif/core/interfaces").BooleanFlag<boolean>;
6
+ };
7
+ run(): Promise<void>;
8
+ private addFile;
9
+ private build;
10
+ private readPackage;
11
+ }
@@ -0,0 +1,56 @@
1
+ import { Command, Flags } from '@oclif/core';
2
+ import { BlobReader, BlobWriter, ZipWriter } from '@zip.js/zip.js';
3
+ import { glob } from 'glob';
4
+ import { Buffer } from 'node:buffer';
5
+ import { promises as fs } from 'node:fs';
6
+ export class Build extends Command {
7
+ static description = 'Build project';
8
+ static flags = {
9
+ dev: Flags.boolean({ char: 'd', description: 'Build in development mode' }),
10
+ };
11
+ async run() {
12
+ this.log('Start building...');
13
+ await this.build();
14
+ }
15
+ async addFile(file, zipWriter) {
16
+ const relativePath = file.relative();
17
+ await zipWriter.add(relativePath, new BlobReader(new Blob([new Uint8Array(await fs.readFile(relativePath))])));
18
+ }
19
+ async build() {
20
+ try {
21
+ await fs.access('dist');
22
+ }
23
+ catch {
24
+ await fs.mkdir('dist');
25
+ }
26
+ const zipFileWriter = new BlobWriter('application/zip');
27
+ const zipWriter = new ZipWriter(zipFileWriter);
28
+ const { flags } = await this.parse(Build);
29
+ const files = await glob('**/*', {
30
+ cwd: process.cwd(),
31
+ dot: true,
32
+ ignore: flags.dev ? [] : ['**/.*', '**/.*/**', 'dist/**/*', 'modules/types/**/*'],
33
+ nodir: true,
34
+ withFileTypes: true,
35
+ });
36
+ const filePromises = files.map((file) => this.addFile(file, zipWriter));
37
+ await Promise.all(filePromises);
38
+ const zipBlob = await zipWriter.close();
39
+ const buffer = Buffer.from(await zipBlob.arrayBuffer());
40
+ const packageInfo = await this.readPackage();
41
+ await fs.writeFile(`dist/${packageInfo.id}_${packageInfo.version}.zip`, buffer);
42
+ if (flags.dev) {
43
+ this.log('Development build completed!');
44
+ }
45
+ else {
46
+ this.log('Production build completed!');
47
+ }
48
+ }
49
+ async readPackage() {
50
+ const packageJsonParsed = JSON.parse(await fs.readFile('package.json', 'utf8'));
51
+ return {
52
+ id: packageJsonParsed.id,
53
+ version: packageJsonParsed.version,
54
+ };
55
+ }
56
+ }
@@ -0,0 +1 @@
1
+ export { run } from '@oclif/core';
package/dist/index.js CHANGED
@@ -1,19 +1 @@
1
- #!/usr/bin/env node
2
- "use strict";
3
- var __importDefault = (this && this.__importDefault) || function (mod) {
4
- return (mod && mod.__esModule) ? mod : { "default": mod };
5
- };
6
- Object.defineProperty(exports, "__esModule", { value: true });
7
- const commander_1 = require("commander");
8
- const build_1 = __importDefault(require("./commands/build"));
9
- const program = new commander_1.Command();
10
- program
11
- .name("vcpm")
12
- .description("VCPM - Voxel Core Project Manager. Is unoficall CLI util for managing content packs")
13
- .version("0.1.0");
14
- program
15
- .command("build")
16
- .description("Build project for production")
17
- .option("-d, --dev", "Build project for development", false)
18
- .action(build_1.default);
19
- program.parse();
1
+ export { run } from '@oclif/core';
@@ -0,0 +1 @@
1
+ export * from './package-info.js';
@@ -1,18 +1 @@
1
- "use strict";
2
- var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
- if (k2 === undefined) k2 = k;
4
- var desc = Object.getOwnPropertyDescriptor(m, k);
5
- if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
- desc = { enumerable: true, get: function() { return m[k]; } };
7
- }
8
- Object.defineProperty(o, k2, desc);
9
- }) : (function(o, m, k, k2) {
10
- if (k2 === undefined) k2 = k;
11
- o[k2] = m[k];
12
- }));
13
- var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
- for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
- };
16
- Object.defineProperty(exports, "__esModule", { value: true });
17
- __exportStar(require("./packInfo"), exports);
18
- __exportStar(require("./buildOptions"), exports);
1
+ export * from './package-info.js';
@@ -0,0 +1,4 @@
1
+ export interface PackageInfo {
2
+ id: string;
3
+ version: string;
4
+ }
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,34 @@
1
+ {
2
+ "commands": {
3
+ "build": {
4
+ "aliases": [],
5
+ "args": {},
6
+ "description": "Build project",
7
+ "flags": {
8
+ "dev": {
9
+ "char": "d",
10
+ "description": "Build in development mode",
11
+ "name": "dev",
12
+ "allowNo": false,
13
+ "type": "boolean"
14
+ }
15
+ },
16
+ "hasDynamicHelp": false,
17
+ "hiddenAliases": [],
18
+ "id": "build",
19
+ "pluginAlias": "vcpm",
20
+ "pluginName": "vcpm",
21
+ "pluginType": "core",
22
+ "strict": true,
23
+ "enableJsonFlag": false,
24
+ "isESM": true,
25
+ "relativePath": [
26
+ "dist",
27
+ "commands",
28
+ "build",
29
+ "index.js"
30
+ ]
31
+ }
32
+ },
33
+ "version": "0.3.0"
34
+ }
package/package.json CHANGED
@@ -1,39 +1,78 @@
1
1
  {
2
2
  "name": "vcpm",
3
- "version": "0.2.2",
4
- "description": "VCPM - Voxel Core Project Manager. Is unoficall CLI util for managing content packs",
5
- "main": "dist/index.js",
6
- "preferGlobal": "true",
7
- "bin": "./dist/index.js",
3
+ "description": "VCPM - Voxel Core Project Manager",
4
+ "version": "0.3.0",
5
+ "author": "Eugene301|TraumDE",
6
+ "bin": "./bin/run.js",
7
+ "bugs": "https://github.com/TraumDE/vcpm/issues",
8
+ "dependencies": {
9
+ "@oclif/core": "^4",
10
+ "@oclif/plugin-autocomplete": "^3.2.39",
11
+ "@oclif/plugin-help": "^6",
12
+ "@oclif/plugin-plugins": "^5",
13
+ "@zip.js/zip.js": "^2.8.15",
14
+ "glob": "^13.0.0"
15
+ },
16
+ "devDependencies": {
17
+ "@eslint/compat": "^1",
18
+ "@oclif/prettier-config": "^0.2.1",
19
+ "@oclif/test": "^4",
20
+ "@types/chai": "^4",
21
+ "@types/mocha": "^10",
22
+ "@types/node": "^18",
23
+ "chai": "^4",
24
+ "eslint": "^9",
25
+ "eslint-config-oclif": "^6",
26
+ "eslint-config-prettier": "^10",
27
+ "mocha": "^10",
28
+ "oclif": "^4",
29
+ "shx": "^0.3.3",
30
+ "ts-node": "^10",
31
+ "typescript": "^5"
32
+ },
33
+ "engines": {
34
+ "node": ">=18.0.0"
35
+ },
8
36
  "files": [
9
- "dist/",
10
- "README.md",
11
- "LICENSE"
37
+ "./bin",
38
+ "./dist",
39
+ "./oclif.manifest.json"
12
40
  ],
13
- "scripts": {
14
- "build": "tsc",
15
- "dev": "ts-node src/index.ts"
16
- },
41
+ "homepage": "https://github.com/TraumDE/vcpm",
17
42
  "keywords": [
18
- "Voxel Core",
43
+ "oclif",
19
44
  "CLI",
20
- "Utility"
45
+ "VCPM",
46
+ "Voxel Core Project Manager",
47
+ "Voxel Core"
21
48
  ],
22
- "repository": {
23
- "type": "git",
24
- "url": "https://github.com/TraumDE/vcpm.git"
25
- },
26
- "author": "Eugene301|TraumDE",
27
49
  "license": "MIT",
28
- "packageManager": "yarn@4.12.0",
29
- "devDependencies": {
30
- "@types/archiver": "^7",
31
- "@types/node": "^25.0.3",
32
- "ts-node": "^10.9.2",
33
- "typescript": "^5.9.3"
50
+ "main": "dist/index.js",
51
+ "type": "module",
52
+ "oclif": {
53
+ "bin": "vcpm",
54
+ "dirname": "vcpm",
55
+ "commands": "./dist/commands",
56
+ "plugins": [
57
+ "@oclif/plugin-autocomplete"
58
+ ],
59
+ "topicSeparator": " ",
60
+ "topics": {
61
+ "hello": {
62
+ "description": "Say hello to the world and others"
63
+ }
64
+ }
34
65
  },
35
- "dependencies": {
36
- "archiver": "^7.0.1",
37
- "commander": "^14.0.2"
38
- }
66
+ "repository": "TraumDE/vcpm",
67
+ "scripts": {
68
+ "build": "shx rm -rf dist && tsc -b",
69
+ "lint": "eslint",
70
+ "postpack": "shx rm -f oclif.manifest.json",
71
+ "posttest": "yarn lint",
72
+ "prepack": "oclif manifest && oclif readme",
73
+ "test": "mocha --forbid-only \"test/**/*.test.ts\"",
74
+ "version": "oclif readme && git add README.md"
75
+ },
76
+ "types": "dist/index.d.ts",
77
+ "packageManager": "yarn@4.12.0"
39
78
  }
@@ -1,54 +0,0 @@
1
- "use strict";
2
- var __importDefault = (this && this.__importDefault) || function (mod) {
3
- return (mod && mod.__esModule) ? mod : { "default": mod };
4
- };
5
- Object.defineProperty(exports, "__esModule", { value: true });
6
- const process_1 = require("process");
7
- const fs_1 = __importDefault(require("fs"));
8
- const path_1 = require("path");
9
- const archiver_1 = __importDefault(require("archiver"));
10
- const isExists = (path) => {
11
- return fs_1.default.existsSync((0, path_1.join)((0, process_1.cwd)(), path));
12
- };
13
- const getPackData = () => {
14
- const jsonData = JSON.parse(fs_1.default.readFileSync((0, path_1.join)((0, process_1.cwd)(), "package.json"), "utf-8"));
15
- return {
16
- id: jsonData.id,
17
- version: jsonData.version,
18
- };
19
- };
20
- const createDistZip = (isDev) => {
21
- if (!isExists("package.json")) {
22
- console.log("Not found package.json!");
23
- return;
24
- }
25
- const packData = getPackData();
26
- const distPath = `dist/${packData.id}_${packData.version}.zip`;
27
- if (isExists(distPath)) {
28
- fs_1.default.rmSync(distPath);
29
- }
30
- const output = fs_1.default.createWriteStream(distPath);
31
- const archive = (0, archiver_1.default)("zip", { zlib: { level: 9 } });
32
- archive.pipe(output);
33
- archive.glob("**/*", {
34
- cwd: ".",
35
- ignore: isDev ? [] : ["**/.*/**", "**/.*", "modules/types/**", "dist/**"],
36
- dot: true,
37
- });
38
- archive.finalize();
39
- if (isDev) {
40
- console.log("Project builded for development!");
41
- }
42
- else {
43
- console.log("Project builded for production!");
44
- }
45
- };
46
- const checkDistFolder = () => {
47
- if (!isExists("dist")) {
48
- fs_1.default.mkdirSync("dist");
49
- }
50
- };
51
- exports.default = (options) => {
52
- checkDistFolder();
53
- createDistZip(options.dev);
54
- };
@@ -1,2 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
@@ -1,2 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });