Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

feat: configuration for seamless cli use in a typescript project#1439

Open
malik-samad wants to merge2 commits intosequelize:main
base:main
Choose a base branch
Loading
frommalik-samad:cli-typescript-support

Conversation

malik-samad
Copy link

  • In this commit, I have modified the templates and made other related changes to add support for typescript projects.

  • The new changes I made, will automatically detect if the project that uses sequelize-cli is on typescript or not and will switch logic based on it.

Pull Request check-list

Please make sure to review and check all of these items:

  • Doesnpm run test pass with this change (including linting)?
  • Does the description below contain a link to an existing issue (Closes #[issue]) or a description of the issue you are solving?
  • Have you added new tests to prevent regressions?
  • Is a documentation update included (if this change modifies existing APIs, or introduces new ones)?

Description of change

Link to the issue:#1436

The sequelize-cli didn't have the support for typescript projects and in this PR I implemented certain changes that will make it capable of handling the CLI for both typescript and javascript files, additionally, I have improved the templates to be able to generate both.ts and.js files for migrations, models, and seeds.

berubenic reacted with rocket emoji
- In this commit, i have modified the templates and did other related changes to add support for typescript projects.- The new changes I made, will automatically detect if the project that uses sequelize-cli is on typescirpt or not and will switch logic based on it.
dataValues: null,
};
} else if (split.length === 3) {
const validValues = /^\{(,? ?[A-z0-9 ]+)+\}$/;
const validValues =
/^\{((('[A-z0-9 ]+')|("[A-z0-9 ]+")|([A-z0-9 ]+)))(, ?(('[A-z0-9 ]+')|("[A-z0-9 ]+")|([A-z0-9 ]+)))*\}$/;

Check failure

Code scanning / CodeQL

Inefficient regular expression

This part of the regular expression may cause exponential backtracking on strings starting with '{{ ,' and containing many repetitions of ' ,'.
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

it's a false positive,@WikiRik can you please dismiss this alert?

dataValues: null,
};
} else if (split.length === 3) {
const validValues = /^\{(,? ?[A-z0-9 ]+)+\}$/;
const validValues =
/^\{((('[A-z0-9 ]+')|("[A-z0-9 ]+")|([A-z0-9 ]+)))(, ?(('[A-z0-9 ]+')|("[A-z0-9 ]+")|([A-z0-9 ]+)))*\}$/;

Check warning

Code scanning / CodeQL

Overly permissive regular expression range

Suspicious character range that is equivalent to \[A-Z\\[\\\\]^_`a-z\].
dataValues: null,
};
} else if (split.length === 3) {
const validValues = /^\{(,? ?[A-z0-9 ]+)+\}$/;
const validValues =
/^\{((('[A-z0-9 ]+')|("[A-z0-9 ]+")|([A-z0-9 ]+)))(, ?(('[A-z0-9 ]+')|("[A-z0-9 ]+")|([A-z0-9 ]+)))*\}$/;

Check warning

Code scanning / CodeQL

Overly permissive regular expression range

Suspicious character range that is equivalent to \[A-Z\\[\\\\]^_`a-z\].
dataValues: null,
};
} else if (split.length === 3) {
const validValues = /^\{(,? ?[A-z0-9 ]+)+\}$/;
const validValues =
/^\{((('[A-z0-9 ]+')|("[A-z0-9 ]+")|([A-z0-9 ]+)))(, ?(('[A-z0-9 ]+')|("[A-z0-9 ]+")|([A-z0-9 ]+)))*\}$/;

Check warning

Code scanning / CodeQL

Overly permissive regular expression range

Suspicious character range that is equivalent to \[A-Z\\[\\\\]^_`a-z\].
dataValues: null,
};
} else if (split.length === 3) {
const validValues = /^\{(,? ?[A-z0-9 ]+)+\}$/;
const validValues =
/^\{((('[A-z0-9 ]+')|("[A-z0-9 ]+")|([A-z0-9 ]+)))(, ?(('[A-z0-9 ]+')|("[A-z0-9 ]+")|([A-z0-9 ]+)))*\}$/;

Check warning

Code scanning / CodeQL

Overly permissive regular expression range

Suspicious character range that is equivalent to \[A-Z\\[\\\\]^_`a-z\].
dataValues: null,
};
} else if (split.length === 3) {
const validValues = /^\{(,? ?[A-z0-9 ]+)+\}$/;
const validValues =
/^\{((('[A-z0-9 ]+')|("[A-z0-9 ]+")|([A-z0-9 ]+)))(, ?(('[A-z0-9 ]+')|("[A-z0-9 ]+")|([A-z0-9 ]+)))*\}$/;

Check warning

Code scanning / CodeQL

Overly permissive regular expression range

Suspicious character range that is equivalent to \[A-Z\\[\\\\]^_`a-z\].
dataValues: null,
};
} else if (split.length === 3) {
const validValues = /^\{(,? ?[A-z0-9 ]+)+\}$/;
const validValues =
/^\{((('[A-z0-9 ]+')|("[A-z0-9 ]+")|([A-z0-9 ]+)))(, ?(('[A-z0-9 ]+')|("[A-z0-9 ]+")|([A-z0-9 ]+)))*\}$/;

Check warning

Code scanning / CodeQL

Overly permissive regular expression range

Suspicious character range that is equivalent to \[A-Z\\[\\\\]^_`a-z\].
@malik-samadmalik-samad marked this pull request as draftJanuary 21, 2024 17:07
@malik-samadmalik-samad marked this pull request as ready for reviewJanuary 21, 2024 17:18
@@ -1,8 +1,9 @@
'use strict';
<%= isTypescriptProject ? `import { QueryInterface, DataTypes } from 'sequelize';` : '' %>

/** @type {import('sequelize-cli').Migration} */
module.exports = {

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

i think also worthexport default no?

}
}

const isTypescriptProject = isPackageInstalled('typescript');
Copy link

@shlomisasshlomisasFeb 26, 2025
edited
Loading

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

what about having a way to decide it from the CLI? e.g.npx sequelize-cli migration:generate --name XXX --typescript and then inside each*_generate.js provide theisTypescript to therender function?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment
Reviewers

@shlomisasshlomisasshlomisas left review comments

@WikiRikWikiRikWikiRik left review comments

At least 1 approving review is required to merge this pull request.

Assignees
No one assigned
Labels
None yet
Projects
None yet
Milestone
No milestone
Development

Successfully merging this pull request may close these issues.

3 participants
@malik-samad@shlomisas@WikiRik

[8]ページ先頭

©2009-2025 Movatter.jp