inray 0.0.5 → 0.0.6
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/LICENSE.md +1 -0
- package/README.md +36 -30
- package/dist/cli/src/lib/command.js +8 -8
- package/dist/cli/src/lib/option.js +6 -6
- package/dist/db/postgres/src/bytes.js +1 -0
- package/dist/db/postgres/src/connection.js +1 -0
- package/dist/db/postgres/src/errors.js +1 -0
- package/dist/db/postgres/src/index.js +1 -0
- package/dist/db/postgres/src/large.js +1 -0
- package/dist/db/postgres/src/query.js +1 -0
- package/dist/db/postgres/src/queue.js +1 -0
- package/dist/db/postgres/src/result.js +1 -0
- package/dist/db/postgres/src/subscribe.js +1 -0
- package/dist/db/postgres/src/types.js +1 -0
- package/dist/db-migrator/src/bin.d.ts +3 -0
- package/dist/db-migrator/src/bin.d.ts.map +1 -0
- package/dist/db-migrator/src/bin.js +72 -0
- package/dist/db-migrator/src/bin.js.map +1 -0
- package/dist/db-migrator/src/index.d.ts +5 -0
- package/dist/db-migrator/src/index.d.ts.map +1 -0
- package/dist/db-migrator/src/index.js +4 -0
- package/dist/db-migrator/src/index.js.map +1 -0
- package/dist/db-migrator/src/lib/MigrationError.d.ts +5 -0
- package/dist/db-migrator/src/lib/MigrationError.d.ts.map +1 -0
- package/dist/db-migrator/src/lib/MigrationError.js +12 -0
- package/dist/db-migrator/src/lib/MigrationError.js.map +1 -0
- package/dist/db-migrator/src/lib/clients/index.d.ts +9 -0
- package/dist/db-migrator/src/lib/clients/index.d.ts.map +1 -0
- package/dist/db-migrator/src/lib/clients/index.js +10 -0
- package/dist/db-migrator/src/lib/clients/index.js.map +1 -0
- package/dist/db-migrator/src/lib/clients/postgres.d.ts +3 -0
- package/dist/db-migrator/src/lib/clients/postgres.d.ts.map +1 -0
- package/dist/db-migrator/src/lib/clients/postgres.js +44 -0
- package/dist/db-migrator/src/lib/clients/postgres.js.map +1 -0
- package/dist/db-migrator/src/lib/migrator.log.d.ts +4 -0
- package/dist/db-migrator/src/lib/migrator.log.d.ts.map +1 -0
- package/dist/db-migrator/src/lib/migrator.log.js +46 -0
- package/dist/db-migrator/src/lib/migrator.log.js.map +1 -0
- package/dist/db-migrator/src/lib/migrator.sql.d.ts +5 -0
- package/dist/db-migrator/src/lib/migrator.sql.d.ts.map +1 -0
- package/dist/db-migrator/src/lib/migrator.sql.js +13 -0
- package/dist/db-migrator/src/lib/migrator.sql.js.map +1 -0
- package/dist/db-migrator/src/lib/migrator.types.d.ts +55 -0
- package/dist/db-migrator/src/lib/migrator.types.d.ts.map +1 -0
- package/dist/db-migrator/src/lib/migrator.types.js +2 -0
- package/dist/db-migrator/src/lib/migrator.types.js.map +1 -0
- package/dist/db-migrator/src/lib/util.d.ts +9 -0
- package/dist/db-migrator/src/lib/util.d.ts.map +1 -0
- package/dist/db-migrator/src/lib/util.js +93 -0
- package/dist/db-migrator/src/lib/util.js.map +1 -0
- package/dist/db-migrator/src/migrator.d.ts +6 -0
- package/dist/db-migrator/src/migrator.d.ts.map +1 -0
- package/dist/db-migrator/src/migrator.js +121 -0
- package/dist/db-migrator/src/migrator.js.map +1 -0
- package/dist/utils/mkdirs.d.ts +15 -0
- package/dist/utils/mkdirs.d.ts.map +1 -0
- package/dist/utils/mkdirs.js +42 -0
- package/dist/utils/mkdirs.js.map +1 -0
- package/dist/utils/mod.d.ts +2 -0
- package/dist/utils/mod.d.ts.map +1 -1
- package/dist/utils/mod.js +2 -0
- package/dist/utils/mod.js.map +1 -1
- package/dist/utils/totalist.d.ts +13 -0
- package/dist/utils/totalist.d.ts.map +1 -0
- package/dist/utils/totalist.js +39 -0
- package/dist/utils/totalist.js.map +1 -0
- package/package.json +10 -3
package/LICENSE.md
CHANGED
|
@@ -46,6 +46,7 @@ Additional Functionality and integrated external libraries:
|
|
|
46
46
|
| [@hono/node-server](https://github.com/honojs/node-server) | [Yusuke Wada](https://github.com/yusukebe) | [MIT](./src/hono/node-server/LICENSE.md) | **2.1.1** | Zero or low | same |
|
|
47
47
|
| [cache-manager](https://cacheable.org/docs/cache-manager/) and parts: keyv, @keyv/serialize, @cacheable/utils, hashery, hookified | [Jared Wray](https://github.com/jaredwray) | [MIT](<./src/caching/LICENSE%20(cache-manager%20and%20parts).md>) | **7.2.9** | Average | caching |
|
|
48
48
|
| [commander.js](https://github.com/tj/commander.js) | [TJ Holowaychuk](https://github.com/tj)<br> [John Gee](https://github.com/shadowspawn) | [MIT](./src/cli/LICENSE.md) | **15.0.0** | Average | cli |
|
|
49
|
+
| [ley](https://github.com/lukeed/ley) and parts: <br> mk-dirs, totalist | [Luke Edwards](https://github.com/lukeed) | [MIT](./src/db/migrator/LICENSE.md) | **0.8.1** | High | db-migrator |
|
|
49
50
|
|
|
50
51
|
\* - integrated version of library
|
|
51
52
|
|
package/README.md
CHANGED
|
@@ -84,6 +84,7 @@ Inray - all-in-one инструментарий для разработки **No
|
|
|
84
84
|
| Задачи по расписанию | /node-cron | <span style="color:green">II</span> | [node-cron](https://www.nodecron.com/) | |
|
|
85
85
|
| Валидация | /valibot | <span style="color:green">II</span> | [valibot (и его части)](https://valibot.dev/) | |
|
|
86
86
|
| Драйверы к базам данных | /db/postgres | <span style="color:red">I</span> | [postgres.js](https://github.com/porsager/postgres/tree/master) | |
|
|
87
|
+
| CLI средство для миграций БД | /db-migrator | <span style="color:blue">III</span> | [ley](https://github.com/lukeed/ley) | |
|
|
87
88
|
| Криптографические функции | /jose | <span style="color:green">II</span> | [jose](https://github.com/panva/jose) | |
|
|
88
89
|
| Работа с телефонными номерами | /phonenumbers | <span style="color:blue">III</span> | [libphonenumber-js](https://gitlab.com/catamphetamine/libphonenumber-js) | |
|
|
89
90
|
| Основной серверный фреймворк | /hono | <span style="color:green">II</span> | [hono](https://hono.dev/docs/) | |
|
|
@@ -95,7 +96,6 @@ Inray - all-in-one инструментарий для разработки **No
|
|
|
95
96
|
|
|
96
97
|
🚧⚠️🛠️ ROADMAP дальнейших интеграций 🚧⚠️🛠️:
|
|
97
98
|
|
|
98
|
-
- мигратор (для различных драйверов БД) 🛠️...
|
|
99
99
|
- iconv (работа с кодировками) 🛠️...
|
|
100
100
|
- tedious (драйвер для работы с MS SQL Server) 🛠️...
|
|
101
101
|
- redis/valkey (кеширование) 🛠️...
|
|
@@ -135,6 +135,10 @@ In progress 🛠️...
|
|
|
135
135
|
|
|
136
136
|
In progress 🛠️...
|
|
137
137
|
|
|
138
|
+
### inray/cli - CLI приложения
|
|
139
|
+
|
|
140
|
+
In progress 🛠️...
|
|
141
|
+
|
|
138
142
|
### inray/collections - коллекции и вспомогательные функции для работы с итерируемыми объектами
|
|
139
143
|
|
|
140
144
|
In progress 🛠️...
|
|
@@ -151,7 +155,7 @@ In progress 🛠️...
|
|
|
151
155
|
|
|
152
156
|
In progress 🛠️...
|
|
153
157
|
|
|
154
|
-
### inray/db, inray/db/postgres - работа с БД
|
|
158
|
+
### inray/db, inray/db/postgres, inray/db-migrator - работа с БД
|
|
155
159
|
|
|
156
160
|
In progress 🛠️...
|
|
157
161
|
|
|
@@ -243,34 +247,35 @@ PERFORMANCE OF THIS SOFTWARE.
|
|
|
243
247
|
|
|
244
248
|
Integrated and modified external libraries:
|
|
245
249
|
|
|
246
|
-
| Library name | Author |
|
|
247
|
-
| :---------------------------------------------------------------------------------------------------------------------------------------- | :------------------------------------------------------------------------------------- |
|
|
248
|
-
| [valibot](https://valibot.dev/) | [Fabian Hiller](https://github.com/fabian-hiller) |
|
|
249
|
-
| [@valibot/i18n](https://github.com/open-circle/valibot/tree/main/packages/i18n) | [Fabian Hiller](https://github.com/fabian-hiller) |
|
|
250
|
-
| [@valibot/to-json-schema](https://github.com/open-circle/valibot/tree/main/packages/to-json-schema) | [Fabian Hiller](https://github.com/fabian-hiller) |
|
|
251
|
-
| [node-cron](https://www.nodecron.com/) | [Lucas Merencia](https://github.com/merencia) |
|
|
252
|
-
| [yaml](https://eemeli.org/yaml/#yaml) | [Eemeli Aro](https://github.com/eemeli) |
|
|
253
|
-
| [@std/async](https://jsr.io/@std/async) | [Deno authors](https://github.com/denoland) |
|
|
254
|
-
| [@std/bytes](https://jsr.io/@std/bytes) | [Deno authors](https://github.com/denoland) |
|
|
255
|
-
| [@std/collections](https://jsr.io/@std/collections) | [Deno authors](https://github.com/denoland) |
|
|
256
|
-
| [@std/csv](https://jsr.io/@std/csv) | [Deno authors](https://github.com/denoland) |
|
|
257
|
-
| [@std/data-structures](https://jsr.io/@std/data-structures) | [Deno authors](https://github.com/denoland) |
|
|
258
|
-
| [@std/encoding](https://jsr.io/@std/encoding) | [Deno authors](https://github.com/denoland) |
|
|
259
|
-
| [@std/fmt](https://jsr.io/@std/fmt) | [Deno authors](https://github.com/denoland) |
|
|
260
|
-
| [@std/json](https://jsr.io/@std/json) | [Deno authors](https://github.com/denoland) |
|
|
261
|
-
| [@std/jsonc](https://jsr.io/@std/jsonc) | [Deno authors](https://github.com/denoland) |
|
|
262
|
-
| [@std/media-types](https://jsr.io/@std/media-types) | [Deno authors](https://github.com/denoland) |
|
|
263
|
-
| [@std/streams](https://jsr.io/@std/streams) | [Deno authors](https://github.com/denoland) |
|
|
264
|
-
| [jose](https://github.com/panva/jose) | [Filip Skokan](https://github.com/panva) |
|
|
265
|
-
| [date-fns](https://date-fns.org/) | [Sasha Koss](https://github.com/kossnocorp) |
|
|
266
|
-
| [unidecode](https://github.com/FGRibreau/node-unidecode) | [Francois-Guillaume Ribreau](https://fgribreau.com) |
|
|
267
|
-
| [libphonenumber-js](https://gitlab.com/catamphetamine/libphonenumber-js) | [Nikolay Kuchumov](https://gitlab.com/catamphetamine) |
|
|
268
|
-
| [logtape](https://logtape.org/) and parts: <br> @logtape/config, @logtape/file, <br> @logtape/pretty, @logtape/redaction, @logtape/syslog | [Hong Minhee (洪 民憙)](https://github.com/dahlia) |
|
|
269
|
-
| [postgres.js](https://github.com/porsager/postgres/tree/master) | [Rasmus Porsager](https://github.com/porsager) |
|
|
270
|
-
| [hono](https://hono.dev/) | [Yusuke Wada](https://github.com/yusukebe) |
|
|
271
|
-
| [@hono/node-server](https://github.com/honojs/node-server) | [Yusuke Wada](https://github.com/yusukebe) |
|
|
272
|
-
| [cache-manager](https://cacheable.org/docs/cache-manager/) and parts: keyv, @keyv/serialize, @cacheable/utils, hashery, hookified | [Jared Wray](https://github.com/jaredwray) |
|
|
273
|
-
| [commander.js](https://github.com/tj/commander.js) | [TJ Holowaychuk](https://github.com/tj)<br> [John Gee](https://github.com/shadowspawn) |
|
|
250
|
+
| Library name | Author | License | Version\* | Modification level\*\* | Internal name\*\*\* |
|
|
251
|
+
| :---------------------------------------------------------------------------------------------------------------------------------------- | :------------------------------------------------------------------------------------- | :---------: | :--------------- | ---------------------- | ------------------- |
|
|
252
|
+
| [valibot](https://valibot.dev/) | [Fabian Hiller](https://github.com/fabian-hiller) | MIT | **1.4.2** | Zero or low | same |
|
|
253
|
+
| [@valibot/i18n](https://github.com/open-circle/valibot/tree/main/packages/i18n) | [Fabian Hiller](https://github.com/fabian-hiller) | MIT | **1.2.0** | Zero or low | same |
|
|
254
|
+
| [@valibot/to-json-schema](https://github.com/open-circle/valibot/tree/main/packages/to-json-schema) | [Fabian Hiller](https://github.com/fabian-hiller) | MIT | **1.7.1** | Zero | same |
|
|
255
|
+
| [node-cron](https://www.nodecron.com/) | [Lucas Merencia](https://github.com/merencia) | ISC | **4.6.0** | Zero or low | same |
|
|
256
|
+
| [yaml](https://eemeli.org/yaml/#yaml) | [Eemeli Aro](https://github.com/eemeli) | ISC | **3.0.0-1 (RC)** | Zero or low | same |
|
|
257
|
+
| [@std/async](https://jsr.io/@std/async) | [Deno authors](https://github.com/denoland) | MIT | **1.5.0** | Zero or low | same as domain |
|
|
258
|
+
| [@std/bytes](https://jsr.io/@std/bytes) | [Deno authors](https://github.com/denoland) | MIT | **1.0.6** | Zero or low | same as domain |
|
|
259
|
+
| [@std/collections](https://jsr.io/@std/collections) | [Deno authors](https://github.com/denoland) | MIT | **1.3.0** | Zero or low | same as domain |
|
|
260
|
+
| [@std/csv](https://jsr.io/@std/csv) | [Deno authors](https://github.com/denoland) | MIT | **1.0.6** | Low | same as domain |
|
|
261
|
+
| [@std/data-structures](https://jsr.io/@std/data-structures) | [Deno authors](https://github.com/denoland) | MIT | **1.1.1** | Zero or low | same as domain |
|
|
262
|
+
| [@std/encoding](https://jsr.io/@std/encoding) | [Deno authors](https://github.com/denoland) | MIT | **1.0.11** | Low | same as domain |
|
|
263
|
+
| [@std/fmt](https://jsr.io/@std/fmt) | [Deno authors](https://github.com/denoland) | MIT | **1.0.10** | Low | same as domain |
|
|
264
|
+
| [@std/json](https://jsr.io/@std/json) | [Deno authors](https://github.com/denoland) | MIT | **1.1.0** | Low | same as domain |
|
|
265
|
+
| [@std/jsonc](https://jsr.io/@std/jsonc) | [Deno authors](https://github.com/denoland) | MIT | **1.0.2** | Zero or low | same as domain |
|
|
266
|
+
| [@std/media-types](https://jsr.io/@std/media-types) | [Deno authors](https://github.com/denoland) | MIT | **1.1.0** | Zero or low | same as domain |
|
|
267
|
+
| [@std/streams](https://jsr.io/@std/streams) | [Deno authors](https://github.com/denoland) | MIT | **1.1.1** | Low | same as domain |
|
|
268
|
+
| [jose](https://github.com/panva/jose) | [Filip Skokan](https://github.com/panva) | MIT | **6.2.8** | Zero or low | same |
|
|
269
|
+
| [date-fns](https://date-fns.org/) | [Sasha Koss](https://github.com/kossnocorp) | MIT | **4.4.0** | Zero or low | same |
|
|
270
|
+
| [unidecode](https://github.com/FGRibreau/node-unidecode) | [Francois-Guillaume Ribreau](https://fgribreau.com) | BSD | **1.1.0** | Average | same |
|
|
271
|
+
| [libphonenumber-js](https://gitlab.com/catamphetamine/libphonenumber-js) | [Nikolay Kuchumov](https://gitlab.com/catamphetamine) | MIT, Apache | **1.13.11** | High | phonenumbers |
|
|
272
|
+
| [logtape](https://logtape.org/) and parts: <br> @logtape/config, @logtape/file, <br> @logtape/pretty, @logtape/redaction, @logtape/syslog | [Hong Minhee (洪 民憙)](https://github.com/dahlia) | MIT | **2.3.2** | Zero or low | same |
|
|
273
|
+
| [postgres.js](https://github.com/porsager/postgres/tree/master) | [Rasmus Porsager](https://github.com/porsager) | UNLICENSE | **3.4.9** | Zero | same |
|
|
274
|
+
| [hono](https://hono.dev/) | [Yusuke Wada](https://github.com/yusukebe) | MIT | **4.13.5** | Low | same |
|
|
275
|
+
| [@hono/node-server](https://github.com/honojs/node-server) | [Yusuke Wada](https://github.com/yusukebe) | MIT | **2.1.1** | Zero or low | same |
|
|
276
|
+
| [cache-manager](https://cacheable.org/docs/cache-manager/) and parts: keyv, @keyv/serialize, @cacheable/utils, hashery, hookified | [Jared Wray](https://github.com/jaredwray) | MIT | **7.2.9** | Average | caching |
|
|
277
|
+
| [commander.js](https://github.com/tj/commander.js) | [TJ Holowaychuk](https://github.com/tj)<br> [John Gee](https://github.com/shadowspawn) | MIT | **15.0.0** | Average | cli |
|
|
278
|
+
| [ley](https://github.com/lukeed/ley) and parts: <br> mk-dirs, totalist | [Luke Edwards](https://github.com/lukeed) | MIT | **0.8.1** | High | db-migrator |
|
|
274
279
|
|
|
275
280
|
\* - integrated version of library
|
|
276
281
|
|
|
@@ -323,3 +328,4 @@ However, sometimes integrated libraries change their original name for one or mo
|
|
|
323
328
|
- [Jared Wray](https://github.com/jaredwray)
|
|
324
329
|
- [TJ Holowaychuk](https://github.com/tj)
|
|
325
330
|
- [John Gee](https://github.com/shadowspawn)
|
|
331
|
+
- [Luke Edwards](https://github.com/lukeed)
|
|
@@ -264,7 +264,7 @@ export class Command extends EventEmitter {
|
|
|
264
264
|
*/
|
|
265
265
|
addCommand(cmd, opts) {
|
|
266
266
|
if (!cmd._name) {
|
|
267
|
-
throw new Error(`Command passed to .addCommand() must have a name
|
|
267
|
+
throw new Error(`Command passed to .addCommand() must have a name
|
|
268
268
|
- specify the name in Command constructor or using .name()`);
|
|
269
269
|
}
|
|
270
270
|
opts = opts || {};
|
|
@@ -415,7 +415,7 @@ export class Command extends EventEmitter {
|
|
|
415
415
|
hook(event, listener) {
|
|
416
416
|
const allowedValues = ['preSubcommand', 'preAction', 'postAction'];
|
|
417
417
|
if (!allowedValues.includes(event)) {
|
|
418
|
-
throw new Error(`Unexpected value for event passed to hook : '${event}'.
|
|
418
|
+
throw new Error(`Unexpected value for event passed to hook : '${event}'.
|
|
419
419
|
Expecting one of '${allowedValues.join("', '")}'`);
|
|
420
420
|
}
|
|
421
421
|
if (this._lifeCycleHooks[event]) {
|
|
@@ -540,7 +540,7 @@ Expecting one of '${allowedValues.join("', '")}'`);
|
|
|
540
540
|
const matchingOption = (option.short && this._findOption(option.short)) || (option.long && this._findOption(option.long));
|
|
541
541
|
if (matchingOption) {
|
|
542
542
|
const matchingFlag = option.long && this._findOption(option.long) ? option.long : option.short;
|
|
543
|
-
throw new Error(`Cannot add option '${option.flags}'${this._name && ` to command '${this._name}'`} due to conflicting flag '${matchingFlag}'
|
|
543
|
+
throw new Error(`Cannot add option '${option.flags}'${this._name && ` to command '${this._name}'`} due to conflicting flag '${matchingFlag}'
|
|
544
544
|
- already used by option '${matchingOption.flags}'`);
|
|
545
545
|
}
|
|
546
546
|
this._initOptionGroup(option);
|
|
@@ -963,7 +963,7 @@ Expecting one of '${allowedValues.join("', '")}'`);
|
|
|
963
963
|
*/
|
|
964
964
|
restoreStateBeforeParse() {
|
|
965
965
|
if (this._storeOptionsAsProperties)
|
|
966
|
-
throw new Error(`Can not call parse again when storeOptionsAsProperties is true.
|
|
966
|
+
throw new Error(`Can not call parse again when storeOptionsAsProperties is true.
|
|
967
967
|
- either make a new Command for each call to parse, or stop storing options as properties`);
|
|
968
968
|
// clear state from _prepareUserArgs
|
|
969
969
|
this._name = this._savedState._name;
|
|
@@ -990,9 +990,9 @@ Expecting one of '${allowedValues.join("', '")}'`);
|
|
|
990
990
|
const executableDirMessage = executableDir
|
|
991
991
|
? `searched for local subcommand relative to directory '${executableDir}'`
|
|
992
992
|
: 'no directory for search for local subcommand, use .executableDir() to supply a custom directory';
|
|
993
|
-
const executableMissing = `'${executableFile}' does not exist
|
|
994
|
-
- if '${subcommandName}' is not meant to be an executable command, remove description parameter from '.command()' and use '.description()' instead
|
|
995
|
-
- if the default executable name is not suitable, use the executableFile option to supply a custom name or path
|
|
993
|
+
const executableMissing = `'${executableFile}' does not exist
|
|
994
|
+
- if '${subcommandName}' is not meant to be an executable command, remove description parameter from '.command()' and use '.description()' instead
|
|
995
|
+
- if the default executable name is not suitable, use the executableFile option to supply a custom name or path
|
|
996
996
|
- ${executableDirMessage}`;
|
|
997
997
|
throw new Error(executableMissing);
|
|
998
998
|
}
|
|
@@ -2099,7 +2099,7 @@ Expecting one of '${allowedValues.join("', '")}'`);
|
|
|
2099
2099
|
addHelpText(position, text) {
|
|
2100
2100
|
const allowedValues = ['beforeAll', 'before', 'after', 'afterAll'];
|
|
2101
2101
|
if (!allowedValues.includes(position)) {
|
|
2102
|
-
throw new Error(`Unexpected value for position to addHelpText.
|
|
2102
|
+
throw new Error(`Unexpected value for position to addHelpText.
|
|
2103
2103
|
Expecting one of '${allowedValues.join("', '")}'`);
|
|
2104
2104
|
}
|
|
2105
2105
|
const helpEvent = `${position}Help`;
|
|
@@ -344,17 +344,17 @@ function splitOptionFlags(flags) {
|
|
|
344
344
|
const unsupportedFlag = flagParts[0];
|
|
345
345
|
const baseError = `option creation failed due to '${unsupportedFlag}' in option flags '${flags}'`;
|
|
346
346
|
if (/^-[^-][^-]/.test(unsupportedFlag))
|
|
347
|
-
throw new Error(`${baseError}
|
|
348
|
-
- a short flag is a single dash and a single character
|
|
349
|
-
- either use a single dash and a single character (for a short flag)
|
|
347
|
+
throw new Error(`${baseError}
|
|
348
|
+
- a short flag is a single dash and a single character
|
|
349
|
+
- either use a single dash and a single character (for a short flag)
|
|
350
350
|
- or use a double dash for a long option (and can have two, like '--ws, --workspace')`);
|
|
351
351
|
if (shortFlagExp.test(unsupportedFlag))
|
|
352
|
-
throw new Error(`${baseError}
|
|
352
|
+
throw new Error(`${baseError}
|
|
353
353
|
- too many short flags`);
|
|
354
354
|
if (longFlagExp.test(unsupportedFlag))
|
|
355
|
-
throw new Error(`${baseError}
|
|
355
|
+
throw new Error(`${baseError}
|
|
356
356
|
- too many long flags`);
|
|
357
|
-
throw new Error(`${baseError}
|
|
357
|
+
throw new Error(`${baseError}
|
|
358
358
|
- unrecognised flag format`);
|
|
359
359
|
}
|
|
360
360
|
if (shortFlag === undefined && longFlag === undefined)
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"bin.d.ts","sourceRoot":"","sources":["../../../src/db-migrator/src/bin.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
import { program } from "../../cli/mod.js";
|
|
3
|
+
import { toConfig } from "./lib/util.js";
|
|
4
|
+
import * as log from "./lib/migrator.log.js";
|
|
5
|
+
import { create, down, status, up } from "./migrator.js";
|
|
6
|
+
async function withConfig(opts) {
|
|
7
|
+
const path = typeof opts.config === 'string' ? opts.config : undefined;
|
|
8
|
+
const loaded = await toConfig(path, opts.cwd || '.');
|
|
9
|
+
if (loaded) {
|
|
10
|
+
log.info('Loading configuration');
|
|
11
|
+
return {
|
|
12
|
+
...opts,
|
|
13
|
+
config: await (typeof loaded === 'function' ? loaded() : loaded)
|
|
14
|
+
};
|
|
15
|
+
}
|
|
16
|
+
const { config: _unused, ...rest } = opts;
|
|
17
|
+
return rest;
|
|
18
|
+
}
|
|
19
|
+
function action(run) {
|
|
20
|
+
return async (...args) => {
|
|
21
|
+
const cmd = args.at(-1);
|
|
22
|
+
try {
|
|
23
|
+
const result = await run(await withConfig(cmd.optsWithGlobals()));
|
|
24
|
+
log.done(cmd.name(), result);
|
|
25
|
+
}
|
|
26
|
+
catch (err) {
|
|
27
|
+
log.bail(err);
|
|
28
|
+
}
|
|
29
|
+
};
|
|
30
|
+
}
|
|
31
|
+
program
|
|
32
|
+
.name('inray-migrator')
|
|
33
|
+
.version('0.0.0')
|
|
34
|
+
.option('-C, --cwd <dir>', 'The current directory to resolve from', '.')
|
|
35
|
+
.option('-d, --dir <dir>', 'The directory of migration files to run', 'migrations')
|
|
36
|
+
.option('-c, --config <path>', 'Path to config file', 'ley.config.js');
|
|
37
|
+
program
|
|
38
|
+
.command('up')
|
|
39
|
+
.description('Run "up" migration(s). Applies all outstanding items.')
|
|
40
|
+
.option('-s, --single', 'Only run a single migration')
|
|
41
|
+
.action(action((opts) => up(opts)));
|
|
42
|
+
program
|
|
43
|
+
.command('down')
|
|
44
|
+
.description('Run "down" migration(s). Defaults to one at a time.')
|
|
45
|
+
.option('-a, --all', 'Run all "down" migrations')
|
|
46
|
+
.action(action((opts) => down(opts)));
|
|
47
|
+
program
|
|
48
|
+
.command('status')
|
|
49
|
+
.description('Check for migration status. Counts unapplied migrations.')
|
|
50
|
+
.action(action((opts) => status(opts)));
|
|
51
|
+
program
|
|
52
|
+
.command('new')
|
|
53
|
+
.argument('<filename>', 'Migration name')
|
|
54
|
+
.description('Create a new migration file.')
|
|
55
|
+
.option('-t, --timestamp', 'Prefix the filename with a timestamp')
|
|
56
|
+
.option('-l, --length <n>', 'The length of prefix, if not timestamp', '5')
|
|
57
|
+
.action(async (filename, _opts, cmd) => {
|
|
58
|
+
try {
|
|
59
|
+
const opts = await withConfig(cmd.optsWithGlobals());
|
|
60
|
+
const result = await create({
|
|
61
|
+
...opts,
|
|
62
|
+
filename,
|
|
63
|
+
length: Number(opts.length ?? 5)
|
|
64
|
+
});
|
|
65
|
+
log.done('new', result);
|
|
66
|
+
}
|
|
67
|
+
catch (err) {
|
|
68
|
+
log.bail(err);
|
|
69
|
+
}
|
|
70
|
+
});
|
|
71
|
+
await program.parseAsync(process.argv);
|
|
72
|
+
//# sourceMappingURL=bin.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"bin.js","sourceRoot":"","sources":["../../../src/db-migrator/src/bin.ts"],"names":[],"mappings":";AACA,OAAO,EAAE,OAAO,EAAgB,MAAM,kBAAkB,CAAC;AAEzD,OAAO,E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ACH,MAAM,IAAI,GAAG,MAAM,UAAU,CAAC,GAAG,CAAC,eAAe,EAAE,CAAC,CAAC;QACrD,MAAM,MAAM,GAAG,MAAM,MAAM,CAAC;YAC1B,GAAG,IAAI;YACP,QAAQ;YACR,MAAM,EAAE,MAAM,CAAC,IAAI,CAAC,MAAM,IAAI,CAAC,CAAC;SACjC,CAAC,CAAC;QACH,GAAG,CAAC,IAAI,CAAC,KAAK,EAAE,MAAM,CAAC,CAAC;IAC1B,CAAC;IAAC,OAAO,GAAG,EAAE,CAAC;QACb,GAAG,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;IAChB,CAAC;AACH,CAAC,CAAC,CAAC;AAEL,MAAM,OAAO,CAAC,UAAU,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC"}
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
export type * from './lib/migrator.types.ts';
|
|
2
|
+
export { create, create as new, down, status, up } from './migrator.ts';
|
|
3
|
+
export { clients, postgresDriver } from './lib/clients/index.ts';
|
|
4
|
+
export { MigrationError } from './lib/MigrationError.ts';
|
|
5
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/db-migrator/src/index.ts"],"names":[],"mappings":"AAAA,mBAAmB,yBAAyB,CAAC;AAC7C,OAAO,EAAE,MAAM,EAAE,MAAM,IAAI,GAAG,EAAE,IAAI,EAAE,MAAM,EAAE,EAAE,EAAE,MAAM,eAAe,CAAC;AACxE,OAAO,EAAE,OAAO,EAAE,cAAc,EAAE,MAAM,wBAAwB,CAAC;AACjE,OAAO,EAAE,cAAc,EAAE,MAAM,yBAAyB,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/db-migrator/src/index.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,MAAM,EAAE,MAAM,IAAI,GAAG,EAAE,IAAI,EAAE,MAAM,EAAE,EAAE,EAAE,MAAM,eAAe,CAAC;AACxE,OAAO,EAAE,OAAO,EAAE,cAAc,EAAE,MAAM,wBAAwB,CAAC;AACjE,OAAO,EAAE,cAAc,EAAE,MAAM,yBAAyB,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"MigrationError.d.ts","sourceRoot":"","sources":["../../../../src/db-migrator/src/lib/MigrationError.ts"],"names":[],"mappings":"AAAA,qBAAa,cAAe,SAAQ,KAAK;IACvC,QAAQ,CAAC,SAAS,EAAE,MAAM,CAAC,MAAM,GAAG,KAAK,EAAE,MAAM,CAAC,CAAC;gBAEvC,GAAG,EAAE,KAAK,EAAE,IAAI,EAAE,MAAM,CAAC,MAAM,GAAG,KAAK,EAAE,MAAM,CAAC;CAQ7D"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
export class MigrationError extends Error {
|
|
2
|
+
migration;
|
|
3
|
+
constructor(err, file) {
|
|
4
|
+
super(err.message);
|
|
5
|
+
const details = err.stack?.replace(/^(.*?)(?:[\n\r])/, '') ?? '';
|
|
6
|
+
Error.captureStackTrace(this, MigrationError);
|
|
7
|
+
this.stack = `${this.stack ?? ''}\n${details}`;
|
|
8
|
+
Object.assign(this, err);
|
|
9
|
+
this.migration = file;
|
|
10
|
+
}
|
|
11
|
+
}
|
|
12
|
+
//# sourceMappingURL=MigrationError.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"MigrationError.js","sourceRoot":"","sources":["../../../../src/db-migrator/src/lib/MigrationError.ts"],"names":[],"mappings":"AAAA,MAAM,OAAO,cAAe,SAAQ,KAAK;IAC9B,SAAS,CAAiC;IAEnD,YAAY,GAAU,EAAE,IAAoC;QAC1D,KAAK,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC;QACnB,MAAM,OAAO,GAAG,GAAG,CAAC,KAAK,EAAE,OAAO,CAAC,kBAAkB,EAAE,EAAE,CAAC,IAAI,EAAE,CAAC;QACjE,KAAK,CAAC,iBAAiB,CAAC,IAAI,EAAE,cAAc,CAAC,CAAC;QAC9C,IAAI,CAAC,KAAK,GAAG,GAAG,IAAI,CAAC,KAAK,IAAI,EAAE,KAAK,OAAO,EAAE,CAAC;QAC/C,MAAM,CAAC,MAAM,CAAC,IAAI,EAAE,GAAG,CAAC,CAAC;QACzB,IAAI,CAAC,SAAS,GAAG,IAAI,CAAC;IACxB,CAAC;CACF"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import type { IMigrationDriver, MigratorAvailableDriver } from '../migrator.types.ts';
|
|
2
|
+
import { postgresDriver } from './postgres.ts';
|
|
3
|
+
export { postgresDriver };
|
|
4
|
+
/**
|
|
5
|
+
* Built-in drivers keyed by {@link MigratorAvailableDriver}.
|
|
6
|
+
* Add a new client file and one entry here when another engine is supported.
|
|
7
|
+
*/
|
|
8
|
+
export declare const clients: Record<MigratorAvailableDriver, IMigrationDriver>;
|
|
9
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../src/db-migrator/src/lib/clients/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,gBAAgB,EAAE,uBAAuB,EAAE,MAAM,sBAAsB,CAAC;AACtF,OAAO,EAAE,cAAc,EAAE,MAAM,eAAe,CAAC;AAE/C,OAAO,EAAE,cAAc,EAAE,CAAC;AAE1B;;;GAGG;AACH,eAAO,MAAM,OAAO,EAAE,MAAM,CAAC,uBAAuB,EAAE,gBAAgB,CAErE,CAAC"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { postgresDriver } from "./postgres.js";
|
|
2
|
+
export { postgresDriver };
|
|
3
|
+
/**
|
|
4
|
+
* Built-in drivers keyed by {@link MigratorAvailableDriver}.
|
|
5
|
+
* Add a new client file and one entry here when another engine is supported.
|
|
6
|
+
*/
|
|
7
|
+
export const clients = {
|
|
8
|
+
postgres: postgresDriver
|
|
9
|
+
};
|
|
10
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../src/db-migrator/src/lib/clients/index.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,cAAc,EAAE,MAAM,eAAe,CAAC;AAE/C,OAAO,EAAE,cAAc,EAAE,CAAC;AAE1B;;;GAGG;AACH,MAAM,CAAC,MAAM,OAAO,GAAsD;IACxE,QAAQ,EAAE,cAAc;CACzB,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"postgres.d.ts","sourceRoot":"","sources":["../../../../../src/db-migrator/src/lib/clients/postgres.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EACV,gBAAgB,EAMjB,MAAM,sBAAsB,CAAC;AAG9B,eAAO,MAAM,cAAc,EAAE,gBAyC5B,CAAC"}
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import { MigrationError } from "../MigrationError.js";
|
|
2
|
+
import { MigrationSQL } from "../migrator.sql.js";
|
|
3
|
+
import { load } from "../util.js";
|
|
4
|
+
export const postgresDriver = {
|
|
5
|
+
async connect(config) {
|
|
6
|
+
const { driver: _driver, ...options } = config ?? {};
|
|
7
|
+
// @ts-ignore не проверять
|
|
8
|
+
const m = (await import('../../../../db/postgres/src/index.js'));
|
|
9
|
+
// @ts-ignore ожидает перевода postgres.js на TypeScript
|
|
10
|
+
return m.default({
|
|
11
|
+
onnotice: () => { },
|
|
12
|
+
...options,
|
|
13
|
+
max: 1
|
|
14
|
+
});
|
|
15
|
+
},
|
|
16
|
+
async setup(dbClient) {
|
|
17
|
+
await dbClient.unsafe(MigrationSQL.table);
|
|
18
|
+
return dbClient.unsafe(MigrationSQL.exists);
|
|
19
|
+
},
|
|
20
|
+
async loop(dbClient, files, method) {
|
|
21
|
+
// @ts-ignore
|
|
22
|
+
await dbClient.begin(async (sql) => {
|
|
23
|
+
for (const obj of files) {
|
|
24
|
+
const file = await load(obj.abs);
|
|
25
|
+
const migrate = file[method];
|
|
26
|
+
if (typeof migrate === 'function') {
|
|
27
|
+
await Promise.resolve(migrate(sql)).catch((err) => {
|
|
28
|
+
throw new MigrationError(err instanceof Error ? err : new Error(String(err)), obj);
|
|
29
|
+
});
|
|
30
|
+
}
|
|
31
|
+
if (method === 'up') {
|
|
32
|
+
await sql `insert into migrations (name,created_at) values (${obj.name},now());`;
|
|
33
|
+
}
|
|
34
|
+
else if (method === 'down') {
|
|
35
|
+
await sql `delete from migrations where name = ${obj.name};`;
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
});
|
|
39
|
+
},
|
|
40
|
+
async end(dbClient) {
|
|
41
|
+
await dbClient.end();
|
|
42
|
+
}
|
|
43
|
+
};
|
|
44
|
+
//# sourceMappingURL=postgres.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"postgres.js","sourceRoot":"","sources":["../../../../../src/db-migrator/src/lib/clients/postgres.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAC;AACtD,OAAO,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AASlD,OAAO,EAAE,IAAI,EAAE,MAAM,YAAY,CAAC;AAElC,MAAM,CAAC,MAAM,cAAc,GAAqB;IAC9C,KAAK,CAAC,OAAO,CAAC,MAAwB;QACpC,MAAM,EAAE,MAAM,EAAE,OAAO,EAAE,GAAG,OAAO,EAAE,GAAG,MAAM,IAAI,EAAE,CAAC;QACrD,0BAA0B;QAC1B,MAAM,CAAC,GAAG,CAAC,MAAM,MAAM,CAAC,sCAAsC,CAAC,CAAQ,CAAC;QACxE,wDAAwD;QACxD,OAAO,CAAC,CAAC,OAAO,CAAC;YACf,QAAQ,EAAE,GAAG,EAAE,GAAE,CAAC;YAClB,GAAG,OAAO;YACV,GAAG,EAAE,CAAC;SACP,CAAqB,CAAC;IACzB,CAAC;IAED,KAAK,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ACF,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"migrator.log.d.ts","sourceRoot":"","sources":["../../../../src/db-migrator/src/lib/migrator.log.ts"],"names":[],"mappings":"AAKA,eAAO,MAAM,IAAI,GAAI,KAAK,MAAM,SAE/B,CAAC;AAEF,eAAO,MAAM,IAAI,GAAI,MAAM,MAAM,EAAE,KAAK,MAAM,GAAG,MAAM,EAAE,SAoBxD,CAAC;AAEF,eAAO,MAAM,IAAI,GAAI,KAAK,OAAO,UAkBhC,CAAC"}
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import { cyan, dim, gray, green, red, underline, yellow } from "../../../fmt/colors.js";
|
|
2
|
+
import { MigrationError } from "./MigrationError.js";
|
|
3
|
+
const PREFIX = '[migrator] ';
|
|
4
|
+
export const info = (msg) => {
|
|
5
|
+
console.log(cyan(PREFIX) + msg);
|
|
6
|
+
};
|
|
7
|
+
export const done = (type, arr) => {
|
|
8
|
+
const files = Array.isArray(arr) ? arr : [arr];
|
|
9
|
+
let msg = '';
|
|
10
|
+
if (type === 'new') {
|
|
11
|
+
msg += 'Created ' + green('1') + ' file:';
|
|
12
|
+
msg += green(dim('\n ⌁ ')) + underline(gray(files[0] ?? ''));
|
|
13
|
+
}
|
|
14
|
+
else if (files.length > 0) {
|
|
15
|
+
const arrow = type === 'down' ? '↓' : '↑';
|
|
16
|
+
const cc = type === 'status' ? yellow : green;
|
|
17
|
+
msg += type === 'status' ? 'Awaiting ' : 'Migrated ';
|
|
18
|
+
msg += cc(String(files.length)) + (files.length > 1 ? ' files:' : ' file:');
|
|
19
|
+
for (const file of files) {
|
|
20
|
+
msg += cc(dim(`\n ${arrow} `)) + underline(gray(file));
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
else {
|
|
24
|
+
msg += 'All caught up! 🎉';
|
|
25
|
+
}
|
|
26
|
+
process.stdout.write('\n' + green(PREFIX) + msg + '\n\n');
|
|
27
|
+
};
|
|
28
|
+
export const bail = (mix) => {
|
|
29
|
+
let msg = mix instanceof MigrationError ? `Error with "${underline(mix.migration.name)}" migration:` : 'An error occurred:';
|
|
30
|
+
if (mix instanceof Error) {
|
|
31
|
+
let pfx = `\n `;
|
|
32
|
+
const [title, ...rest] = mix.stack?.split(/[\n\r]+/g) ?? [];
|
|
33
|
+
msg += '\n\n ' + red(dim(underline(title ?? mix.message)));
|
|
34
|
+
rest.forEach((str) => (msg += dim('\n ' + str)));
|
|
35
|
+
if (!rest.length)
|
|
36
|
+
pfx += ' ';
|
|
37
|
+
for (const [key, value] of Object.entries(mix)) {
|
|
38
|
+
if (key === 'migration' || value === undefined)
|
|
39
|
+
continue;
|
|
40
|
+
msg += pfx + `${key}: ` + dim(String(value));
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
process.stdout.write('\n' + red(PREFIX) + msg + '\n\n');
|
|
44
|
+
process.exit(1);
|
|
45
|
+
};
|
|
46
|
+
//# sourceMappingURL=migrator.log.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"migrator.log.js","sourceRoot":"","sources":["../../../../src/db-migrator/src/lib/migrator.log.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,GAAG,EAAE,IAAI,EAAE,KAAK,EAAE,GAAG,EAAE,SAAS,EAAE,MAAM,EAAE,MAAM,wBAAwB,CAAC;AACxF,OAAO,EAAE,cAAc,EAAE,MAAM,qBAAqB,CAAC;AAErD,MAAM,MAAM,GAAG,aAAa,CAAC;AAE7B,MAAM,CAAC,MAAM,IAAI,GAAG,CAAC,GAAW,EAAE,EAAE;IAClC,OAAO,CAAC,GAAG,CAAC,IAAI,CAAC,MAAM,CAAC,GAAG,GAAG,CAAC,CAAC;AAClC,CAAC,CAAC;AAEF,MAAM,CAAC,MAAM,IAAI,GAAG,CAAC,IAAY,EAAE,GAAsB,EAAE,EAAE;IAC3D,MAAM,KAAK,GAAG,KAAK,CAAC,OAAO,CAAC,GAAG,CAAC,CA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