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

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.
@@ -1,12 +1,11 @@
1
- import logdown from 'logdown';
2
1
  import { CopyConfigOptions } from './CopyConfigOptions';
3
2
  export declare class CopyConfig {
4
- private readonly logger?;
5
3
  private readonly options;
4
+ private readonly logger;
6
5
  private readonly noClone;
7
6
  private readonly noCleanup;
8
7
  private readonly filterFiles;
9
- constructor(options: CopyConfigOptions | undefined, logger?: logdown.Logger | undefined);
8
+ constructor(options: CopyConfigOptions);
10
9
  private readEnvVars;
11
10
  private getFilesFromString;
12
11
  private resolveFiles;
@@ -1 +1 @@
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"}
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"}
package/lib/CopyConfig.js CHANGED
@@ -46,19 +46,18 @@ 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"));
49
50
  const path_1 = __importDefault(require("path"));
50
51
  const utils = __importStar(require("./utils"));
51
52
  const defaultOptions = {
52
53
  baseDir: 'config',
53
54
  externalDir: '',
54
55
  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, logger) {
61
- this.logger = logger;
60
+ constructor(options) {
62
61
  this.noClone = false;
63
62
  this.noCleanup = false;
64
63
  this.filterFiles = ['.DS_Store'];
@@ -73,6 +72,10 @@ class CopyConfig {
73
72
  this.options.baseDir = this.options.externalDir;
74
73
  }
75
74
  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;
76
79
  }
77
80
  readEnvVars() {
78
81
  const externalDir = process.env.WIRE_CONFIGURATION_EXTERNAL_DIR;
@@ -118,7 +121,6 @@ class CopyConfig {
118
121
  });
119
122
  }
120
123
  async copyDirOrFile(source, destination) {
121
- var _a, _b, _c;
122
124
  const filter = (src) => {
123
125
  for (const fileName in this.filterFiles) {
124
126
  if (src.endsWith(fileName)) {
@@ -132,26 +134,24 @@ class CopyConfig {
132
134
  throw new Error('Cannot copy a directory into a file.');
133
135
  }
134
136
  if (isGlob(source)) {
135
- (_a = this.logger) === null || _a === void 0 ? void 0 : _a.info(`Resolving "${source}"`);
137
+ this.logger.info(`Resolving "${source}"`);
136
138
  const copiedFiles = await utils.copyAsync(source, destination);
137
139
  for (const copiedFile of copiedFiles) {
138
140
  const [copiedFrom, copiedTo] = copiedFile.history;
139
- (_b = this.logger) === null || _b === void 0 ? void 0 : _b.debug(`Copying "${copiedFrom}" -> "${copiedTo}"`);
141
+ this.logger.info(`Copying "${copiedFrom}" -> "${copiedTo}"`);
140
142
  }
141
143
  return copiedFiles.map(file => file.path);
142
144
  }
143
145
  if (utils.isFile(source) && !utils.isFile(destination)) {
144
146
  destination = path_1.default.join(destination, path_1.default.basename(source));
145
147
  }
146
- (_c = this.logger) === null || _c === void 0 ? void 0 : _c.debug(`Copying "${source}" -> "${destination}"`);
148
+ this.logger.info(`Copying "${source}" -> "${destination}"`);
147
149
  // Info: "fs.copy" creates all sub-folders which are needed along the way:
148
150
  // see https://github.com/jprichardson/node-fs-extra/blob/7.0.1/lib/copy/copy.js#L43
149
- // by default, fs.copy() copies folders recursively
150
- await fs.copy(source, destination, { filter, overwrite: true });
151
+ await fs.copy(source, destination, { filter, overwrite: true, recursive: true });
151
152
  return [destination];
152
153
  }
153
154
  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
- (_a = this.logger) === null || _a === void 0 ? void 0 : _a.error(`No git installation found: (error: "${stderrVersion}"). Trying to download the zip file ...`);
163
+ this.logger.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
- (_b = this.logger) === null || _b === void 0 ? void 0 : _b.info(`Downloading "${url}" ...`);
171
+ this.logger.info(`Downloading "${url}" ...`);
172
172
  await utils.downloadFileAsync(url, this.options.baseDir);
173
173
  }
174
174
  else {
175
- (_c = this.logger) === null || _c === void 0 ? void 0 : _c.info(`Cloning "${bareUrl}" (branch "${branch}") ...`);
175
+ this.logger.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,8 +181,7 @@ class CopyConfig {
181
181
  }
182
182
  }
183
183
  async removeBasedir() {
184
- var _a;
185
- (_a = this.logger) === null || _a === void 0 ? void 0 : _a.debug(`Cleaning up "${this.options.baseDir}" ...`);
184
+ this.logger.info(`Cleaning up "${this.options.baseDir}" ...`);
186
185
  await utils.rimrafAsync(this.options.baseDir);
187
186
  }
188
187
  async copy() {
@@ -33,6 +33,5 @@ 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';
37
36
  }
38
37
  //# 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;IACtB,QAAQ,CAAC,EAAE,SAAS,GAAG,MAAM,GAAG,QAAQ,CAAC;CAC1C"}
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"}
package/lib/cli.js CHANGED
@@ -26,25 +26,20 @@ 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;
29
34
  (async () => {
30
- const configExplorer = (0, cosmiconfig_1.cosmiconfig)('copyconfig');
31
35
  const configFile = await configExplorer.search();
32
- const config = configFile ? configFile.config : undefined;
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
- }
36
+ if (configFile) {
37
+ logger.info(`Found configuration file "${configFile.filepath}".`);
44
38
  }
45
- const copiedFiles = await new _1.CopyConfig(config, logger).copy();
39
+ const config = configFile ? configFile.config : undefined;
40
+ const copiedFiles = await new _1.CopyConfig(config).copy();
46
41
  const copyMessage = copiedFiles.length ? `Copied ${copiedFiles.length}` : "Didn't copy any";
47
- logger === null || logger === void 0 ? void 0 : logger.info(`${copyMessage} file${copiedFiles.length === 1 ? '' : 's'}.`);
42
+ logger.info(`${copyMessage} file${copiedFiles.length === 1 ? '' : 's'}.`);
48
43
  })().catch(error => {
49
44
  console.error(error);
50
45
  process.exit(1);
package/lib/utils.d.ts CHANGED
@@ -5,30 +5,6 @@ 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: ((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
- };
8
+ export declare const rimrafAsync: (arg1: string) => Promise<void>;
33
9
  export declare const execAsync: typeof exec.__promisify__;
34
10
  //# 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,YAA0B,CAAC;AAC9D,eAAO,MAAM,WAAW;;;;;;;;;;;;;;;;;;;;;;;;CAAS,CAAC;AAClC,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,YAAgC,CAAC;AACpE,eAAO,MAAM,WAAW,iCAAoB,CAAC;AAC7C,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 = require("rimraf");
29
+ const rimraf_1 = __importDefault(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) => /\w\.\w+$/.test(path);
82
+ const isFile = (path) => /[^.\/\\]+\..+$/.test(path);
83
83
  exports.isFile = isFile;
84
- exports.rimrafAsync = rimraf_1.rimraf;
84
+ exports.rimrafAsync = (0, util_1.promisify)(rimraf_1.default);
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.2",
39
- "gitHead": "a106d98232b52392791c21fc90591bcb24347216"
38
+ "version": "2.2.3-hotfix-1.2",
39
+ "gitHead": "ed9fc82dffbcf03fe6ac1ec613b24a4330df26f4"
40
40
  }