New Version
This commit is contained in:
parent
f2892f1bf4
commit
ae4706c4c4
2
.npmrc
2
.npmrc
@ -1,2 +1,2 @@
|
|||||||
registry=https://git.tben.me/api/packages/Moduletrace/npm/
|
@moduletrace:registry=https://git.tben.me/api/packages/moduletrace/npm/
|
||||||
//git.tben.me/api/packages/Moduletrace/npm/:_authToken=${GITBEN_NPM_TOKEN}
|
//git.tben.me/api/packages/Moduletrace/npm/:_authToken=${GITBEN_NPM_TOKEN}
|
||||||
|
BIN
bin/turbosync
Executable file
BIN
bin/turbosync
Executable file
Binary file not shown.
51
index.d.ts
vendored
Normal file
51
index.d.ts
vendored
Normal file
@ -0,0 +1,51 @@
|
|||||||
|
// @ts-check
|
||||||
|
|
||||||
|
export type TurboSyncConfigArray = TurboSyncConfigObject[];
|
||||||
|
|
||||||
|
export interface TurboSyncConfigObject {
|
||||||
|
title?: string;
|
||||||
|
files?: string[] | TurboSyncFileObject[];
|
||||||
|
folders?: string[] | TurboSyncFileObject[];
|
||||||
|
options?: TurboSyncOptions;
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface TurboSyncFileObject {
|
||||||
|
path: string;
|
||||||
|
host?: string;
|
||||||
|
user?: string;
|
||||||
|
ssh_key?: string;
|
||||||
|
interval?: number;
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface TurboSyncOptions {
|
||||||
|
delete?: boolean;
|
||||||
|
exclude?: string[];
|
||||||
|
interval?: number;
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface SyncFilesFnParams {
|
||||||
|
files: string[] | TurboSyncFileObject[];
|
||||||
|
options: TurboSyncOptions | undefined;
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface SyncFilesSyncFnParams {
|
||||||
|
files: string[] | TurboSyncFileObject[];
|
||||||
|
options: TurboSyncOptions | undefined;
|
||||||
|
filePath: string;
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface SyncFoldersFnParams {
|
||||||
|
folders: string[] | TurboSyncFileObject[];
|
||||||
|
options: TurboSyncOptions | undefined;
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface SyncFoldersSyncFnParams {
|
||||||
|
dirs: string[] | TurboSyncFileObject[];
|
||||||
|
options: TurboSyncOptions | undefined;
|
||||||
|
dirPath: string;
|
||||||
|
init?: boolean;
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface HandleEnvVarsFnParams {
|
||||||
|
json: string;
|
||||||
|
}
|
24
index.js
24
index.js
@ -72,7 +72,7 @@ try {
|
|||||||
|
|
||||||
const parsedConfigJSON = handleEnvVars({ json: configJSON });
|
const parsedConfigJSON = handleEnvVars({ json: configJSON });
|
||||||
|
|
||||||
/** @type {TurboSyncConfigArray} */
|
/** @type {import(".").TurboSyncConfigArray} */
|
||||||
const configArray = JSON.parse(parsedConfigJSON);
|
const configArray = JSON.parse(parsedConfigJSON);
|
||||||
|
|
||||||
for (let i = 0; i < configArray.length; i++) {
|
for (let i = 0; i < configArray.length; i++) {
|
||||||
@ -91,14 +91,6 @@ try {
|
|||||||
}
|
}
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
// setTimeout(() => {
|
|
||||||
// if (configFinalPath) {
|
|
||||||
// fs.watchFile(configFinalPath, { interval: 2000 }, (curr, prev) => {
|
|
||||||
// process.exit(7);
|
|
||||||
// });
|
|
||||||
// }
|
|
||||||
// }, 1000);
|
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.log(`Process Error =>`, error.message);
|
console.log(`Process Error =>`, error.message);
|
||||||
process.exit();
|
process.exit();
|
||||||
@ -109,17 +101,3 @@ setInterval(() => {
|
|||||||
`Turbo Sync Running for ${process.uptime().toLocaleString()}s ...`
|
`Turbo Sync Running for ${process.uptime().toLocaleString()}s ...`
|
||||||
);
|
);
|
||||||
}, 60000);
|
}, 60000);
|
||||||
|
|
||||||
// process.on("exit", (code) => {
|
|
||||||
// if (code === 7) {
|
|
||||||
// console.log("Config file changed. Restarting Turbo Sync service ...");
|
|
||||||
|
|
||||||
// const args = process.argv;
|
|
||||||
// const cmd = args.shift();
|
|
||||||
// if (cmd) {
|
|
||||||
// spawn(cmd, args, {
|
|
||||||
// stdio: "inherit",
|
|
||||||
// });
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
// });
|
|
||||||
|
@ -9,7 +9,7 @@ const watchFolders = require("./watch/folders");
|
|||||||
const confFileProvidedJSON = process.argv[process.argv.length - 1];
|
const confFileProvidedJSON = process.argv[process.argv.length - 1];
|
||||||
|
|
||||||
try {
|
try {
|
||||||
/** @type {TurboSyncConfigObject} */
|
/** @type {import("..").TurboSyncConfigObject} */
|
||||||
const configFileObject = JSON.parse(confFileProvidedJSON);
|
const configFileObject = JSON.parse(confFileProvidedJSON);
|
||||||
|
|
||||||
console.log(`Running '${configFileObject.title}' ...`);
|
console.log(`Running '${configFileObject.title}' ...`);
|
||||||
|
25
package-lock.json
generated
25
package-lock.json
generated
@ -1,17 +1,36 @@
|
|||||||
{
|
{
|
||||||
"name": "turbo-sync",
|
"name": "@moduletrace/turbosync",
|
||||||
"version": "1.0.0",
|
"version": "1.0.0",
|
||||||
"lockfileVersion": 3,
|
"lockfileVersion": 3,
|
||||||
"requires": true,
|
"requires": true,
|
||||||
"packages": {
|
"packages": {
|
||||||
"": {
|
"": {
|
||||||
"name": "turbo-sync",
|
"name": "@moduletrace/turbosync",
|
||||||
"version": "1.0.0",
|
"version": "1.0.0",
|
||||||
"license": "ISC",
|
"license": "ISC",
|
||||||
"bin": {
|
"bin": {
|
||||||
"turbo-sync": "index.js",
|
|
||||||
"turbosync": "index.js"
|
"turbosync": "index.js"
|
||||||
|
},
|
||||||
|
"devDependencies": {
|
||||||
|
"@types/node": "^22.10.2"
|
||||||
}
|
}
|
||||||
|
},
|
||||||
|
"node_modules/@types/node": {
|
||||||
|
"version": "22.10.2",
|
||||||
|
"resolved": "https://registry.npmjs.org/@types/node/-/node-22.10.2.tgz",
|
||||||
|
"integrity": "sha512-Xxr6BBRCAOQixvonOye19wnzyDiUtTeqldOOmj3CkeblonbccA12PFwlufvRdrpjXxqnmUaeiU5EOA+7s5diUQ==",
|
||||||
|
"dev": true,
|
||||||
|
"license": "MIT",
|
||||||
|
"dependencies": {
|
||||||
|
"undici-types": "~6.20.0"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"node_modules/undici-types": {
|
||||||
|
"version": "6.20.0",
|
||||||
|
"resolved": "https://registry.npmjs.org/undici-types/-/undici-types-6.20.0.tgz",
|
||||||
|
"integrity": "sha512-Ny6QZ2Nju20vw1SRHe3d9jVu6gJ+4e3+MMpqu7pqE5HT6WsTSlce++GQmK5UXS8mzV8DSYHrQH+Xrf2jVcuKNg==",
|
||||||
|
"dev": true,
|
||||||
|
"license": "MIT"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
10
package.json
10
package.json
@ -1,10 +1,11 @@
|
|||||||
{
|
{
|
||||||
"name": "turbosync",
|
"name": "@moduletrace/turbosync",
|
||||||
"version": "1.3.4",
|
"version": "1.0.0",
|
||||||
"module": "index.js",
|
"module": "index.js",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"start": "node index.ts",
|
"start": "node index.ts",
|
||||||
"build": "tsc",
|
"build": "tsc",
|
||||||
|
"compile": "bun build index.js --compile --outfile bin/turbosync",
|
||||||
"dev": "node index.js --watch"
|
"dev": "node index.js --watch"
|
||||||
},
|
},
|
||||||
"bin": {
|
"bin": {
|
||||||
@ -13,5 +14,8 @@
|
|||||||
"description": "Sync files and directories with ease",
|
"description": "Sync files and directories with ease",
|
||||||
"main": "index.js",
|
"main": "index.js",
|
||||||
"author": "Benjamin Toby",
|
"author": "Benjamin Toby",
|
||||||
"license": "ISC"
|
"license": "ISC",
|
||||||
|
"devDependencies": {
|
||||||
|
"@types/node": "^22.10.2"
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
12
publish.sh
Executable file
12
publish.sh
Executable file
@ -0,0 +1,12 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
if [ -z "$1" ]; then
|
||||||
|
msg="Updates"
|
||||||
|
else
|
||||||
|
msg="$1"
|
||||||
|
fi
|
||||||
|
|
||||||
|
git add .
|
||||||
|
git commit -m "$msg"
|
||||||
|
git push
|
||||||
|
npm publish
|
61
types.js
61
types.js
@ -1,61 +0,0 @@
|
|||||||
// @ts-check
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @typedef {TurboSyncConfigObject[]} TurboSyncConfigArray
|
|
||||||
*/
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @typedef {object} TurboSyncConfigObject
|
|
||||||
* @property {string} [title]
|
|
||||||
* @property {string[] | TurboSyncFileObject[]} [files]
|
|
||||||
* @property {string[] | TurboSyncFileObject[]} [folders]
|
|
||||||
* @property {TurboSyncOptions} [options]
|
|
||||||
*/
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @typedef {object} TurboSyncFileObject
|
|
||||||
* @property {string} path
|
|
||||||
* @property {string} [host]
|
|
||||||
* @property {string} [user]
|
|
||||||
* @property {string} [ssh_key]
|
|
||||||
* @property {number} [interval]
|
|
||||||
*/
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @typedef {object} TurboSyncOptions
|
|
||||||
* @property {boolean} [delete] - Should files removed be deleted in all destinations?
|
|
||||||
* @property {string[]} [exclude] - Patterns that should be ignored. Eg "*.log"
|
|
||||||
* @property {number} [interval] - Seconds to delay before update
|
|
||||||
*/
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @typedef {object} SyncFilesFnParams
|
|
||||||
* @property {string[] | TurboSyncFileObject[]} files
|
|
||||||
* @property {TurboSyncOptions | undefined} options
|
|
||||||
*/
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @typedef {object} SyncFilesSyncFnParams
|
|
||||||
* @property {string[] | TurboSyncFileObject[]} files
|
|
||||||
* @property {TurboSyncOptions | undefined} options
|
|
||||||
* @property {string} filePath
|
|
||||||
*/
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @typedef {object} SyncFoldersFnParams
|
|
||||||
* @property {string[] | TurboSyncFileObject[]} folders
|
|
||||||
* @property {TurboSyncOptions | undefined} options
|
|
||||||
*/
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @typedef {object} SyncFoldersSyncFnParams
|
|
||||||
* @property {string[] | TurboSyncFileObject[]} dirs
|
|
||||||
* @property {TurboSyncOptions | undefined} options
|
|
||||||
* @property {string} dirPath
|
|
||||||
* @property {boolean} [init] - is this an initialization phase?
|
|
||||||
*/
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @typedef {object} HandleEnvVarsFnParams
|
|
||||||
* @property {string} json
|
|
||||||
*/
|
|
Loading…
Reference in New Issue
Block a user