syncodemayo 1.0.8 → 2.0.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.
Files changed (78) hide show
  1. package/CHANGELOG.md +81 -0
  2. package/README.md +99 -30
  3. package/dist/cli.d.ts +2 -0
  4. package/dist/cli.js +66 -0
  5. package/dist/cli.js.map +1 -0
  6. package/dist/env.d.ts +1 -0
  7. package/dist/env.js +17 -0
  8. package/dist/env.js.map +1 -0
  9. package/dist/index.d.ts +1 -0
  10. package/dist/index.js +2 -0
  11. package/dist/index.js.map +1 -0
  12. package/dist/lib/Args.d.ts +21 -0
  13. package/dist/lib/Args.js +99 -0
  14. package/dist/lib/Args.js.map +1 -0
  15. package/{lib → dist/lib}/Cli.d.ts +5 -0
  16. package/dist/lib/Cli.js +104 -0
  17. package/dist/lib/Cli.js.map +1 -0
  18. package/{lib → dist/lib}/Client.d.ts +5 -3
  19. package/dist/lib/Client.js +73 -0
  20. package/dist/lib/Client.js.map +1 -0
  21. package/dist/lib/Config.d.ts +48 -0
  22. package/dist/lib/Config.js +92 -0
  23. package/dist/lib/Config.js.map +1 -0
  24. package/dist/lib/ConfigSchema.d.ts +3 -0
  25. package/dist/lib/ConfigSchema.js +132 -0
  26. package/dist/lib/ConfigSchema.js.map +1 -0
  27. package/dist/lib/Connection.d.ts +41 -0
  28. package/dist/lib/Connection.js +176 -0
  29. package/dist/lib/Connection.js.map +1 -0
  30. package/dist/lib/Filelist.d.ts +42 -0
  31. package/dist/lib/Filelist.js +156 -0
  32. package/dist/lib/Filelist.js.map +1 -0
  33. package/dist/lib/Log.d.ts +12 -0
  34. package/dist/lib/Log.js +46 -0
  35. package/dist/lib/Log.js.map +1 -0
  36. package/dist/lib/Prompt.d.ts +15 -0
  37. package/dist/lib/Prompt.js +31 -0
  38. package/dist/lib/Prompt.js.map +1 -0
  39. package/dist/lib/RemoteConnection.d.ts +37 -0
  40. package/dist/lib/RemoteConnection.js +2 -0
  41. package/dist/lib/RemoteConnection.js.map +1 -0
  42. package/dist/lib/Sync.d.ts +18 -0
  43. package/dist/lib/Sync.js +127 -0
  44. package/dist/lib/Sync.js.map +1 -0
  45. package/dist/lib/TargetServer.d.ts +31 -0
  46. package/dist/lib/TargetServer.js +76 -0
  47. package/dist/lib/TargetServer.js.map +1 -0
  48. package/dist/lib/index.d.ts +8 -0
  49. package/dist/lib/index.js +9 -0
  50. package/dist/lib/index.js.map +1 -0
  51. package/dist/vendor/strip-json-comments.d.ts +23 -0
  52. package/dist/vendor/strip-json-comments.js +126 -0
  53. package/dist/vendor/strip-json-comments.js.map +1 -0
  54. package/package.json +24 -26
  55. package/.npmignore +0 -9
  56. package/cli.d.ts +0 -0
  57. package/cli.js +0 -93
  58. package/index.d.ts +0 -1
  59. package/index.js +0 -7
  60. package/lib/Cli.js +0 -122
  61. package/lib/Client.js +0 -81
  62. package/lib/Config.d.ts +0 -32
  63. package/lib/Config.js +0 -115
  64. package/lib/ConfigSchema.d.ts +0 -7
  65. package/lib/ConfigSchema.js +0 -65
  66. package/lib/Connection.d.ts +0 -14
  67. package/lib/Connection.js +0 -111
  68. package/lib/Filelist.d.ts +0 -11
  69. package/lib/Filelist.js +0 -59
  70. package/lib/Sync.d.ts +0 -18
  71. package/lib/Sync.js +0 -141
  72. package/lib/TargetServer.d.ts +0 -22
  73. package/lib/TargetServer.js +0 -73
  74. package/lib/index.d.ts +0 -7
  75. package/lib/index.js +0 -13
  76. package/missing-types.d.ts +0 -14
  77. package/tsconfig.json +0 -48
  78. package/yarn.lock +0 -975
package/lib/Sync.js DELETED
@@ -1,141 +0,0 @@
1
- "use strict";
2
- var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
- return new (P || (P = Promise))(function (resolve, reject) {
4
- function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
5
- function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
6
- function step(result) { result.done ? resolve(result.value) : new P(function (resolve) { resolve(result.value); }).then(fulfilled, rejected); }
7
- step((generator = generator.apply(thisArg, _arguments || [])).next());
8
- });
9
- };
10
- Object.defineProperty(exports, "__esModule", { value: true });
11
- const path = require("path");
12
- const yesno = require("yesno");
13
- const Config_1 = require("./Config");
14
- const Filelist_1 = require("./Filelist");
15
- class Sync {
16
- constructor(conn, config, target) {
17
- this._conn = conn;
18
- this._config = config;
19
- this._target = Config_1.resolveTarget(config, target);
20
- }
21
- run(isDryRun = false, forceConfirmation = false) {
22
- return __awaiter(this, void 0, void 0, function* () {
23
- const { localFiles, remoteFiles } = yield this._getFilelists(this._config.local, this._target, this._conn);
24
- const changeset = this._buildChangeset(localFiles, remoteFiles);
25
- const filesToUpload = [...changeset.added, ...changeset.changed];
26
- if (isDryRun || (filesToUpload.length === 0 && changeset.removed.length === 0)) {
27
- return changeset;
28
- }
29
- const _verifiedDirs = new Map();
30
- const verifyDirExists = (remoteDir) => __awaiter(this, void 0, void 0, function* () {
31
- if (!_verifiedDirs.has(remoteDir)) {
32
- const isVerified = yield this._conn.remoteDirectoryExists(remoteDir);
33
- _verifiedDirs.set(remoteDir, isVerified);
34
- }
35
- return true;
36
- });
37
- console.log("\n%s files to upload...", filesToUpload.length);
38
- console.log("%s files to remove...\n", changeset.removed.length);
39
- const confirmed = forceConfirmation === true
40
- ? true
41
- : yield this._confirmUpload(this._target, filesToUpload.length);
42
- if (!confirmed) {
43
- console.error("Canceled upload.");
44
- return null;
45
- }
46
- console.log("Uploading %s files...", filesToUpload.length);
47
- let sequentialUploader = Promise.resolve(true);
48
- filesToUpload.forEach((filePath) => {
49
- sequentialUploader = sequentialUploader.then(() => __awaiter(this, void 0, void 0, function* () {
50
- const remotePath = `${this._target.path}${filePath.replace(this._config.local.path, '')}`;
51
- const remoteDir = path.dirname(remotePath);
52
- const localPath = path.resolve(filePath);
53
- yield verifyDirExists(remoteDir);
54
- yield this._conn.putFile(localPath, remotePath);
55
- return true;
56
- }));
57
- });
58
- if (this._config.local.deleteRemoteFiles && changeset.removed.length > 0) {
59
- changeset.removed.forEach((filePath) => {
60
- sequentialUploader = sequentialUploader.then(() => __awaiter(this, void 0, void 0, function* () {
61
- const remotePath = `${this._target.path}${filePath.replace(this._config.local.path, '')}`;
62
- const didDelete = yield this._conn.deleteRemoteFile(remotePath);
63
- if (!didDelete)
64
- console.log(" -> Error deleting file");
65
- return true;
66
- }));
67
- });
68
- }
69
- yield sequentialUploader;
70
- // await Promise.all(
71
- // filesToUpload.map(async (filePath: string) => {
72
- // const remotePath = `${this._target.path}${filePath.replace(this._config.local.path, '')}`
73
- // const remoteDir = path.dirname(remotePath)
74
- // console.log(" ?", remoteDir)
75
- // await verifyDirExists(remoteDir)
76
- // console.log(" -", filePath)
77
- // await this._conn.putFile(filePath, remotePath)
78
- // return filePath
79
- // })
80
- // )
81
- const remoteCachePath = `${this._target.path}/${this._target.cache}`;
82
- yield verifyDirExists(path.dirname(remoteCachePath));
83
- yield this._conn.putContent(JSON.stringify(localFiles, null, 2), remoteCachePath);
84
- return changeset;
85
- });
86
- }
87
- _confirmUpload(target, fileCount) {
88
- // If no prompt is specified, auto-confirm upload!
89
- return new Promise(resolve => {
90
- if (!target.prompt)
91
- return resolve(true);
92
- const message = typeof target.prompt === 'string'
93
- ? target.prompt
94
- : "Confirm upload?";
95
- yesno.ask(`${message} - (Yes will upload)`, null, resolve);
96
- });
97
- }
98
- _getFilelists(local, target, conn) {
99
- return __awaiter(this, void 0, void 0, function* () {
100
- // Load/build Filesets in parralel.
101
- const remoteFilesLoader = Filelist_1.getRemoteFilelist(target, conn);
102
- const localFilesBuilder = Filelist_1.buildLocalFilelist(local);
103
- return {
104
- localFiles: yield localFilesBuilder,
105
- remoteFiles: yield remoteFilesLoader
106
- };
107
- });
108
- }
109
- _buildChangeset(localFiles, remoteFiles) {
110
- const changeset = {
111
- added: [],
112
- removed: [],
113
- changed: []
114
- };
115
- // Build list of files that need to be uploaded...
116
- Object.keys(localFiles).forEach((localFilename) => {
117
- const localHash = localFiles[localFilename];
118
- const remoteHash = remoteFiles[localFilename];
119
- // Local hash not in remote cache
120
- if (!(localFilename in remoteFiles)) {
121
- changeset.added.push(localFilename);
122
- }
123
- else if (remoteHash != localHash) {
124
- changeset.changed.push(localFilename);
125
- }
126
- // Local hash and remote hash are equal!
127
- });
128
- // Build list of files to be removed from the server...
129
- Object.keys(remoteFiles).forEach((remoteFilename) => {
130
- if (!(remoteFilename in localFiles)) {
131
- changeset.removed.push(remoteFilename);
132
- }
133
- });
134
- return changeset;
135
- }
136
- static create(conn, config, target) {
137
- return new Sync(conn, config, target);
138
- }
139
- }
140
- exports.Sync = Sync;
141
- //# sourceMappingURL=Sync.js.map
@@ -1,22 +0,0 @@
1
- import { IConfig, ITargetConfig } from './Config';
2
- import { IChangeset } from './Sync';
3
- export declare class TargetServer {
4
- private _config;
5
- private _targetConfig;
6
- readonly config: ITargetConfig;
7
- readonly name: string;
8
- constructor(config: IConfig, target: string | ITargetConfig | undefined);
9
- /**
10
- * Add a cache file, if there's not one
11
- */
12
- prepare(force?: boolean): Promise<boolean>;
13
- /**
14
- * Verify the server has a cache file
15
- */
16
- verify(): Promise<boolean>;
17
- /**
18
- * Sync local files to target server
19
- */
20
- sync(isDryRun: boolean, forceConfirmation?: boolean): Promise<IChangeset | null>;
21
- static create(config: IConfig, targetConfig: string | ITargetConfig | undefined): TargetServer;
22
- }
@@ -1,73 +0,0 @@
1
- "use strict";
2
- var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
- return new (P || (P = Promise))(function (resolve, reject) {
4
- function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
5
- function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
6
- function step(result) { result.done ? resolve(result.value) : new P(function (resolve) { resolve(result.value); }).then(fulfilled, rejected); }
7
- step((generator = generator.apply(thisArg, _arguments || [])).next());
8
- });
9
- };
10
- Object.defineProperty(exports, "__esModule", { value: true });
11
- const Config_1 = require("./Config");
12
- const Connection_1 = require("./Connection");
13
- const Sync_1 = require("./Sync");
14
- class TargetServer {
15
- get config() {
16
- return this._targetConfig;
17
- }
18
- get name() {
19
- return this.config._name;
20
- }
21
- constructor(config, target) {
22
- this._config = config;
23
- this._targetConfig = Config_1.resolveTarget(config, target);
24
- }
25
- /**
26
- * Add a cache file, if there's not one
27
- */
28
- prepare(force) {
29
- return __awaiter(this, void 0, void 0, function* () {
30
- const remoteCachePath = `${this._targetConfig.path}/${this._targetConfig.cache}`;
31
- const conn = Connection_1.Connection.create(this._targetConfig);
32
- const remoteIsConfigured = yield conn.remoteFileExists(remoteCachePath);
33
- if (remoteIsConfigured && force !== true) {
34
- console.log(`${this._targetConfig.host} already is initialized.`);
35
- return false;
36
- }
37
- const remoteDirExists = yield conn.remoteDirectoryExists(this._targetConfig.path);
38
- if (!remoteDirExists) {
39
- throw new Error("Remote path not found: " + this._targetConfig.path);
40
- }
41
- yield conn.putContent("{}", remoteCachePath);
42
- return true;
43
- });
44
- }
45
- /**
46
- * Verify the server has a cache file
47
- */
48
- verify() {
49
- return __awaiter(this, void 0, void 0, function* () {
50
- const remoteCachePath = `${this._targetConfig.path}/${this._targetConfig.cache}`;
51
- const conn = Connection_1.Connection.create(this._targetConfig);
52
- const remoteIsConfigured = yield conn.remoteFileExists(remoteCachePath);
53
- if (remoteIsConfigured) {
54
- return true;
55
- }
56
- return false;
57
- });
58
- }
59
- /**
60
- * Sync local files to target server
61
- */
62
- sync(isDryRun, forceConfirmation = false) {
63
- return __awaiter(this, void 0, void 0, function* () {
64
- const sync = Sync_1.Sync.create(Connection_1.Connection.create(this._targetConfig), this._config, this._targetConfig);
65
- return sync.run(isDryRun, forceConfirmation);
66
- });
67
- }
68
- static create(config, targetConfig) {
69
- return new TargetServer(config, targetConfig);
70
- }
71
- }
72
- exports.TargetServer = TargetServer;
73
- //# sourceMappingURL=TargetServer.js.map
package/lib/index.d.ts DELETED
@@ -1,7 +0,0 @@
1
- export * from './Client';
2
- export * from './Config';
3
- export * from './ConfigSchema';
4
- export * from './Connection';
5
- export * from './Filelist';
6
- export * from './Sync';
7
- export * from './TargetServer';
package/lib/index.js DELETED
@@ -1,13 +0,0 @@
1
- "use strict";
2
- function __export(m) {
3
- for (var p in m) if (!exports.hasOwnProperty(p)) exports[p] = m[p];
4
- }
5
- Object.defineProperty(exports, "__esModule", { value: true });
6
- __export(require("./Client"));
7
- __export(require("./Config"));
8
- __export(require("./ConfigSchema"));
9
- __export(require("./Connection"));
10
- __export(require("./Filelist"));
11
- __export(require("./Sync"));
12
- __export(require("./TargetServer"));
13
- //# sourceMappingURL=index.js.map
@@ -1,14 +0,0 @@
1
- declare module 'jsftp'
2
- declare module 'jsftp-mkdirp'
3
- declare module 'yesno'
4
- declare module 'strip-json-comments'
5
-
6
- // declare module 'strip-json-comments' {
7
- // interface StripJsonOptions {
8
- // whitespace?: boolean;
9
- // }
10
-
11
- // export function stripJsonComments(input: string, opts?: StripJsonOptions): string;
12
-
13
- // // export = stripJsonComments;
14
- // }
package/tsconfig.json DELETED
@@ -1,48 +0,0 @@
1
- {
2
- "compilerOptions": {
3
- /* Basic Options */
4
- "target": "es2015", /* Specify ECMAScript target version: 'ES3' (default), 'ES5', 'ES2015', 'ES2016', 'ES2017', or 'ESNEXT'. */
5
- "module": "commonjs", /* Specify module code generation: 'commonjs', 'amd', 'system', 'umd', 'es2015', or 'ESNext'. */
6
- // "lib": [], /* Specify library files to be included in the compilation: */
7
- // "allowJs": true, /* Allow javascript files to be compiled. */
8
- // "checkJs": true, /* Report errors in .js files. */
9
- // "jsx": "preserve", /* Specify JSX code generation: 'preserve', 'react-native', or 'react'. */
10
- "declaration": true, /* Generates corresponding '.d.ts' file. */
11
- "sourceMap": true, /* Generates corresponding '.map' file. */
12
- // "outFile": "./", /* Concatenate and emit output to single file. */
13
- // "outDir": "./", /* Redirect output structure to the directory. */
14
- // "rootDir": "./", /* Specify the root directory of input files. Use to control the output directory structure with --outDir. */
15
- "removeComments": false, /* Do not emit comments to output. */
16
- // "noEmit": true, /* Do not emit outputs. */
17
- // "importHelpers": true, /* Import emit helpers from 'tslib'. */
18
- // "downlevelIteration": true, /* Provide full support for iterables in 'for-of', spread, and destructuring when targeting 'ES5' or 'ES3'. */
19
- // "isolatedModules": true, /* Transpile each file as a separate module (similar to 'ts.transpileModule'). */
20
- /* Strict Type-Checking Options */
21
- "strict": true, /* Enable all strict type-checking options. */
22
- // "noImplicitAny": true, /* Raise error on expressions and declarations with an implied 'any' type. */
23
- // "strictNullChecks": true, /* Enable strict null checks. */
24
- // "noImplicitThis": true, /* Raise error on 'this' expressions with an implied 'any' type. */
25
- "alwaysStrict": true, /* Parse in strict mode and emit "use strict" for each source file. */
26
- /* Additional Checks */
27
- "noUnusedLocals": true, /* Report errors on unused locals. */
28
- // "noUnusedParameters": true, /* Report errors on unused parameters. */
29
- // "noImplicitReturns": true, /* Report error when not all code paths in function return a value. */
30
- // "noFallthroughCasesInSwitch": true, /* Report errors for fallthrough cases in switch statement. */
31
- /* Module Resolution Options */
32
- // "moduleResolution": "node", /* Specify module resolution strategy: 'node' (Node.js) or 'classic' (TypeScript pre-1.6). */
33
- // "baseUrl": "./", /* Base directory to resolve non-absolute module names. */
34
- // "paths": {}, /* A series of entries which re-map imports to lookup locations relative to the 'baseUrl'. */
35
- // "rootDirs": [], /* List of root folders whose combined content represents the structure of the project at runtime. */
36
- // "typeRoots": [], /* List of folders to include type definitions from. */
37
- // "types": [], /* Type declaration files to be included in compilation. */
38
- // "allowSyntheticDefaultImports": true, /* Allow default imports from modules with no default export. This does not affect code emit, just typechecking. */
39
- /* Source Map Options */
40
- "sourceRoot": "./", /* Specify the location where debugger should locate TypeScript files instead of source locations. */
41
- // "mapRoot": "./", /* Specify the location where debugger should locate map files instead of generated locations. */
42
- // "inlineSourceMap": true, /* Emit a single file with source maps instead of having a separate file. */
43
- "inlineSources": true, /* Emit the source alongside the sourcemaps within a single file; requires '--inlineSourceMap' or '--sourceMap' to be set. */
44
- /* Experimental Options */
45
- // "emitDecoratorMetadata": true, /* Enables experimental support for emitting type metadata for decorators. */
46
- "experimentalDecorators": true /* Enables experimental support for ES7 decorators. */
47
- }
48
- }