@rvoh/dream 0.30.0 → 0.30.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.
- package/dist/cjs/src/bin/index.js +26 -11
- package/dist/cjs/src/cli/index.js +28 -0
- package/dist/cjs/src/cli/logger/DreamCliLogger.js +57 -0
- package/dist/cjs/src/cli/logger/helpers/createSpinner.js +14 -0
- package/dist/cjs/src/cli/logger/loggable/DreamCliLoggable.js +22 -0
- package/dist/cjs/src/cli/logger/loggable/DreamCliLoggableSpinner.js +31 -0
- package/dist/cjs/src/cli/logger/loggable/DreamCliLoggableText.js +21 -0
- package/dist/cjs/src/cli/logger/loggable/colorize.js +8 -0
- package/dist/cjs/src/cli/logger/loggable/spinners.js +1185 -0
- package/dist/cjs/src/decorators/Decorators.js +2 -2
- package/dist/cjs/src/helpers/db/runMigration.js +8 -3
- package/dist/esm/src/bin/index.js +24 -9
- package/dist/esm/src/cli/index.js +28 -0
- package/dist/esm/src/cli/logger/DreamCliLogger.js +54 -0
- package/dist/esm/src/cli/logger/helpers/createSpinner.js +11 -0
- package/dist/esm/src/cli/logger/loggable/DreamCliLoggable.js +19 -0
- package/dist/esm/src/cli/logger/loggable/DreamCliLoggableSpinner.js +28 -0
- package/dist/esm/src/cli/logger/loggable/DreamCliLoggableText.js +18 -0
- package/dist/esm/src/cli/logger/loggable/colorize.js +5 -0
- package/dist/esm/src/cli/logger/loggable/spinners.js +1183 -0
- package/dist/esm/src/decorators/Decorators.js +2 -2
- package/dist/esm/src/helpers/db/runMigration.js +8 -3
- package/dist/types/src/cli/index.d.ts +5 -0
- package/dist/types/src/cli/logger/DreamCliLogger.d.ts +22 -0
- package/dist/types/src/cli/logger/helpers/createSpinner.d.ts +2 -0
- package/dist/types/src/cli/logger/loggable/DreamCliLoggable.d.ts +15 -0
- package/dist/types/src/cli/logger/loggable/DreamCliLoggableSpinner.d.ts +21 -0
- package/dist/types/src/cli/logger/loggable/DreamCliLoggableText.d.ts +16 -0
- package/dist/types/src/cli/logger/loggable/colorize.d.ts +5 -0
- package/dist/types/src/cli/logger/loggable/spinners.d.ts +355 -0
- package/dist/types/src/decorators/Decorators.d.ts +2 -1
- package/docs/assets/search.js +1 -1
- package/docs/classes/Benchmark.html +2 -2
- package/docs/classes/CalendarDate.html +2 -2
- package/docs/classes/CreateOrFindByFailedToCreateAndFind.html +3 -3
- package/docs/classes/Decorators.html +20 -20
- package/docs/classes/Dream.html +126 -126
- package/docs/classes/DreamApplication.html +4 -4
- package/docs/classes/DreamBin.html +2 -2
- package/docs/classes/DreamCLI.html +6 -4
- package/docs/classes/DreamDbConnection.html +2 -2
- package/docs/classes/DreamImporter.html +2 -2
- package/docs/classes/DreamMigrationHelpers.html +7 -7
- package/docs/classes/DreamSerializer.html +2 -2
- package/docs/classes/DreamTransaction.html +2 -2
- package/docs/classes/Encrypt.html +2 -2
- package/docs/classes/Env.html +2 -2
- package/docs/classes/GlobalNameNotSet.html +3 -3
- package/docs/classes/NonLoadedAssociation.html +3 -3
- package/docs/classes/Query.html +50 -50
- package/docs/classes/Range.html +2 -2
- package/docs/classes/RecordNotFound.html +3 -3
- package/docs/classes/ValidationError.html +3 -3
- package/docs/functions/Attribute.html +1 -1
- package/docs/functions/RendersMany.html +1 -1
- package/docs/functions/RendersOne.html +1 -1
- package/docs/functions/ReplicaSafe.html +1 -1
- package/docs/functions/STI.html +1 -1
- package/docs/functions/SoftDelete.html +1 -1
- package/docs/functions/camelize.html +1 -1
- package/docs/functions/capitalize.html +1 -1
- package/docs/functions/closeAllDbConnections.html +1 -1
- package/docs/functions/compact.html +1 -1
- package/docs/functions/db.html +1 -1
- package/docs/functions/debug.html +1 -1
- package/docs/functions/dreamDbConnections.html +1 -1
- package/docs/functions/dreamPath.html +1 -1
- package/docs/functions/generateDream.html +1 -1
- package/docs/functions/globalClassNameFromFullyQualifiedModelName.html +1 -1
- package/docs/functions/hyphenize.html +1 -1
- package/docs/functions/inferSerializerFromDreamClassOrViewModelClass.html +1 -1
- package/docs/functions/inferSerializerFromDreamOrViewModel.html +1 -1
- package/docs/functions/isEmpty.html +1 -1
- package/docs/functions/loadRepl.html +1 -1
- package/docs/functions/lookupClassByGlobalName.html +1 -1
- package/docs/functions/pascalize.html +1 -1
- package/docs/functions/pgErrorType.html +1 -1
- package/docs/functions/range-1.html +1 -1
- package/docs/functions/relativeDreamPath.html +1 -1
- package/docs/functions/round.html +1 -1
- package/docs/functions/serializerNameFromFullyQualifiedModelName.html +1 -1
- package/docs/functions/sharedPathPrefix.html +1 -1
- package/docs/functions/snakeify.html +1 -1
- package/docs/functions/sortBy.html +1 -1
- package/docs/functions/standardizeFullyQualifiedModelName.html +1 -1
- package/docs/functions/uncapitalize.html +1 -1
- package/docs/functions/uniq.html +1 -1
- package/docs/functions/validateColumn.html +1 -1
- package/docs/functions/validateTable.html +1 -1
- package/docs/interfaces/AttributeStatement.html +2 -2
- package/docs/interfaces/DecoratorContext.html +2 -2
- package/docs/interfaces/DreamApplicationInitOptions.html +2 -2
- package/docs/interfaces/DreamApplicationOpts.html +2 -2
- package/docs/interfaces/DreamSerializerAssociationStatement.html +2 -2
- package/docs/interfaces/EncryptOptions.html +2 -2
- package/docs/interfaces/OpenapiSchemaProperties.html +1 -1
- package/docs/interfaces/OpenapiSchemaPropertiesShorthand.html +1 -1
- package/docs/interfaces/OpenapiTypeFieldObject.html +1 -1
- package/docs/types/Camelized.html +1 -1
- package/docs/types/CommonOpenapiSchemaObjectFields.html +1 -1
- package/docs/types/DreamAssociationMetadata.html +1 -1
- package/docs/types/DreamAttributes.html +1 -1
- package/docs/types/DreamClassColumn.html +1 -1
- package/docs/types/DreamColumn.html +1 -1
- package/docs/types/DreamColumnNames.html +1 -1
- package/docs/types/DreamLogLevel.html +1 -1
- package/docs/types/DreamLogger.html +1 -1
- package/docs/types/DreamOrViewModelSerializerKey.html +1 -1
- package/docs/types/DreamParamSafeAttributes.html +1 -1
- package/docs/types/DreamParamSafeColumnNames.html +1 -1
- package/docs/types/DreamSerializerKey.html +1 -1
- package/docs/types/DreamSerializers.html +1 -1
- package/docs/types/DreamTableSchema.html +1 -1
- package/docs/types/DreamVirtualColumns.html +1 -1
- package/docs/types/EncryptAlgorithm.html +1 -1
- package/docs/types/Hyphenized.html +1 -1
- package/docs/types/IdType.html +1 -1
- package/docs/types/OpenapiAllTypes.html +1 -1
- package/docs/types/OpenapiFormats.html +1 -1
- package/docs/types/OpenapiNumberFormats.html +1 -1
- package/docs/types/OpenapiPrimitiveTypes.html +1 -1
- package/docs/types/OpenapiSchemaArray.html +1 -1
- package/docs/types/OpenapiSchemaArrayShorthand.html +1 -1
- package/docs/types/OpenapiSchemaBase.html +1 -1
- package/docs/types/OpenapiSchemaBody.html +1 -1
- package/docs/types/OpenapiSchemaBodyShorthand.html +1 -1
- package/docs/types/OpenapiSchemaCommonFields.html +1 -1
- package/docs/types/OpenapiSchemaExpressionAllOf.html +1 -1
- package/docs/types/OpenapiSchemaExpressionAnyOf.html +1 -1
- package/docs/types/OpenapiSchemaExpressionOneOf.html +1 -1
- package/docs/types/OpenapiSchemaExpressionRef.html +1 -1
- package/docs/types/OpenapiSchemaExpressionRefSchemaShorthand.html +1 -1
- package/docs/types/OpenapiSchemaInteger.html +1 -1
- package/docs/types/OpenapiSchemaNull.html +1 -1
- package/docs/types/OpenapiSchemaNumber.html +1 -1
- package/docs/types/OpenapiSchemaObject.html +1 -1
- package/docs/types/OpenapiSchemaObjectAllOf.html +1 -1
- package/docs/types/OpenapiSchemaObjectAllOfShorthand.html +1 -1
- package/docs/types/OpenapiSchemaObjectAnyOf.html +1 -1
- package/docs/types/OpenapiSchemaObjectAnyOfShorthand.html +1 -1
- package/docs/types/OpenapiSchemaObjectBase.html +1 -1
- package/docs/types/OpenapiSchemaObjectBaseShorthand.html +1 -1
- package/docs/types/OpenapiSchemaObjectOneOf.html +1 -1
- package/docs/types/OpenapiSchemaObjectOneOfShorthand.html +1 -1
- package/docs/types/OpenapiSchemaObjectShorthand.html +1 -1
- package/docs/types/OpenapiSchemaPartialSegment.html +1 -1
- package/docs/types/OpenapiSchemaPrimitiveGeneric.html +1 -1
- package/docs/types/OpenapiSchemaShorthandExpressionAllOf.html +1 -1
- package/docs/types/OpenapiSchemaShorthandExpressionAnyOf.html +1 -1
- package/docs/types/OpenapiSchemaShorthandExpressionOneOf.html +1 -1
- package/docs/types/OpenapiSchemaShorthandExpressionSerializableRef.html +1 -1
- package/docs/types/OpenapiSchemaShorthandExpressionSerializerRef.html +1 -1
- package/docs/types/OpenapiSchemaShorthandPrimitiveGeneric.html +1 -1
- package/docs/types/OpenapiSchemaString.html +1 -1
- package/docs/types/OpenapiShorthandAllTypes.html +1 -1
- package/docs/types/OpenapiShorthandPrimitiveTypes.html +1 -1
- package/docs/types/OpenapiTypeField.html +1 -1
- package/docs/types/Pascalized.html +1 -1
- package/docs/types/PrimaryKeyType.html +1 -1
- package/docs/types/RoundingPrecision.html +1 -1
- package/docs/types/SerializableClassOrSerializerCallback.html +1 -1
- package/docs/types/SerializableDreamClassOrViewModelClass.html +1 -1
- package/docs/types/SerializableDreamOrViewModel.html +1 -1
- package/docs/types/SerializableTypes.html +1 -1
- package/docs/types/Snakeified.html +1 -1
- package/docs/types/Timestamp.html +1 -1
- package/docs/types/UpdateableAssociationProperties.html +1 -1
- package/docs/types/UpdateableProperties.html +1 -1
- package/docs/types/ValidationType.html +1 -1
- package/docs/types/ViewModelSerializerKey.html +1 -1
- package/docs/types/WhereStatementForDream.html +1 -1
- package/docs/types/WhereStatementForDreamClass.html +1 -1
- package/docs/variables/DreamConst.html +1 -1
- package/docs/variables/TRIGRAM_OPERATORS.html +1 -1
- package/docs/variables/openapiPrimitiveTypes-1.html +1 -1
- package/docs/variables/openapiShorthandPrimitiveTypes-1.html +1 -1
- package/docs/variables/ops.html +1 -1
- package/docs/variables/primaryKeyTypes.html +1 -1
- package/package.json +3 -2
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const index_js_1 = require("../cli/index.js");
|
|
3
4
|
const ConnectionConfRetriever_js_1 = require("../db/ConnectionConfRetriever.js");
|
|
4
|
-
const
|
|
5
|
+
const index_js_2 = require("../dream-application/index.js");
|
|
5
6
|
const SchemaBuilder_js_1 = require("../helpers/cli/SchemaBuilder.js");
|
|
6
7
|
const generateDream_js_1 = require("../helpers/cli/generateDream.js");
|
|
7
8
|
const generateMigration_js_1 = require("../helpers/cli/generateMigration.js");
|
|
@@ -19,14 +20,14 @@ class DreamBin {
|
|
|
19
20
|
await onSync();
|
|
20
21
|
}
|
|
21
22
|
static async buildDreamSchema() {
|
|
22
|
-
|
|
23
|
+
const spinner = index_js_1.default.logger.log('writing dream schema...', { spinner: true });
|
|
23
24
|
await new SchemaBuilder_js_1.default().build();
|
|
24
|
-
|
|
25
|
+
spinner.stop();
|
|
25
26
|
}
|
|
26
27
|
static async dbCreate() {
|
|
27
28
|
const connectionRetriever = new ConnectionConfRetriever_js_1.default();
|
|
28
29
|
const primaryDbConf = connectionRetriever.getConnectionConf('primary');
|
|
29
|
-
|
|
30
|
+
const spinner = index_js_1.default.logger.log(`creating ${primaryDbConf.name}...`, { spinner: true });
|
|
30
31
|
await (0, createDb_js_1.default)('primary');
|
|
31
32
|
// TODO: add support for creating replicas. Began doing it below, but it is very tricky,
|
|
32
33
|
// and we don't need it at the moment, so kicking off for future development when we have more time
|
|
@@ -36,12 +37,12 @@ class DreamBin {
|
|
|
36
37
|
// console.log(`creating ${process.env[replicaDbConf.name]}`)
|
|
37
38
|
// await createDb('replica')
|
|
38
39
|
// }
|
|
39
|
-
|
|
40
|
+
spinner.stop();
|
|
40
41
|
}
|
|
41
42
|
static async dbDrop() {
|
|
42
43
|
const connectionRetriever = new ConnectionConfRetriever_js_1.default();
|
|
43
44
|
const primaryDbConf = connectionRetriever.getConnectionConf('primary');
|
|
44
|
-
|
|
45
|
+
const spinner = index_js_1.default.logger.log(`dropping ${primaryDbConf.name}...`, { spinner: true });
|
|
45
46
|
await (0, dropDb_js_1.default)('primary');
|
|
46
47
|
// TODO: add support for dropping replicas. Began doing it below, but it is very tricky,
|
|
47
48
|
// and we don't need it at the moment, so kicking off for future development when we have more time
|
|
@@ -51,19 +52,27 @@ class DreamBin {
|
|
|
51
52
|
// console.log(`dropping ${process.env[replicaDbConf.name]}`)
|
|
52
53
|
// await _dropDb('replica')
|
|
53
54
|
// }
|
|
54
|
-
|
|
55
|
+
spinner.stop();
|
|
55
56
|
}
|
|
56
57
|
static async dbMigrate() {
|
|
58
|
+
const connectionRetriever = new ConnectionConfRetriever_js_1.default();
|
|
59
|
+
const primaryDbConf = connectionRetriever.getConnectionConf('primary');
|
|
60
|
+
const spinner = index_js_1.default.logger.log(`migrating ${primaryDbConf.name}...`, { spinner: true });
|
|
57
61
|
await (0, runMigration_js_1.default)({ mode: 'migrate' });
|
|
58
62
|
await this.duplicateDatabase();
|
|
63
|
+
spinner.stop();
|
|
59
64
|
}
|
|
60
65
|
static async dbRollback(opts) {
|
|
66
|
+
const connectionRetriever = new ConnectionConfRetriever_js_1.default();
|
|
67
|
+
const primaryDbConf = connectionRetriever.getConnectionConf('primary');
|
|
68
|
+
const spinner = index_js_1.default.logger.log(`rolling back ${primaryDbConf.name}...`, { spinner: true });
|
|
61
69
|
let step = opts.steps;
|
|
62
70
|
while (step > 0) {
|
|
63
71
|
await (0, runMigration_js_1.default)({ mode: 'rollback' });
|
|
64
72
|
step -= 1;
|
|
65
73
|
}
|
|
66
74
|
await this.duplicateDatabase();
|
|
75
|
+
spinner.stop();
|
|
67
76
|
}
|
|
68
77
|
static async generateDream(fullyQualifiedModelName, columnsWithTypes, options) {
|
|
69
78
|
await (0, generateDream_js_1.default)({ fullyQualifiedModelName, columnsWithTypes, options });
|
|
@@ -78,12 +87,11 @@ class DreamBin {
|
|
|
78
87
|
// It is only made private so that people don't mistakenly try
|
|
79
88
|
// to use it to generate docs for their apps.
|
|
80
89
|
static async buildDocs() {
|
|
81
|
-
|
|
90
|
+
index_js_1.default.logger.log('generating docs...');
|
|
82
91
|
await (0, sspawn_js_1.default)('yarn typedoc src/index.ts --tsconfig ./tsconfig.esm.build.json --out docs');
|
|
83
|
-
console.log('done!');
|
|
84
92
|
}
|
|
85
93
|
static async duplicateDatabase() {
|
|
86
|
-
const parallelTests =
|
|
94
|
+
const parallelTests = index_js_2.default.getOrFail().parallelTests;
|
|
87
95
|
if (!parallelTests)
|
|
88
96
|
return;
|
|
89
97
|
const connectionRetriever = new ConnectionConfRetriever_js_1.default();
|
|
@@ -91,15 +99,22 @@ class DreamBin {
|
|
|
91
99
|
const client = await (0, loadPgClient_js_1.default)({ useSystemDb: true });
|
|
92
100
|
if (process.env.DREAM_CORE_DEVELOPMENT === '1') {
|
|
93
101
|
const replicaTestWorkerDatabaseName = `replica_test_${dbConf.name}`;
|
|
94
|
-
|
|
102
|
+
const spinner = index_js_1.default.logger.log(`creating fake replica test database ${replicaTestWorkerDatabaseName}...`, {
|
|
103
|
+
spinner: true,
|
|
104
|
+
});
|
|
95
105
|
await client.query(`DROP DATABASE IF EXISTS ${replicaTestWorkerDatabaseName};`);
|
|
96
106
|
await client.query(`CREATE DATABASE ${replicaTestWorkerDatabaseName} TEMPLATE ${dbConf.name};`);
|
|
107
|
+
spinner.stop();
|
|
97
108
|
}
|
|
98
109
|
for (let i = 2; i <= parallelTests; i++) {
|
|
99
110
|
const workerDatabaseName = `${dbConf.name}_${i}`;
|
|
100
111
|
console.log(`creating duplicate test database ${workerDatabaseName} for concurrent tests`);
|
|
112
|
+
const spinner = index_js_1.default.logger.log(`creating duplicate test database ${workerDatabaseName} for concurrent tests...`, {
|
|
113
|
+
spinner: true,
|
|
114
|
+
});
|
|
101
115
|
await client.query(`DROP DATABASE IF EXISTS ${workerDatabaseName};`);
|
|
102
116
|
await client.query(`CREATE DATABASE ${workerDatabaseName} TEMPLATE ${dbConf.name};`);
|
|
117
|
+
spinner.stop();
|
|
103
118
|
}
|
|
104
119
|
await client.end();
|
|
105
120
|
}
|
|
@@ -1,8 +1,10 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const child_process_1 = require("child_process");
|
|
3
4
|
const commander_1 = require("commander");
|
|
4
5
|
const index_js_1 = require("../bin/index.js");
|
|
5
6
|
const EnvInternal_js_1 = require("../helpers/EnvInternal.js");
|
|
7
|
+
const DreamCliLogger_js_1 = require("./logger/DreamCliLogger.js");
|
|
6
8
|
class DreamCLI {
|
|
7
9
|
/**
|
|
8
10
|
* use this method for initializing a standalone dream application. If using Psychic and Dream together,
|
|
@@ -144,6 +146,32 @@ class DreamCLI {
|
|
|
144
146
|
process.exit();
|
|
145
147
|
});
|
|
146
148
|
}
|
|
149
|
+
/*
|
|
150
|
+
* the default spawn provided by node:child_process is incompatible
|
|
151
|
+
* with promises. this will automatically wrap the spawn method,
|
|
152
|
+
* and will by default connect STDOUT to the current STDOUT,
|
|
153
|
+
* so that whatever the command is outputting is output to the
|
|
154
|
+
* primary STDOUT context.
|
|
155
|
+
*/
|
|
156
|
+
static async spawn(command, opts) {
|
|
157
|
+
return new Promise((accept, reject) => {
|
|
158
|
+
const spawnInstance = (0, child_process_1.spawn)(command, {
|
|
159
|
+
stdio: 'inherit',
|
|
160
|
+
shell: true,
|
|
161
|
+
...(opts || {}),
|
|
162
|
+
});
|
|
163
|
+
spawnInstance.on('close', code => {
|
|
164
|
+
if (code !== 0)
|
|
165
|
+
reject(new Error(code?.toString()));
|
|
166
|
+
accept({});
|
|
167
|
+
});
|
|
168
|
+
});
|
|
169
|
+
}
|
|
170
|
+
static get logger() {
|
|
171
|
+
this._logger ||= new DreamCliLogger_js_1.default();
|
|
172
|
+
return this._logger;
|
|
173
|
+
}
|
|
174
|
+
static _logger = undefined;
|
|
147
175
|
}
|
|
148
176
|
exports.default = DreamCLI;
|
|
149
177
|
function myParseInt(value) {
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const DreamCliLoggableSpinner_js_1 = require("./loggable/DreamCliLoggableSpinner.js");
|
|
4
|
+
const DreamCliLoggableText_js_1 = require("./loggable/DreamCliLoggableText.js");
|
|
5
|
+
class DreamCliLogger {
|
|
6
|
+
logs = [];
|
|
7
|
+
log(text, { permanent = false, spinner = false, logPrefix, logPrefixColor, logPrefixBgColor, spinnerPrefixColor = 'greenBright', spinnerPrefixBgColor, } = {}) {
|
|
8
|
+
const loggable = spinner
|
|
9
|
+
? new DreamCliLoggableSpinner_js_1.default({
|
|
10
|
+
text,
|
|
11
|
+
permanent: false,
|
|
12
|
+
spinner: 'noise',
|
|
13
|
+
color: spinnerPrefixColor,
|
|
14
|
+
bgColor: spinnerPrefixBgColor,
|
|
15
|
+
})
|
|
16
|
+
: new DreamCliLoggableText_js_1.default(text, {
|
|
17
|
+
permanent,
|
|
18
|
+
logPrefix,
|
|
19
|
+
logPrefixColor: logPrefixColor || (permanent ? 'green' : 'yellow'),
|
|
20
|
+
logPrefixBgColor,
|
|
21
|
+
});
|
|
22
|
+
this.logs.push(loggable);
|
|
23
|
+
// re-render everything
|
|
24
|
+
this.render();
|
|
25
|
+
return loggable;
|
|
26
|
+
}
|
|
27
|
+
render() {
|
|
28
|
+
this.clear();
|
|
29
|
+
let skipNext = false;
|
|
30
|
+
this.logs.forEach(loggable => {
|
|
31
|
+
if (skipNext) {
|
|
32
|
+
skipNext = false;
|
|
33
|
+
return;
|
|
34
|
+
}
|
|
35
|
+
loggable.render();
|
|
36
|
+
});
|
|
37
|
+
}
|
|
38
|
+
get spinners() {
|
|
39
|
+
return this.logs.filter(log => log instanceof DreamCliLoggableSpinner_js_1.default);
|
|
40
|
+
}
|
|
41
|
+
/*
|
|
42
|
+
* remove all logs that are not marked permanent,
|
|
43
|
+
* then clear STDOUT and re-render with only
|
|
44
|
+
* the permanent logs remaining.
|
|
45
|
+
*/
|
|
46
|
+
purge() {
|
|
47
|
+
this.logs = this.logs.filter(log => log.permanent);
|
|
48
|
+
this.render();
|
|
49
|
+
}
|
|
50
|
+
clear() {
|
|
51
|
+
console.clear();
|
|
52
|
+
// @ts-expect-error this works fine with no args provided
|
|
53
|
+
process.stdout.clearLine?.();
|
|
54
|
+
process.stdout.cursorTo?.(0);
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
exports.default = DreamCliLogger;
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.default = createSpinner;
|
|
4
|
+
const yocto_spinner_1 = require("yocto-spinner");
|
|
5
|
+
const spinners_js_1 = require("../loggable/spinners.js");
|
|
6
|
+
function createSpinner(text, spinnerKey = 'noise') {
|
|
7
|
+
return (0, yocto_spinner_1.default)({
|
|
8
|
+
text,
|
|
9
|
+
spinner: {
|
|
10
|
+
interval: spinners_js_1.default[spinnerKey].interval,
|
|
11
|
+
frames: [...spinners_js_1.default[spinnerKey].frames],
|
|
12
|
+
},
|
|
13
|
+
}).start();
|
|
14
|
+
}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const colorize_js_1 = require("./colorize.js");
|
|
4
|
+
class DreamCliLoggable {
|
|
5
|
+
permanent;
|
|
6
|
+
logPrefix;
|
|
7
|
+
logPrefixColor;
|
|
8
|
+
logPrefixBgColor;
|
|
9
|
+
constructor({ permanent, logPrefix = '✺', logPrefixColor, logPrefixBgColor, }) {
|
|
10
|
+
this.permanent = permanent;
|
|
11
|
+
this.logPrefix = logPrefix;
|
|
12
|
+
this.logPrefixColor = logPrefixColor;
|
|
13
|
+
this.logPrefixBgColor = logPrefixBgColor;
|
|
14
|
+
}
|
|
15
|
+
render() {
|
|
16
|
+
throw new Error('define in base class');
|
|
17
|
+
}
|
|
18
|
+
get colorizedLogPrefix() {
|
|
19
|
+
return (0, colorize_js_1.default)(this.logPrefix, { color: this.logPrefixColor, bgColor: this.logPrefixBgColor });
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
exports.default = DreamCliLoggable;
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const createSpinner_js_1 = require("../helpers/createSpinner.js");
|
|
4
|
+
const DreamCliLoggable_js_1 = require("./DreamCliLoggable.js");
|
|
5
|
+
const index_js_1 = require("../../index.js");
|
|
6
|
+
class DreamCliLoggableSpinner extends DreamCliLoggable_js_1.default {
|
|
7
|
+
text;
|
|
8
|
+
spinner;
|
|
9
|
+
currentIndex = 0;
|
|
10
|
+
color;
|
|
11
|
+
bgColor;
|
|
12
|
+
lastRender;
|
|
13
|
+
_spinner;
|
|
14
|
+
constructor({ text, permanent, spinner, color, bgColor, }) {
|
|
15
|
+
super({ permanent });
|
|
16
|
+
this.text = text;
|
|
17
|
+
this.spinner = spinner;
|
|
18
|
+
this.color = color;
|
|
19
|
+
this.bgColor = bgColor;
|
|
20
|
+
}
|
|
21
|
+
render() {
|
|
22
|
+
this._spinner?.stop();
|
|
23
|
+
this._spinner = (0, createSpinner_js_1.default)(this.text, this.spinner);
|
|
24
|
+
}
|
|
25
|
+
stop(message = this.text + ' done!') {
|
|
26
|
+
this._spinner.stop();
|
|
27
|
+
index_js_1.default.logger.purge();
|
|
28
|
+
index_js_1.default.logger.log(message, { permanent: true });
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
exports.default = DreamCliLoggableSpinner;
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const colorize_js_1 = require("./colorize.js");
|
|
4
|
+
const DreamCliLoggable_js_1 = require("./DreamCliLoggable.js");
|
|
5
|
+
class DreamCliLoggableText extends DreamCliLoggable_js_1.default {
|
|
6
|
+
text;
|
|
7
|
+
color;
|
|
8
|
+
bgColor;
|
|
9
|
+
constructor(text, { permanent, logPrefix, color, bgColor, logPrefixColor, logPrefixBgColor, }) {
|
|
10
|
+
super({ permanent, logPrefix });
|
|
11
|
+
this.text = text;
|
|
12
|
+
this.color = color;
|
|
13
|
+
this.bgColor = bgColor;
|
|
14
|
+
this.logPrefixColor = logPrefixColor;
|
|
15
|
+
this.logPrefixBgColor = logPrefixBgColor;
|
|
16
|
+
}
|
|
17
|
+
render() {
|
|
18
|
+
console.log(`${this.colorizedLogPrefix} ${(0, colorize_js_1.default)(this.text, { color: this.color, bgColor: this.bgColor })}`);
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
exports.default = DreamCliLoggableText;
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.default = colorize;
|
|
4
|
+
const yoctocolors_1 = require("yoctocolors");
|
|
5
|
+
function colorize(text, { color, bgColor }) {
|
|
6
|
+
const foregroundApplied = color ? yoctocolors_1.default[color](text) : text;
|
|
7
|
+
return bgColor ? yoctocolors_1.default[bgColor](foregroundApplied) : foregroundApplied;
|
|
8
|
+
}
|