@yongdall/migrate 0.6.1 → 0.6.4
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/cli/migrate.mjs +1 -1
- package/cli/migrate.mjs.map +1 -1
- package/index.mjs +1 -1
- package/index.mjs.map +1 -1
- package/package.json +8 -7
package/cli/migrate.mjs
CHANGED
|
@@ -11,7 +11,7 @@ import migrate from "#index";
|
|
|
11
11
|
async function migrate_default({ options, development, plugins }) {
|
|
12
12
|
await init({ development });
|
|
13
13
|
const domain = options.domain?.find(Boolean) || "";
|
|
14
|
-
const database = options.
|
|
14
|
+
const database = options.database?.find(Boolean) || void 0;
|
|
15
15
|
migrate({
|
|
16
16
|
domain,
|
|
17
17
|
plugins: [...plugins],
|
package/cli/migrate.mjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"migrate.mjs","names":[],"sources":["../../../cli/migrate/cli/migrate.mjs"],"sourcesContent":["import { stop } from '@yongdall/connection';\nimport init from '@yongdall/init';\nimport migrate from '#index';\n/** @import { Cli } from '@yongdall/cli-parse' */\n\n\n\n/**\n * \n * @param {Cli.Env} env \n */\nexport default async function ({ options, development, plugins }) {\n\tawait init({ development });\n\tconst domain = options.domain?.find(Boolean) || '';\n\tconst database = options.
|
|
1
|
+
{"version":3,"file":"migrate.mjs","names":[],"sources":["../../../cli/migrate/cli/migrate.mjs"],"sourcesContent":["import { stop } from '@yongdall/connection';\nimport init from '@yongdall/init';\nimport migrate from '#index';\n/** @import { Cli } from '@yongdall/cli-parse' */\n\n\n\n/**\n * \n * @param {Cli.Env} env \n */\nexport default async function ({ options, development, plugins }) {\n\tawait init({ development });\n\tconst domain = options.domain?.find(Boolean) || '';\n\tconst database = options.database?.find(Boolean) || undefined;\n\tmigrate({ domain, plugins: [...plugins], database }).then(stop);\n}\n"],"mappings":";;;;;;;;;;AAWA,+BAA+B,EAAE,SAAS,aAAa,WAAW;AACjE,OAAM,KAAK,EAAE,aAAa,CAAC;CAC3B,MAAM,SAAS,QAAQ,QAAQ,KAAK,QAAQ,IAAI;CAChD,MAAM,WAAW,QAAQ,UAAU,KAAK,QAAQ,IAAI;AACpD,SAAQ;EAAE;EAAQ,SAAS,CAAC,GAAG,QAAQ;EAAE;EAAU,CAAC,CAAC,KAAK,KAAK"}
|
package/index.mjs
CHANGED
|
@@ -18,7 +18,7 @@ import { loadPluginProfiles } from "@yongdall/plugins";
|
|
|
18
18
|
*/
|
|
19
19
|
async function migrate_default({ plugins, database, domain } = {}) {
|
|
20
20
|
const pluginSet = plugins?.length ? new Set(plugins) : null;
|
|
21
|
-
const modelList = await Array.fromAsync(loadPluginProfiles("migration", function* (config, plugin) {
|
|
21
|
+
const modelList = await Array.fromAsync(loadPluginProfiles(["migration", "migrations"], function* (config, plugin) {
|
|
22
22
|
if (!config) return;
|
|
23
23
|
if (pluginSet && !pluginSet.has(plugin)) return;
|
|
24
24
|
const models = config.models;
|
package/index.mjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.mjs","names":[],"sources":["../../cli/migrate/index.mjs"],"sourcesContent":["/** @import { ModelTable } from '@yongdall/model' */\nimport { useDatabase } from '@yongdall/connection';\nimport { _run } from '@yongdall/context';\nimport { loadPluginProfiles } from '@yongdall/plugins';\n\n/**\n * @typedef {object} Profile\n * @property {ModelTable[]} models\n */\n/**\n * \n * @param {object} [options]\n * @param {string[]} [options.plugins]\n * @param {string} [options.database] \n * @param {string} [options.domain] \n * @returns {Promise<void>}\n */\nexport default async function ({\n\tplugins, database, domain\n} = {}) {\n\tconst pluginSet = plugins?.length ? new Set(plugins) : null;\n\tconst modelList = await Array.fromAsync(\n\t\tloadPluginProfiles('migration', function* (/** @type {Partial<Profile>} */config, plugin) {\n\t\t\tif (!config) { return; }\n\t\t\tif (pluginSet && !pluginSet.has(plugin)) { return; }\n\t\t\tconst models = config.models;\n\t\t\tif (!Array.isArray(models)) { return; }\n\t\t\tyield* models;\n\t\t})\n\t);\n\treturn _run({ domain: domain || '' }, async () => {\n\t\tif (typeof database === 'string') {\n\t\t\tconst id = ['-_/'].includes(database) ? '' : database;\n\t\t\tconst models = modelList.filter(v => (v.databaseId || '') === id);\n\t\t\tawait useDatabase(id).transaction(t => t.syncTables(models));\n\t\t\treturn;\n\t\t}\n\t\tconst models = Object.groupBy(modelList, d => d.databaseId || '');\n\t\tfor (const [databaseId, list] of Object.entries(models)) {\n\t\t\tif (!list) { continue; }\n\t\t\tawait useDatabase(databaseId).transaction(t => t.syncTables(list));\n\t\t}\n\n\t});\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;AAiBA,+BAA+B,EAC9B,SAAS,UAAU,WAChB,EAAE,EAAE;CACP,MAAM,YAAY,SAAS,SAAS,IAAI,IAAI,QAAQ,GAAG;CACvD,MAAM,YAAY,MAAM,MAAM,UAC7B,mBAAmB,aAAa,WAA0C,QAAQ,QAAQ;
|
|
1
|
+
{"version":3,"file":"index.mjs","names":[],"sources":["../../cli/migrate/index.mjs"],"sourcesContent":["/** @import { ModelTable } from '@yongdall/model' */\nimport { useDatabase } from '@yongdall/connection';\nimport { _run } from '@yongdall/context';\nimport { loadPluginProfiles } from '@yongdall/plugins';\n\n/**\n * @typedef {object} Profile\n * @property {ModelTable[]} models\n */\n/**\n * \n * @param {object} [options]\n * @param {string[]} [options.plugins]\n * @param {string} [options.database] \n * @param {string} [options.domain] \n * @returns {Promise<void>}\n */\nexport default async function ({\n\tplugins, database, domain\n} = {}) {\n\tconst pluginSet = plugins?.length ? new Set(plugins) : null;\n\tconst modelList = await Array.fromAsync(\n\t\tloadPluginProfiles(['migration', 'migrations'], function* (/** @type {Partial<Profile>} */config, plugin) {\n\t\t\tif (!config) { return; }\n\t\t\tif (pluginSet && !pluginSet.has(plugin)) { return; }\n\t\t\tconst models = config.models;\n\t\t\tif (!Array.isArray(models)) { return; }\n\t\t\tyield* models;\n\t\t})\n\t);\n\treturn _run({ domain: domain || '' }, async () => {\n\t\tif (typeof database === 'string') {\n\t\t\tconst id = ['-_/'].includes(database) ? '' : database;\n\t\t\tconst models = modelList.filter(v => (v.databaseId || '') === id);\n\t\t\tawait useDatabase(id).transaction(t => t.syncTables(models));\n\t\t\treturn;\n\t\t}\n\t\tconst models = Object.groupBy(modelList, d => d.databaseId || '');\n\t\tfor (const [databaseId, list] of Object.entries(models)) {\n\t\t\tif (!list) { continue; }\n\t\t\tawait useDatabase(databaseId).transaction(t => t.syncTables(list));\n\t\t}\n\n\t});\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;AAiBA,+BAA+B,EAC9B,SAAS,UAAU,WAChB,EAAE,EAAE;CACP,MAAM,YAAY,SAAS,SAAS,IAAI,IAAI,QAAQ,GAAG;CACvD,MAAM,YAAY,MAAM,MAAM,UAC7B,mBAAmB,CAAC,aAAa,aAAa,EAAE,WAA0C,QAAQ,QAAQ;AACzG,MAAI,CAAC,OAAU;AACf,MAAI,aAAa,CAAC,UAAU,IAAI,OAAO,CAAI;EAC3C,MAAM,SAAS,OAAO;AACtB,MAAI,CAAC,MAAM,QAAQ,OAAO,CAAI;AAC9B,SAAO;GACN,CACF;AACD,QAAO,KAAK,EAAE,QAAQ,UAAU,IAAI,EAAE,YAAY;AACjD,MAAI,OAAO,aAAa,UAAU;GACjC,MAAM,KAAK,CAAC,MAAM,CAAC,SAAS,SAAS,GAAG,KAAK;GAC7C,MAAM,SAAS,UAAU,QAAO,OAAM,EAAE,cAAc,QAAQ,GAAG;AACjE,SAAM,YAAY,GAAG,CAAC,aAAY,MAAK,EAAE,WAAW,OAAO,CAAC;AAC5D;;EAED,MAAM,SAAS,OAAO,QAAQ,YAAW,MAAK,EAAE,cAAc,GAAG;AACjE,OAAK,MAAM,CAAC,YAAY,SAAS,OAAO,QAAQ,OAAO,EAAE;AACxD,OAAI,CAAC,KAAQ;AACb,SAAM,YAAY,WAAW,CAAC,aAAY,MAAK,EAAE,WAAW,KAAK,CAAC;;GAGlE"}
|
package/package.json
CHANGED
|
@@ -1,20 +1,21 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@yongdall/migrate",
|
|
3
|
-
"version": "0.6.
|
|
3
|
+
"version": "0.6.4",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"main": "./index.mjs",
|
|
6
6
|
"imports": {
|
|
7
7
|
"#index": "./index.mjs"
|
|
8
8
|
},
|
|
9
9
|
"dependencies": {
|
|
10
|
-
"@yongdall/plugins": "^0.6.
|
|
11
|
-
"@yongdall/context": "^0.6.
|
|
12
|
-
"@yongdall/init": "^0.6.
|
|
13
|
-
"@yongdall/connection": "^0.6.
|
|
14
|
-
"@yongdall/model": "^0.6.
|
|
10
|
+
"@yongdall/plugins": "^0.6.4",
|
|
11
|
+
"@yongdall/context": "^0.6.4",
|
|
12
|
+
"@yongdall/init": "^0.6.4",
|
|
13
|
+
"@yongdall/connection": "^0.6.4",
|
|
14
|
+
"@yongdall/model": "^0.6.4"
|
|
15
15
|
},
|
|
16
16
|
"devDependencies": {
|
|
17
|
-
"@yongdall/cli
|
|
17
|
+
"@yongdall/cli": "^0.6.4",
|
|
18
|
+
"@yongdall/cli-parse": "^0.6.4"
|
|
18
19
|
},
|
|
19
20
|
"exports": {
|
|
20
21
|
".": "./index.mjs"
|