@appium/docutils 0.3.3 → 0.3.5
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/build/lib/builder/deploy.d.ts.map +1 -1
- package/build/lib/builder/deploy.js +4 -3
- package/build/lib/builder/deploy.js.map +1 -1
- package/build/lib/builder/nav.js +2 -2
- package/build/lib/builder/nav.js.map +1 -1
- package/build/lib/builder/reference.js +2 -2
- package/build/lib/builder/reference.js.map +1 -1
- package/build/lib/builder/site.d.ts.map +1 -1
- package/build/lib/builder/site.js +4 -3
- package/build/lib/builder/site.js.map +1 -1
- package/build/lib/cli/check.js +2 -2
- package/build/lib/cli/check.js.map +1 -1
- package/build/lib/cli/command/build.d.ts.map +1 -1
- package/build/lib/cli/command/build.js +3 -2
- package/build/lib/cli/command/build.js.map +1 -1
- package/build/lib/cli/command/init.js +2 -2
- package/build/lib/cli/command/init.js.map +1 -1
- package/build/lib/cli/command/validate.js +2 -5
- package/build/lib/cli/command/validate.js.map +1 -1
- package/build/lib/cli/config.d.ts.map +1 -1
- package/build/lib/cli/config.js +15 -4
- package/build/lib/cli/config.js.map +1 -1
- package/build/lib/cli/index.d.ts.map +1 -1
- package/build/lib/cli/index.js +10 -22
- package/build/lib/cli/index.js.map +1 -1
- package/build/lib/fs.js +2 -2
- package/build/lib/fs.js.map +1 -1
- package/build/lib/index.d.ts +1 -0
- package/build/lib/index.d.ts.map +1 -1
- package/build/lib/index.js +1 -0
- package/build/lib/index.js.map +1 -1
- package/build/lib/init.js +3 -3
- package/build/lib/init.js.map +1 -1
- package/build/lib/logger.d.ts +12 -6
- package/build/lib/logger.d.ts.map +1 -1
- package/build/lib/logger.js +47 -43
- package/build/lib/logger.js.map +1 -1
- package/build/lib/scaffold.js +3 -3
- package/build/lib/scaffold.js.map +1 -1
- package/build/lib/validate.js +2 -2
- package/build/lib/validate.js.map +1 -1
- package/lib/builder/deploy.ts +4 -3
- package/lib/builder/nav.ts +2 -2
- package/lib/builder/reference.ts +2 -2
- package/lib/builder/site.ts +5 -5
- package/lib/cli/check.ts +2 -2
- package/lib/cli/command/build.ts +3 -2
- package/lib/cli/command/init.ts +2 -2
- package/lib/cli/command/validate.ts +2 -2
- package/lib/cli/config.ts +17 -5
- package/lib/cli/index.ts +8 -19
- package/lib/fs.ts +2 -2
- package/lib/index.ts +1 -0
- package/lib/init.ts +3 -3
- package/lib/logger.ts +46 -45
- package/lib/scaffold.ts +3 -3
- package/lib/validate.ts +2 -2
- package/package.json +6 -6
- package/requirements.txt +1 -1
package/lib/logger.ts
CHANGED
|
@@ -136,58 +136,59 @@ class DocutilsReporter extends FancyReporter {
|
|
|
136
136
|
*/
|
|
137
137
|
let globalLevel: LogLevel = LogLevelMap[DEFAULT_LOG_LEVEL];
|
|
138
138
|
|
|
139
|
+
/**
|
|
140
|
+
* Type guard to see if a string is a recognized log level
|
|
141
|
+
* @param level any value
|
|
142
|
+
*/
|
|
143
|
+
export function isLogLevelString(level: any): level is keyof typeof LogLevelMap {
|
|
144
|
+
return level in LogLevelMap;
|
|
145
|
+
}
|
|
146
|
+
|
|
139
147
|
/**
|
|
140
148
|
* The logger from which all loggers are created. This one uses a unique tag and our custom reporter.
|
|
141
149
|
*/
|
|
142
|
-
const rootLogger =
|
|
143
|
-
|
|
144
|
-
)
|
|
150
|
+
const rootLogger = consola.create({
|
|
151
|
+
defaults: {tag: 'docutils'},
|
|
152
|
+
reporters: [new DocutilsReporter()],
|
|
153
|
+
level: globalLevel,
|
|
154
|
+
});
|
|
155
|
+
// this prevents logging before `initLogger` is called
|
|
156
|
+
rootLogger.pause();
|
|
145
157
|
|
|
146
158
|
/**
|
|
147
|
-
*
|
|
148
|
-
* @description
|
|
149
|
-
* Alright. So when you create a new logger via {@linkcode Consola.create}, it's basically a clone
|
|
150
|
-
* of its parent with a new set of options.
|
|
151
|
-
*
|
|
152
|
-
* If we change the log level of the root logger (which we do: see `cli/index.ts`), we may (almost
|
|
153
|
-
* certainly) have
|
|
154
|
-
* child loggers which: a) have already been created and b) have inherited the old/default log level
|
|
155
|
-
* from the root logger. We don't _want_ that (though this is likely a reasonable use case) for our
|
|
156
|
-
* purposes.
|
|
157
|
-
*
|
|
158
|
-
* The implementation below solves the problem by maintaining its own singleton log level value, and
|
|
159
|
-
* intercepts the `level` property of any logger created from the root logger.
|
|
160
|
-
*
|
|
161
|
-
* There are other ways to go about this which may be better, but this seemed pretty straightforward.
|
|
159
|
+
* A map of tags to loggers
|
|
162
160
|
*/
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
}
|
|
177
|
-
return Reflect.get(target, prop, receiver);
|
|
178
|
-
},
|
|
179
|
-
set(target, prop, value, receiver) {
|
|
180
|
-
if (prop === 'level') {
|
|
181
|
-
globalLevel = value as LogLevel;
|
|
182
|
-
return true;
|
|
183
|
-
}
|
|
184
|
-
return Reflect.set(target, prop, value, receiver);
|
|
185
|
-
},
|
|
186
|
-
});
|
|
161
|
+
const loggers: Map<string, WeakRef<Consola>> = new Map();
|
|
162
|
+
|
|
163
|
+
export function getLogger(tag: string, parent = rootLogger) {
|
|
164
|
+
if (loggers.has(tag)) {
|
|
165
|
+
const logger = loggers.get(tag)?.deref();
|
|
166
|
+
if (logger) {
|
|
167
|
+
return logger;
|
|
168
|
+
}
|
|
169
|
+
}
|
|
170
|
+
const logger = parent.withTag(tag);
|
|
171
|
+
logger.level = globalLevel;
|
|
172
|
+
loggers.set(tag, new WeakRef(logger));
|
|
173
|
+
return logger;
|
|
187
174
|
}
|
|
188
175
|
|
|
189
176
|
/**
|
|
190
|
-
*
|
|
191
|
-
*
|
|
177
|
+
* Initialize the logging system.
|
|
178
|
+
*
|
|
179
|
+
* This should only be called once. The loglevel cannot be changed once it is set.
|
|
180
|
+
*
|
|
181
|
+
* @remarks Child loggers seem to inherit the "paused" state of the parent, so when this is called, we must resume all of them.
|
|
192
182
|
*/
|
|
193
|
-
export
|
|
183
|
+
export const initLogger = _.once((level: keyof typeof LogLevelMap | LogLevel) => {
|
|
184
|
+
globalLevel = isLogLevelString(level) ? LogLevelMap[level] : level;
|
|
185
|
+
rootLogger.level = globalLevel;
|
|
186
|
+
rootLogger.resume();
|
|
187
|
+
for (const ref of loggers.values()) {
|
|
188
|
+
const logger = ref.deref();
|
|
189
|
+
if (logger) {
|
|
190
|
+
logger.level = globalLevel;
|
|
191
|
+
logger.resume();
|
|
192
|
+
}
|
|
193
|
+
}
|
|
194
|
+
});
|
package/lib/scaffold.ts
CHANGED
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
*/
|
|
5
5
|
|
|
6
6
|
import {fs} from '@appium/support';
|
|
7
|
-
import
|
|
7
|
+
import {getLogger} from './logger';
|
|
8
8
|
import path from 'node:path';
|
|
9
9
|
import {createPatch} from 'diff';
|
|
10
10
|
import {NormalizedPackageJson} from 'read-pkg';
|
|
@@ -15,8 +15,8 @@ import _ from 'lodash';
|
|
|
15
15
|
import {stringifyJson, readPackageJson, safeWriteFile} from './fs';
|
|
16
16
|
import {NAME_ERR_ENOENT, NAME_ERR_EEXIST} from './constants';
|
|
17
17
|
|
|
18
|
-
const log =
|
|
19
|
-
const dryRunLog =
|
|
18
|
+
const log = getLogger('init');
|
|
19
|
+
const dryRunLog = getLogger('dry-run', log);
|
|
20
20
|
|
|
21
21
|
/**
|
|
22
22
|
* Creates a unified patch for display in "dry run" mode
|
package/lib/validate.ts
CHANGED
|
@@ -40,7 +40,7 @@ import {
|
|
|
40
40
|
whichPython,
|
|
41
41
|
readMkDocsYml,
|
|
42
42
|
} from './fs';
|
|
43
|
-
import
|
|
43
|
+
import {getLogger} from './logger';
|
|
44
44
|
import {MkDocsYml, PipPackage, TypeDocJson} from './model';
|
|
45
45
|
import {relative} from './util';
|
|
46
46
|
|
|
@@ -64,7 +64,7 @@ const TYPEDOC_VERSION_REGEX = /TypeDoc\s(\d+\.\d+\..+)/;
|
|
|
64
64
|
*/
|
|
65
65
|
const MKDOCS_VERSION_REGEX = /mkdocs,\s+version\s+(\d+\.\d+\.\S+)/;
|
|
66
66
|
|
|
67
|
-
const log =
|
|
67
|
+
const log = getLogger('validate');
|
|
68
68
|
|
|
69
69
|
/**
|
|
70
70
|
* The "kinds" of validation which were requested to be performed
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@appium/docutils",
|
|
3
|
-
"version": "0.3.
|
|
3
|
+
"version": "0.3.5",
|
|
4
4
|
"description": "Documentation generation utilities for Appium and related projects",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"automation",
|
|
@@ -49,9 +49,9 @@
|
|
|
49
49
|
"start": "node ./build/lib/cli/index.js"
|
|
50
50
|
},
|
|
51
51
|
"dependencies": {
|
|
52
|
-
"@appium/support": "^3.1.
|
|
53
|
-
"@appium/tsconfig": "^0.
|
|
54
|
-
"@appium/typedoc-plugin-appium": "^0.
|
|
52
|
+
"@appium/support": "^3.1.10",
|
|
53
|
+
"@appium/tsconfig": "^0.3.0",
|
|
54
|
+
"@appium/typedoc-plugin-appium": "^0.6.1",
|
|
55
55
|
"@sliphua/lilconfig-ts-loader": "3.2.2",
|
|
56
56
|
"chalk": "4.1.2",
|
|
57
57
|
"consola": "2.15.3",
|
|
@@ -67,7 +67,7 @@
|
|
|
67
67
|
"semver": "7.3.8",
|
|
68
68
|
"source-map-support": "0.5.21",
|
|
69
69
|
"teen_process": "2.0.2",
|
|
70
|
-
"type-fest": "3.
|
|
70
|
+
"type-fest": "3.8.0",
|
|
71
71
|
"typedoc": "0.23.28",
|
|
72
72
|
"typedoc-plugin-markdown": "3.14.0",
|
|
73
73
|
"typedoc-plugin-resolve-crossmodule-references": "0.3.3",
|
|
@@ -83,5 +83,5 @@
|
|
|
83
83
|
"publishConfig": {
|
|
84
84
|
"access": "public"
|
|
85
85
|
},
|
|
86
|
-
"gitHead": "
|
|
86
|
+
"gitHead": "e9b50225dc09a306b6eb8dafa0543c2a45cb8238"
|
|
87
87
|
}
|
package/requirements.txt
CHANGED