@xenon-device-management/xenon 1.1.26 → 1.1.28
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/lib/package.json
CHANGED
|
@@ -54,9 +54,10 @@ const logger_1 = __importDefault(require("../logger"));
|
|
|
54
54
|
const config_1 = require("../config");
|
|
55
55
|
function resolvePluginRoot() {
|
|
56
56
|
let dir = __dirname;
|
|
57
|
-
for (let i = 0; i <
|
|
57
|
+
for (let i = 0; i < 8; i++) {
|
|
58
58
|
const pkgJson = path.join(dir, 'package.json');
|
|
59
|
-
|
|
59
|
+
const schema = path.join(dir, 'prisma', 'schema.prisma');
|
|
60
|
+
if (fs.existsSync(pkgJson) && fs.existsSync(schema)) {
|
|
60
61
|
try {
|
|
61
62
|
const pkg = JSON.parse(fs.readFileSync(pkgJson, 'utf8'));
|
|
62
63
|
if (pkg.name === '@xenon-device-management/xenon' || pkg.name === 'xenon') {
|
|
@@ -93,16 +94,19 @@ function runMigrations() {
|
|
|
93
94
|
const dbDir = path.dirname(config_1.config.databasePath || path.join(os.homedir(), '.cache', 'xenon', 'xenon.db'));
|
|
94
95
|
fs.mkdirSync(dbDir, { recursive: true });
|
|
95
96
|
const { cmd, prefix } = resolvePrismaInvocation(rootDir);
|
|
96
|
-
const args = [...prefix, 'migrate', 'deploy', '--schema', schemaPath];
|
|
97
97
|
const env = Object.assign(Object.assign({}, process.env), { DATABASE_URL: config_1.config.databaseUrl });
|
|
98
|
+
const isSqlite = config_1.config.databaseProvider === 'sqlite';
|
|
99
|
+
const args = isSqlite
|
|
100
|
+
? [...prefix, 'db', 'push', '--skip-generate', '--accept-data-loss', '--schema', schemaPath]
|
|
101
|
+
: [...prefix, 'migrate', 'deploy', '--schema', schemaPath];
|
|
98
102
|
try {
|
|
99
|
-
logger_1.default.info(`[DBMigrate]
|
|
103
|
+
logger_1.default.info(`[DBMigrate] Syncing database schema (${config_1.config.databaseProvider}, ${isSqlite ? 'db push' : 'migrate deploy'})...`);
|
|
100
104
|
(0, node_child_process_1.execFileSync)(cmd, args, { env, cwd: rootDir, stdio: 'pipe' });
|
|
101
|
-
logger_1.default.info('[DBMigrate]
|
|
105
|
+
logger_1.default.info('[DBMigrate] Database schema in sync.');
|
|
102
106
|
}
|
|
103
107
|
catch (err) {
|
|
104
108
|
const msg = ((_a = err === null || err === void 0 ? void 0 : err.stderr) === null || _a === void 0 ? void 0 : _a.toString()) || (err === null || err === void 0 ? void 0 : err.message) || String(err);
|
|
105
|
-
logger_1.default.error(`[DBMigrate] Auto-
|
|
109
|
+
logger_1.default.error(`[DBMigrate] Auto-sync failed: ${msg}`);
|
|
106
110
|
}
|
|
107
111
|
});
|
|
108
112
|
}
|
package/package.json
CHANGED