Skip to content

Commit

Permalink
fix(deps): update sequelize to v6
Browse files Browse the repository at this point in the history
  • Loading branch information
rocwind committed Aug 23, 2021
1 parent 515ca34 commit bf7a152
Show file tree
Hide file tree
Showing 7 changed files with 63 additions and 68 deletions.
6 changes: 3 additions & 3 deletions core/services/app-manager.js
Original file line number Diff line number Diff line change
Expand Up @@ -69,8 +69,8 @@ proto.deleteApp = function (appId) {
};

proto.modifyApp = function (appId, params) {
return models.Apps.update(params, { where: { id: appId } }).spread(
(affectedCount, affectedRows) => {
return models.Apps.update(params, { where: { id: appId } }).then(
([affectedCount, affectedRows]) => {
if (!_.gt(affectedCount, 0)) {
throw AppError.AppError('modify errors');
}
Expand Down Expand Up @@ -135,7 +135,7 @@ proto.getAppDetailInfo = function (appInfo, currentUid) {
return Promise.all([
models.Deployments.findAll({ where: { appid: appId } }),
models.Collaborators.findAll({ where: { appid: appId } }),
]).spread((deploymentInfos, collaboratorInfos) => {
]).then(([deploymentInfos, collaboratorInfos]) => {
return Promise.props({
collaborators: Promise.reduce(
collaboratorInfos,
Expand Down
2 changes: 1 addition & 1 deletion core/services/deployments.js
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ proto.renameDeloymentByName = function (deploymentName, appId, newName) {
return models.Deployments.update(
{ name: newName },
{ where: { name: deploymentName, appid: appId } },
).spread((affectedCount, affectedRow) => {
).then(([affectedCount, affectedRow]) => {
if (_.gt(affectedCount, 0)) {
return { name: newName };
} else {
Expand Down
18 changes: 9 additions & 9 deletions core/services/package-manager.js
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ proto.createDeploymentsVersionIfNotExist = function (
},
defaults: { current_package_id: 0 },
transaction: t,
}).spread((data, created) => {
}).then(([data, created]) => {
if (created) {
log.debug(`createDeploymentsVersionIfNotExist findOrCreate version ${appVersion}`);
}
Expand Down Expand Up @@ -354,13 +354,13 @@ proto.createDiffPackagesByLastNums = function (appId, originalPackage, num) {
}),
models.Apps.findByPk(appId),
])
.spread((lastNumsPackages, basePackages, appInfo) => {
.then(([lastNumsPackages, basePackages, appInfo]) => {
return [
_.uniqBy(_.unionBy(lastNumsPackages, basePackages, 'id'), 'package_hash'),
appInfo,
];
})
.spread((lastNumsPackages, appInfo) => {
.then(([lastNumsPackages, appInfo]) => {
return self.createDiffPackages(
originalPackage,
lastNumsPackages,
Expand Down Expand Up @@ -435,7 +435,7 @@ proto.releasePackage = function (appId, deploymentId, packageInfo, filePath, rel
return common.unzipFile(filePath, directoryPath);
}),
])
.spread((blobHash) => {
.then(([blobHash]) => {
return security.uploadPackageType(directoryPath).then((type) => {
return models.Apps.findByPk(appId).then((appInfo) => {
if (type > 0 && appInfo.os > 0 && appInfo.os != type) {
Expand Down Expand Up @@ -485,7 +485,7 @@ proto.releasePackage = function (appId, deploymentId, packageInfo, filePath, rel
});
});
})
.spread((packageHash, manifestHash, blobHash) => {
.then(([packageHash, manifestHash, blobHash]) => {
var stats = fs.statSync(filePath);
var params = {
releaseMethod: constConfig.RELEAS_EMETHOD_UPLOAD,
Expand Down Expand Up @@ -537,7 +537,7 @@ proto.modifyReleasePackage = function (packageId, params) {
}),
models.DeploymentsVersions.findByPk(packageInfo.deployment_version_id),
])
.spread((v1, v2) => {
.then(([v1, v2]) => {
if (v1 && !_.eq(v1.id, v2.id)) {
log.debug(v1);
throw new AppError.AppError(`${appVersion} already exist.`);
Expand Down Expand Up @@ -633,7 +633,7 @@ proto.promotePackage = function (sourceDeploymentInfo, destDeploymentInfo, param
});
}
})
.spread((sourcePack, deploymentsVersions) => {
.then(([sourcePack, deploymentsVersions]) => {
var appFinalVersion = appVersion || deploymentsVersions.app_version;
log.debug('sourcePack', sourcePack);
log.debug('deploymentsVersions', deploymentsVersions);
Expand Down Expand Up @@ -662,7 +662,7 @@ proto.promotePackage = function (sourceDeploymentInfo, destDeploymentInfo, param
return [sourcePack, deploymentsVersions, appFinalVersion];
});
})
.spread((sourcePack, deploymentsVersions, appFinalVersion) => {
.then(([sourcePack, deploymentsVersions, appFinalVersion]) => {
var versionInfo = common.validatorVersion(appFinalVersion);
if (!versionInfo[0]) {
log.debug(`targetBinaryVersion ${appVersion} not support.`);
Expand Down Expand Up @@ -727,7 +727,7 @@ proto.rollbackPackage = function (deploymentVersionId, targetLabel, rollbackUid)
});
}
})
.spread((currentPackageInfo, rollbackPackageInfos) => {
.then(([currentPackageInfo, rollbackPackageInfos]) => {
if (currentPackageInfo && rollbackPackageInfos.length > 0) {
for (var i = rollbackPackageInfos.length - 1; i >= 0; i--) {
if (
Expand Down
2 changes: 1 addition & 1 deletion models/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ fs.readdirSync(__dirname)
return file.indexOf('.') !== 0 && file !== basename && file.slice(-3) === '.js';
})
.forEach(function (file) {
var model = sequelize['import'](path.join(__dirname, file));
var model = require(path.join(__dirname, file))(sequelize, Sequelize.DataTypes);
db[model.name] = model;
});

Expand Down
93 changes: 44 additions & 49 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@
"recursive-readdir": "2.2.2",
"redis": "3.1.2",
"request": "2.88.2",
"sequelize": "5.22.4",
"sequelize": "6.6.5",
"serve-favicon": "2.5.0",
"slash": "3.0.0",
"upyun": "3.4.4",
Expand Down
8 changes: 4 additions & 4 deletions routes/apps.js
Original file line number Diff line number Diff line change
Expand Up @@ -396,7 +396,7 @@ router.patch(
});
}
})
.spread((deploymentInfo, packageInfo) => {
.then(([deploymentInfo, packageInfo]) => {
if (!packageInfo) {
throw new AppError.AppError('does not find the packageInfo');
}
Expand Down Expand Up @@ -451,7 +451,7 @@ router.post(
deployments.findDeloymentByName(sourceDeploymentName, appId),
deployments.findDeloymentByName(destDeploymentName, appId),
])
.spread((sourceDeploymentInfo, destDeploymentInfo) => {
.then(([sourceDeploymentInfo, destDeploymentInfo]) => {
if (!sourceDeploymentInfo) {
throw new AppError.AppError(`${sourceDeploymentName} does not exist.`);
}
Expand All @@ -460,7 +460,7 @@ router.post(
}
return [sourceDeploymentInfo, destDeploymentInfo];
})
.spread((sourceDeploymentInfo, destDeploymentInfo) => {
.then(([sourceDeploymentInfo, destDeploymentInfo]) => {
var params = _.get(req.body, 'packageInfo', {});
_.set(params, 'promoteUid', uid);
return [
Expand All @@ -472,7 +472,7 @@ router.post(
destDeploymentInfo,
];
})
.spread((packages, destDeploymentInfo) => {
.then(([packages, destDeploymentInfo]) => {
if (packages) {
Promise.delay(1000).then(() => {
packageManager
Expand Down

0 comments on commit bf7a152

Please sign in to comment.