@wireapp/copy-config 2.2.3-hotfix-1.2 → 2.2.3-hotfix-1.3

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
@@ -38,6 +38,6 @@ Additionally, some parameters can be set via environment variables (which then t
38
38
  copy-config
39
39
  ```
40
40
 
41
- ### API Usage
41
+ ### API Usage:
42
42
 
43
43
  See [`cli.ts`](./src/main/cli.ts).
@@ -1,11 +1,12 @@
1
+ import logdown from 'logdown';
1
2
  import { CopyConfigOptions } from './CopyConfigOptions';
2
3
  export declare class CopyConfig {
4
+ private readonly logger?;
3
5
  private readonly options;
4
- private readonly logger;
5
6
  private readonly noClone;
6
7
  private readonly noCleanup;
7
8
  private readonly filterFiles;
8
- constructor(options: CopyConfigOptions);
9
+ constructor(options: CopyConfigOptions | undefined, logger?: logdown.Logger | undefined);
9
10
  private readEnvVars;
10
11
  private getFilesFromString;
11
12
  private resolveFiles;
@@ -1 +1 @@
1
- {"version":3,"file":"CopyConfig.d.ts","sourceRoot":"","sources":["../src/CopyConfig.ts"],"names":[],"mappings":"AAwBA,OAAO,EAAC,iBAAiB,EAAC,MAAM,qBAAqB,CAAC;AAWtD,qBAAa,UAAU;IACrB,OAAO,CAAC,QAAQ,CAAC,OAAO,CAA8B;IACtD,OAAO,CAAC,QAAQ,CAAC,MAAM,CAAiB;IACxC,OAAO,CAAC,QAAQ,CAAC,OAAO,CAAkB;IAC1C,OAAO,CAAC,QAAQ,CAAC,SAAS,CAAkB;IAC5C,OAAO,CAAC,QAAQ,CAAC,WAAW,CAA2B;gBAE3C,OAAO,EAAE,iBAAiB;IAqBtC,OAAO,CAAC,WAAW;IAmBnB,OAAO,CAAC,kBAAkB;IAkB1B,OAAO,CAAC,YAAY;IAmBP,aAAa,CAAC,MAAM,EAAE,MAAM,EAAE,WAAW,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,EAAE,CAAC;YA0CpE,KAAK;YAkCL,aAAa;IAKd,IAAI,IAAI,OAAO,CAAC,MAAM,EAAE,CAAC;CA0BvC"}
1
+ {"version":3,"file":"CopyConfig.d.ts","sourceRoot":"","sources":["../src/CopyConfig.ts"],"names":[],"mappings":"AAoBA,OAAO,OAAO,MAAM,SAAS,CAAC;AAI9B,OAAO,EAAC,iBAAiB,EAAC,MAAM,qBAAqB,CAAC;AAYtD,qBAAa,UAAU;IAQnB,OAAO,CAAC,QAAQ,CAAC,MAAM,CAAC;IAP1B,OAAO,CAAC,QAAQ,CAAC,OAAO,CAA8B;IACtD,OAAO,CAAC,QAAQ,CAAC,OAAO,CAAkB;IAC1C,OAAO,CAAC,QAAQ,CAAC,SAAS,CAAkB;IAC5C,OAAO,CAAC,QAAQ,CAAC,WAAW,CAA2B;gBAGrD,OAAO,EAAE,iBAAiB,GAAG,SAAS,EACrB,MAAM,CAAC,4BAAgB;IAiB1C,OAAO,CAAC,WAAW;IAmBnB,OAAO,CAAC,kBAAkB;IAkB1B,OAAO,CAAC,YAAY;IAmBP,aAAa,CAAC,MAAM,EAAE,MAAM,EAAE,WAAW,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,EAAE,CAAC;YA2CpE,KAAK;YAkCL,aAAa;IAKd,IAAI,IAAI,OAAO,CAAC,MAAM,EAAE,CAAC;CA0BvC"}
package/lib/CopyConfig.js CHANGED
@@ -46,18 +46,19 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
46
46
  Object.defineProperty(exports, "__esModule", { value: true });
47
47
  exports.CopyConfig = void 0;
48
48
  const fs = __importStar(require("fs-extra"));
49
- const logdown_1 = __importDefault(require("logdown"));
50
49
  const path_1 = __importDefault(require("path"));
51
50
  const utils = __importStar(require("./utils"));
52
51
  const defaultOptions = {
53
52
  baseDir: 'config',
54
53
  externalDir: '',
55
54
  files: {},
55
+ logLevel: 'info',
56
56
  forceDownload: false,
57
57
  repositoryUrl: 'https://github.com/wireapp/wire-web-config-default#master',
58
58
  };
59
59
  class CopyConfig {
60
- constructor(options) {
60
+ constructor(options, logger) {
61
+ this.logger = logger;
61
62
  this.noClone = false;
62
63
  this.noCleanup = false;
63
64
  this.filterFiles = ['.DS_Store'];
@@ -72,10 +73,6 @@ class CopyConfig {
72
73
  this.options.baseDir = this.options.externalDir;
73
74
  }
74
75
  this.options.baseDir = path_1.default.resolve(this.options.baseDir);
75
- this.logger = (0, logdown_1.default)('@wireapp/copy-config/CopyConfig', {
76
- markdown: false,
77
- });
78
- this.logger.state.isEnabled = true;
79
76
  }
80
77
  readEnvVars() {
81
78
  const externalDir = process.env.WIRE_CONFIGURATION_EXTERNAL_DIR;
@@ -121,6 +118,7 @@ class CopyConfig {
121
118
  });
122
119
  }
123
120
  async copyDirOrFile(source, destination) {
121
+ var _a, _b, _c;
124
122
  const filter = (src) => {
125
123
  for (const fileName in this.filterFiles) {
126
124
  if (src.endsWith(fileName)) {
@@ -134,24 +132,26 @@ class CopyConfig {
134
132
  throw new Error('Cannot copy a directory into a file.');
135
133
  }
136
134
  if (isGlob(source)) {
137
- this.logger.info(`Resolving "${source}"`);
135
+ (_a = this.logger) === null || _a === void 0 ? void 0 : _a.info(`Resolving "${source}"`);
138
136
  const copiedFiles = await utils.copyAsync(source, destination);
139
137
  for (const copiedFile of copiedFiles) {
140
138
  const [copiedFrom, copiedTo] = copiedFile.history;
141
- this.logger.info(`Copying "${copiedFrom}" -> "${copiedTo}"`);
139
+ (_b = this.logger) === null || _b === void 0 ? void 0 : _b.debug(`Copying "${copiedFrom}" -> "${copiedTo}"`);
142
140
  }
143
141
  return copiedFiles.map(file => file.path);
144
142
  }
145
143
  if (utils.isFile(source) && !utils.isFile(destination)) {
146
144
  destination = path_1.default.join(destination, path_1.default.basename(source));
147
145
  }
148
- this.logger.info(`Copying "${source}" -> "${destination}"`);
146
+ (_c = this.logger) === null || _c === void 0 ? void 0 : _c.debug(`Copying "${source}" -> "${destination}"`);
149
147
  // Info: "fs.copy" creates all sub-folders which are needed along the way:
150
148
  // see https://github.com/jprichardson/node-fs-extra/blob/7.0.1/lib/copy/copy.js#L43
151
- await fs.copy(source, destination, { filter, overwrite: true, recursive: true });
149
+ // by default, fs.copy() copies folders recursively
150
+ await fs.copy(source, destination, { filter, overwrite: true });
152
151
  return [destination];
153
152
  }
154
153
  async clone() {
154
+ var _a, _b, _c;
155
155
  const repositoryData = this.options.repositoryUrl.split('#');
156
156
  let bareUrl = repositoryData[0];
157
157
  const branch = repositoryData[1] || 'master';
@@ -160,7 +160,7 @@ class CopyConfig {
160
160
  await this.removeBasedir();
161
161
  }
162
162
  if (stderrVersion) {
163
- this.logger.error(`No git installation found: (error: "${stderrVersion}"). Trying to download the zip file ...`);
163
+ (_a = this.logger) === null || _a === void 0 ? void 0 : _a.error(`No git installation found: (error: "${stderrVersion}"). Trying to download the zip file ...`);
164
164
  }
165
165
  if (stderrVersion || this.options.forceDownload) {
166
166
  if (bareUrl.startsWith('git')) {
@@ -168,11 +168,11 @@ class CopyConfig {
168
168
  bareUrl = bareUrl.replace(gitProtocolRegex, 'https://$1$2/$3');
169
169
  }
170
170
  const url = `${bareUrl}/archive/${branch}.zip`;
171
- this.logger.info(`Downloading "${url}" ...`);
171
+ (_b = this.logger) === null || _b === void 0 ? void 0 : _b.info(`Downloading "${url}" ...`);
172
172
  await utils.downloadFileAsync(url, this.options.baseDir);
173
173
  }
174
174
  else {
175
- this.logger.info(`Cloning "${bareUrl}" (branch "${branch}") ...`);
175
+ (_c = this.logger) === null || _c === void 0 ? void 0 : _c.info(`Cloning "${bareUrl}" (branch "${branch}") ...`);
176
176
  const command = `git clone --depth 1 -b ${branch} ${bareUrl} ${this.options.baseDir}`;
177
177
  const { stderr: stderrClone } = await utils.execAsync(command);
178
178
  if (stderrClone.includes('fatal')) {
@@ -181,7 +181,8 @@ class CopyConfig {
181
181
  }
182
182
  }
183
183
  async removeBasedir() {
184
- this.logger.info(`Cleaning up "${this.options.baseDir}" ...`);
184
+ var _a;
185
+ (_a = this.logger) === null || _a === void 0 ? void 0 : _a.debug(`Cleaning up "${this.options.baseDir}" ...`);
185
186
  await utils.rimrafAsync(this.options.baseDir);
186
187
  }
187
188
  async copy() {
@@ -33,5 +33,6 @@ export interface CopyConfigOptions {
33
33
  * @example `https://github.com/wireapp/wire-web-config-default#v0.7.1`
34
34
  */
35
35
  repositoryUrl: string;
36
+ logLevel?: 'verbose' | 'info' | 'silent';
36
37
  }
37
38
  //# sourceMappingURL=CopyConfigOptions.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"CopyConfigOptions.d.ts","sourceRoot":"","sources":["../src/CopyConfigOptions.ts"],"names":[],"mappings":"AAmBA,MAAM,WAAW,iBAAiB;IAChC;;;;OAIG;IACH,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB;;;;;OAKG;IACH,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB;;;;;;;;;;;OAWG;IACH,KAAK,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,EAAE,CAAC,CAAC;IAC1C,kDAAkD;IAClD,aAAa,CAAC,EAAE,OAAO,CAAC;IACxB;;;;OAIG;IACH,aAAa,EAAE,MAAM,CAAC;CACvB"}
1
+ {"version":3,"file":"CopyConfigOptions.d.ts","sourceRoot":"","sources":["../src/CopyConfigOptions.ts"],"names":[],"mappings":"AAmBA,MAAM,WAAW,iBAAiB;IAChC;;;;OAIG;IACH,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB;;;;;OAKG;IACH,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB;;;;;;;;;;;OAWG;IACH,KAAK,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,EAAE,CAAC,CAAC;IAC1C,kDAAkD;IAClD,aAAa,CAAC,EAAE,OAAO,CAAC;IACxB;;;;OAIG;IACH,aAAa,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,EAAE,SAAS,GAAG,MAAM,GAAG,QAAQ,CAAC;CAC1C"}
package/lib/cli.js CHANGED
@@ -26,20 +26,25 @@ Object.defineProperty(exports, "__esModule", { value: true });
26
26
  const cosmiconfig_1 = require("cosmiconfig");
27
27
  const logdown_1 = __importDefault(require("logdown"));
28
28
  const _1 = require("./");
29
- const configExplorer = (0, cosmiconfig_1.cosmiconfig)('copyconfig');
30
- const logger = (0, logdown_1.default)('@wireapp/copy-config/cli', {
31
- markdown: false,
32
- });
33
- logger.state.isEnabled = true;
34
29
  (async () => {
30
+ const configExplorer = (0, cosmiconfig_1.cosmiconfig)('copyconfig');
35
31
  const configFile = await configExplorer.search();
36
- if (configFile) {
37
- logger.info(`Found configuration file "${configFile.filepath}".`);
38
- }
39
32
  const config = configFile ? configFile.config : undefined;
40
- const copiedFiles = await new _1.CopyConfig(config).copy();
33
+ const logLevel = (config === null || config === void 0 ? void 0 : config.logLevel) || 'info';
34
+ const logger = logLevel !== 'silent' ? (0, logdown_1.default)('@wireapp/copy-config', { markdown: false }) : undefined;
35
+ if (logger) {
36
+ logger.state.isEnabled = true;
37
+ if (configFile) {
38
+ logger.info(`Found configuration file "${configFile.filepath}".`);
39
+ }
40
+ if (logLevel !== 'verbose') {
41
+ // Disable debug logging when not in verbose mode
42
+ logger.debug = () => { };
43
+ }
44
+ }
45
+ const copiedFiles = await new _1.CopyConfig(config, logger).copy();
41
46
  const copyMessage = copiedFiles.length ? `Copied ${copiedFiles.length}` : "Didn't copy any";
42
- logger.info(`${copyMessage} file${copiedFiles.length === 1 ? '' : 's'}.`);
47
+ logger === null || logger === void 0 ? void 0 : logger.info(`${copyMessage} file${copiedFiles.length === 1 ? '' : 's'}.`);
43
48
  })().catch(error => {
44
49
  console.error(error);
45
50
  process.exit(1);
package/lib/utils.d.ts CHANGED
@@ -5,6 +5,30 @@ export declare function copyAsync(source: string, destination: string): Promise<
5
5
  export declare function downloadFileAsync(url: string, baseDir: string): Promise<void>;
6
6
  export declare function extractAsync(zipFile: string, destination: string): Promise<void>;
7
7
  export declare const isFile: (path: string) => boolean;
8
- export declare const rimrafAsync: (arg1: string) => Promise<void>;
8
+ export declare const rimrafAsync: ((path: string | string[], opt?: import("rimraf").RimrafAsyncOptions | undefined) => Promise<boolean>) & {
9
+ rimraf: (path: string | string[], opt?: import("rimraf").RimrafAsyncOptions | undefined) => Promise<boolean>;
10
+ sync: (path: string | string[], opt?: import("rimraf").RimrafSyncOptions | undefined) => boolean;
11
+ rimrafSync: (path: string | string[], opt?: import("rimraf").RimrafSyncOptions | undefined) => boolean;
12
+ manual: ((path: string | string[], opt?: import("rimraf").RimrafAsyncOptions | undefined) => Promise<boolean>) & {
13
+ sync: (path: string | string[], opt?: import("rimraf").RimrafSyncOptions | undefined) => boolean;
14
+ };
15
+ manualSync: (path: string | string[], opt?: import("rimraf").RimrafSyncOptions | undefined) => boolean;
16
+ native: ((path: string | string[], opt?: import("rimraf").RimrafAsyncOptions | undefined) => Promise<boolean>) & {
17
+ sync: (path: string | string[], opt?: import("rimraf").RimrafSyncOptions | undefined) => boolean;
18
+ };
19
+ nativeSync: (path: string | string[], opt?: import("rimraf").RimrafSyncOptions | undefined) => boolean;
20
+ posix: ((path: string | string[], opt?: import("rimraf").RimrafAsyncOptions | undefined) => Promise<boolean>) & {
21
+ sync: (path: string | string[], opt?: import("rimraf").RimrafSyncOptions | undefined) => boolean;
22
+ };
23
+ posixSync: (path: string | string[], opt?: import("rimraf").RimrafSyncOptions | undefined) => boolean;
24
+ windows: ((path: string | string[], opt?: import("rimraf").RimrafAsyncOptions | undefined) => Promise<boolean>) & {
25
+ sync: (path: string | string[], opt?: import("rimraf").RimrafSyncOptions | undefined) => boolean;
26
+ };
27
+ windowsSync: (path: string | string[], opt?: import("rimraf").RimrafSyncOptions | undefined) => boolean;
28
+ moveRemove: ((path: string | string[], opt?: import("rimraf").RimrafAsyncOptions | undefined) => Promise<boolean>) & {
29
+ sync: (path: string | string[], opt?: import("rimraf").RimrafSyncOptions | undefined) => boolean;
30
+ };
31
+ moveRemoveSync: (path: string | string[], opt?: import("rimraf").RimrafSyncOptions | undefined) => boolean;
32
+ };
9
33
  export declare const execAsync: typeof exec.__promisify__;
10
34
  //# sourceMappingURL=utils.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../src/utils.ts"],"names":[],"mappings":";AAwBA,OAAO,IAAI,MAAM,OAAO,CAAC;AAEzB,OAAO,EAAC,IAAI,EAAC,MAAM,eAAe,CAAC;AAInC,wBAAsB,SAAS,CAAC,MAAM,EAAE,MAAM,EAAE,WAAW,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,EAAE,CAAC,CAUpF;AAED,wBAAsB,iBAAiB,CAAC,GAAG,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAoBnF;AAED,wBAAsB,YAAY,CAAC,OAAO,EAAE,MAAM,EAAE,WAAW,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAsBtF;AAED,eAAO,MAAM,MAAM,SAAU,MAAM,YAAgC,CAAC;AACpE,eAAO,MAAM,WAAW,iCAAoB,CAAC;AAC7C,eAAO,MAAM,SAAS,2BAAkB,CAAC"}
1
+ {"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../src/utils.ts"],"names":[],"mappings":";AAwBA,OAAO,IAAI,MAAM,OAAO,CAAC;AAEzB,OAAO,EAAC,IAAI,EAAC,MAAM,eAAe,CAAC;AAInC,wBAAsB,SAAS,CAAC,MAAM,EAAE,MAAM,EAAE,WAAW,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,EAAE,CAAC,CAUpF;AAED,wBAAsB,iBAAiB,CAAC,GAAG,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAoBnF;AAED,wBAAsB,YAAY,CAAC,OAAO,EAAE,MAAM,EAAE,WAAW,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAsBtF;AAED,eAAO,MAAM,MAAM,SAAU,MAAM,YAA0B,CAAC;AAC9D,eAAO,MAAM,WAAW;;;;;;;;;;;;;;;;;;;;;;;;CAAS,CAAC;AAClC,eAAO,MAAM,SAAS,2BAAkB,CAAC"}
package/lib/utils.js CHANGED
@@ -26,7 +26,7 @@ const axios_1 = __importDefault(require("axios"));
26
26
  const copy_1 = __importDefault(require("copy"));
27
27
  const fs_extra_1 = require("fs-extra");
28
28
  const jszip_1 = __importDefault(require("jszip"));
29
- const rimraf_1 = __importDefault(require("rimraf"));
29
+ const rimraf_1 = require("rimraf");
30
30
  const child_process_1 = require("child_process");
31
31
  const path_1 = __importDefault(require("path"));
32
32
  const util_1 = require("util");
@@ -79,7 +79,7 @@ async function extractAsync(zipFile, destination) {
79
79
  }));
80
80
  }
81
81
  exports.extractAsync = extractAsync;
82
- const isFile = (path) => /[^.\/\\]+\..+$/.test(path);
82
+ const isFile = (path) => /\w\.\w+$/.test(path);
83
83
  exports.isFile = isFile;
84
- exports.rimrafAsync = (0, util_1.promisify)(rimraf_1.default);
84
+ exports.rimrafAsync = rimraf_1.rimraf;
85
85
  exports.execAsync = (0, util_1.promisify)(child_process_1.exec);
package/package.json CHANGED
@@ -35,6 +35,6 @@
35
35
  "test": "jest",
36
36
  "test:coverage": "jest --coverage"
37
37
  },
38
- "version": "2.2.3-hotfix-1.2",
39
- "gitHead": "ed9fc82dffbcf03fe6ac1ec613b24a4330df26f4"
38
+ "version": "2.2.3-hotfix-1.3",
39
+ "gitHead": "a5ea2d935c4495276c7d6e97bae17c776c9286be"
40
40
  }