Skip to content
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 our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

job prevent-typescript-dependency error #127

Open
nvuillam opened this issue Sep 1, 2024 · 9 comments
Open

job prevent-typescript-dependency error #127

nvuillam opened this issue Sep 1, 2024 · 9 comments

Comments

@nvuillam
Copy link

nvuillam commented Sep 1, 2024

I don't understand why job prevent-typescript-dependency is failing.

My package.json (containing typescript as devDependency) : https://github.com/hardisgroupcom/sfdx-hardis/blob/migrate-sf-plugin/package.json, but I check on core SF plugins (like plugin-apex) and they also contain the same dev dependency.

Example failing job: https://github.com/hardisgroupcom/sfdx-hardis/actions/runs/10657386234/job/29537151978?pr=770

[4/4] Calculating file sizes...
info 
=> Found "[email protected]"
info Has been hoisted to "typescript"
info Reasons this module exists
   - Specified in "devDependencies"
   - Hoisted from "@salesforce#dev-scripts#typescript"
   - Hoisted from "@oclif#plugin-command-snapshot#ts-json-schema-generator#typescript"
   - Hoisted from "@salesforce#dev-scripts#@commitlint#cli#@commitlint#load#typescript"
info Disk size without dependencies: "31.2MB"
info Disk size with unique dependencies: "31.2MB"
info Disk size with transitive dependencies: "31.2MB"
info Number of shared dependencies: 0

What can I do to pass the test ?

cc @iowillhoit

@nvuillam
Copy link
Author

nvuillam commented Sep 1, 2024

@goncastrum I won't click here and I hope nobody else will, it looks like phishing.

@iam-py-test
Copy link

@nvuillam they are a known spam bot. The MediaFire link downloads a password-protected archive containing an unknown piece of malware:
https://github.com/hagezi/dns-blocklists/issues/3598
https://www.virustotal.com/gui/file/1f79a95f6bde6c375a9d60dfba8c02fd463d2cbe1d2d7a38eaa0ba403d3529d0/detection
The uBlock Origin team has created a GitHub Actions script to detect and remove these comments: https://github.com/uBlockOrigin/uAssets/blob/master/.github/workflows/on-issue-comment.yml
While it is effective, I am concerned about false positives.
Thanks

@cristiand391
Copy link
Member

devDeps shouldn't affect the test, we do yarn install --production:
https://github.com/salesforcecli/github-workflows/blob/main/.github/workflows/preventTypescriptDep.yml

also, I've seen yarn why not working as expected (still yarn v1, might have bugs 🤷🏼 ), you can use npm why instead.

I cloned your project/branch, ran yarn install --production, npm why typescript and got this;

➜  sfdx-hardis git:(migrate-sf-plugin) npm why typescript
[email protected]
node_modules/typescript
  dev typescript@"^5.4.5" from the root project
  peerOptional typescript@">=4.9.5" from [email protected]
  node_modules/cosmiconfig
    cosmiconfig@"^9.0.0" from the root project
    cosmiconfig@"^9.0.0" from [email protected]
    node_modules/puppeteer
      puppeteer@"^23.2.0" from the root project
    cosmiconfig@"^9.0.0" from @oclif/[email protected]
    node_modules/@oclif/core
      @oclif/core@"^4" from the root project
      @oclif/core@"^4" from @salesforce/[email protected]
      node_modules/@salesforce/sf-plugins-core
        @salesforce/sf-plugins-core@"^10.0.0" from the root project

stopped using cosmiconfig specifically b/c of this (it has TS as a peerDep and npm installs it):
oclif/core#1108

Try updating to latest sf-plugins-core (I think its coming from there via an old oclif/core version).

@nvuillam
Copy link
Author

nvuillam commented Sep 2, 2024

Ok i'll try that and let you know here, thanks

@nvuillam
Copy link
Author

nvuillam commented Sep 2, 2024

@cristiand391 I upgraded to the latest @salesforce/plugin-core , but... it does not accept the property flags on classes, even the hello/world.ts command of plugin is crying :/

src/commands/hello/world.ts:17:26 - error TS2742: The inferred type of 'flags' cannot be named without a reference to '@salesforce/sf-plugins-core/node_modules/@oclif/core/interfaces'. This is likely not portable. A type annotation is necessary.

17   public static readonly flags = {
                            ~~~~~

Would you have a magic tip so I solve the issue ? ^^

Here is the complete code of the sample command provided by sf plugins

import { SfCommand, Flags } from '@salesforce/sf-plugins-core';
import { Messages } from '@salesforce/core';

Messages.importMessagesDirectoryFromMetaUrl(import.meta.url);
const messages = Messages.loadMessages('sfdx-hardis', 'hello.world');

export type HelloWorldResult = {
  name: string;
  time: string;
};

export default class World extends SfCommand<HelloWorldResult> {
  public static readonly summary = messages.getMessage('summary');
  public static readonly description = messages.getMessage('description');
  public static readonly examples = messages.getMessages('examples');

  public static readonly flags = {
    name: Flags.string({
      char: 'n',
      summary: messages.getMessage('flags.name.summary'),
      description: messages.getMessage('flags.name.description'),
      default: 'World',
    }),
  };

  public async run(): Promise<HelloWorldResult> {
    const { flags } = await this.parse(World);
    const time = new Date().toDateString();
    this.log(messages.getMessage('info.hello', [flags.name, time]));
    return {
      name: flags.name,
      time,
    };
  }
}

@nvuillam
Copy link
Author

nvuillam commented Sep 2, 2024

I upgraded @salesforce/sf-plugins-core to latest version

Latest job run : https://github.com/hardisgroupcom/sfdx-hardis/actions/runs/10673342257/job/29582239557?pr=770

Would it be possible to add some variable in your script allowing to skip the typescript check ? I don't think I'll be able to get rid of it :/

$ npm why typescript
[email protected]
node_modules/typescript
  dev typescript@"^5.4.5" from the root project
  peerOptional typescript@">=4.9.5" from [email protected]
  node_modules/cosmiconfig
    cosmiconfig@"^9.0.0" from the root project
    cosmiconfig@"^9.0.0" from [email protected]
    node_modules/puppeteer
      puppeteer@"^23.2.0" from the root project
    cosmiconfig@"^9.0.0" from @oclif/[email protected]
    node_modules/@oclif/core
      @oclif/core@"^4" from the root project
      @oclif/core@"^4" from [email protected]
      node_modules/oclif
        dev oclif@"^4.14.0" from the root project
      @oclif/core@"^4" from @oclif/[email protected]
      node_modules/@oclif/plugin-warn-if-update-available
        @oclif/plugin-warn-if-update-available@"^3.0.19" from [email protected]
        node_modules/oclif
          dev oclif@"^4.14.0" from the root project
      @oclif/core@"^4" from @oclif/[email protected]
      node_modules/@oclif/plugin-not-found
        @oclif/plugin-not-found@"^3.2.3" from [email protected]
        node_modules/oclif
          dev oclif@"^4.14.0" from the root project
      @oclif/core@"^4" from @oclif/[email protected]
      node_modules/@oclif/plugin-help
        @oclif/plugin-help@"^6.2.2" from [email protected]
        node_modules/oclif
          dev oclif@"^4.14.0" from the root project
    cosmiconfig@"*" from @types/[email protected]
    node_modules/@types/cosmiconfig
      dev @types/cosmiconfig@"^6.0.0" from the root project
  peer typescript@">=4.2.0" from [email protected]
  node_modules/ts-api-utils
    ts-api-utils@"^1.0.1" from @typescript-eslint/[email protected]
    node_modules/@typescript-eslint/eslint-plugin
      @typescript-eslint/eslint-plugin@"^6.21.0" from [email protected]
      node_modules/eslint-config-salesforce-typescript
        eslint-config-salesforce-typescript@"^3.3.0" from @salesforce/[email protected]
        node_modules/@salesforce/dev-scripts
          dev @salesforce/dev-scripts@"^10" from the root project
    ts-api-utils@"^1.0.1" from @typescript-eslint/[email protected]
    node_modules/@typescript-eslint/typescript-estree
      @typescript-eslint/typescript-estree@"6.21.0" from @typescript-eslint/[email protected]
      node_modules/@typescript-eslint/parser
        @typescript-eslint/parser@"^6.21.0" from [email protected]
        node_modules/eslint-config-salesforce-typescript
          eslint-config-salesforce-typescript@"^3.3.0" from @salesforce/[email protected]
          node_modules/@salesforce/dev-scripts
            dev @salesforce/dev-scripts@"^10" from the root project
        peer @typescript-eslint/parser@"^6.0.0 || ^6.0.0-alpha" from @typescript-eslint/[email protected]
        node_modules/@typescript-eslint/eslint-plugin
          @typescript-eslint/eslint-plugin@"^6.21.0" from [email protected]
          node_modules/eslint-config-salesforce-typescript
            eslint-config-salesforce-typescript@"^3.3.0" from @salesforce/[email protected]
            node_modules/@salesforce/dev-scripts
              dev @salesforce/dev-scripts@"^10" from the root project
      @typescript-eslint/typescript-estree@"6.21.0" from @typescript-eslint/[email protected]
      node_modules/@typescript-eslint/type-utils
        @typescript-eslint/type-utils@"6.21.0" from @typescript-eslint/[email protected]
        node_modules/@typescript-eslint/eslint-plugin
          @typescript-eslint/eslint-plugin@"^6.21.0" from [email protected]
          node_modules/eslint-config-salesforce-typescript
            eslint-config-salesforce-typescript@"^3.3.0" from @salesforce/[email protected]
            node_modules/@salesforce/dev-scripts
              dev @salesforce/dev-scripts@"^10" from the root project
      @typescript-eslint/typescript-estree@"6.21.0" from @typescript-eslint/[email protected]
      node_modules/@typescript-eslint/utils
        @typescript-eslint/utils@"^6.17.0" from [email protected]
        node_modules/eslint-plugin-sf-plugin
          dev eslint-plugin-sf-plugin@"^1.18.6" from the root project
        @typescript-eslint/utils@"6.21.0" from @typescript-eslint/[email protected]
        node_modules/@typescript-eslint/eslint-plugin
          @typescript-eslint/eslint-plugin@"^6.21.0" from [email protected]
          node_modules/eslint-config-salesforce-typescript
            eslint-config-salesforce-typescript@"^3.3.0" from @salesforce/[email protected]
            node_modules/@salesforce/dev-scripts
              dev @salesforce/dev-scripts@"^10" from the root project
        @typescript-eslint/utils@"6.21.0" from @typescript-eslint/[email protected]
        node_modules/@typescript-eslint/type-utils
          @typescript-eslint/type-utils@"6.21.0" from @typescript-eslint/[email protected]
          node_modules/@typescript-eslint/eslint-plugin
            @typescript-eslint/eslint-plugin@"^6.21.0" from [email protected]
            node_modules/eslint-config-salesforce-typescript
              eslint-config-salesforce-typescript@"^3.3.0" from @salesforce/[email protected]
              node_modules/@salesforce/dev-scripts
                dev @salesforce/dev-scripts@"^10" from the root project
    ts-api-utils@"^1.0.1" from @typescript-eslint/[email protected]
    node_modules/@typescript-eslint/type-utils
      @typescript-eslint/type-utils@"6.21.0" from @typescript-eslint/[email protected]
      node_modules/@typescript-eslint/eslint-plugin
        @typescript-eslint/eslint-plugin@"^6.21.0" from [email protected]
        node_modules/eslint-config-salesforce-typescript
          eslint-config-salesforce-typescript@"^3.3.0" from @salesforce/[email protected]
          node_modules/@salesforce/dev-scripts
            dev @salesforce/dev-scripts@"^10" from the root project
  peer typescript@">=2.7" from [email protected]
  node_modules/ts-node
    dev ts-node@"^10.9.2" from the root project
    ts-node@"^10.8.1" from @commitlint/[email protected]
    node_modules/@commitlint/load
      @commitlint/load@"^17.8.1" from @commitlint/[email protected]
      node_modules/@commitlint/cli
        @commitlint/cli@"^17.1.2" from @salesforce/[email protected]
        node_modules/@salesforce/dev-scripts
          dev @salesforce/dev-scripts@"^10" from the root project
    ts-node@"^10.9.2" from @salesforce/[email protected]
    node_modules/@salesforce/dev-scripts
      dev @salesforce/dev-scripts@"^10" from the root project
    peer ts-node@">=10" from [email protected]
    node_modules/@commitlint/load/node_modules/cosmiconfig-typescript-loader
      cosmiconfig-typescript-loader@"^4.0.0" from @commitlint/[email protected]
      node_modules/@commitlint/load
        @commitlint/load@"^17.8.1" from @commitlint/[email protected]
        node_modules/@commitlint/cli
          @commitlint/cli@"^17.1.2" from @salesforce/[email protected]
          node_modules/@salesforce/dev-scripts
            dev @salesforce/dev-scripts@"^10" from the root project
  typescript@"~5.4.2" from [email protected]
  node_modules/ts-json-schema-generator
    ts-json-schema-generator@"^1.5.1" from @oclif/[email protected]
    node_modules/@oclif/plugin-command-snapshot
      dev @oclif/plugin-command-snapshot@"^5.1.9" from the root project
  peer typescript@"4.6.x || 4.7.x || 4.8.x || 4.9.x || 5.0.x || 5.1.x || 5.2.x || 5.3.x || 5.4.x" from [email protected]
  node_modules/typedoc
    typedoc@"^0.25.12" from @salesforce/[email protected]
    node_modules/@salesforce/dev-scripts
      dev @salesforce/dev-scripts@"^10" from the root project
  typescript@"^4.6.4 || ^5.2.2" from @commitlint/[email protected]
  node_modules/@commitlint/load
    @commitlint/load@"^17.8.1" from @commitlint/[email protected]
    node_modules/@commitlint/cli
      @commitlint/cli@"^17.1.2" from @salesforce/[email protected]
      node_modules/@salesforce/dev-scripts
        dev @salesforce/dev-scripts@"^10" from the root project
  typescript@"^5.4.3" from @salesforce/[email protected]
  node_modules/@salesforce/dev-scripts
    dev @salesforce/dev-scripts@"^10" from the root project
  peerOptional typescript@">=4.9.5" from [email protected]
  node_modules/@commitlint/load/node_modules/cosmiconfig
    cosmiconfig@"^8.0.0" from @commitlint/[email protected]
    node_modules/@commitlint/load
      @commitlint/load@"^17.8.1" from @commitlint/[email protected]
      node_modules/@commitlint/cli
        @commitlint/cli@"^17.1.2" from @salesforce/[email protected]
        node_modules/@salesforce/dev-scripts
          dev @salesforce/dev-scripts@"^10" from the root project
    peer cosmiconfig@">=7" from [email protected]
    node_modules/@commitlint/load/node_modules/cosmiconfig-typescript-loader
      cosmiconfig-typescript-loader@"^4.0.0" from @commitlint/[email protected]
      node_modules/@commitlint/load
        @commitlint/load@"^17.8.1" from @commitlint/[email protected]
        node_modules/@commitlint/cli
          @commitlint/cli@"^17.1.2" from @salesforce/[email protected]
          node_modules/@salesforce/dev-scripts
            dev @salesforce/dev-scripts@"^10" from the root project
  peer typescript@">=4" from [email protected]
  node_modules/@commitlint/load/node_modules/cosmiconfig-typescript-loader
    cosmiconfig-typescript-loader@"^4.0.0" from @commitlint/[email protected]
    node_modules/@commitlint/load
      @commitlint/load@"^17.8.1" from @commitlint/[email protected]
      node_modules/@commitlint/cli
        @commitlint/cli@"^17.1.2" from @salesforce/[email protected]
        node_modules/@salesforce/dev-scripts
          dev @salesforce/dev-scripts@"^10" from the root project
  peerOptional typescript@">=4.9.5" from [email protected]
  node_modules/@salesforce/dev-scripts/node_modules/cosmiconfig
    cosmiconfig@"^8.3.6" from @salesforce/[email protected]
    node_modules/@salesforce/dev-scripts
      dev @salesforce/dev-scripts@"^10" from the root project

@cristiand391
Copy link
Member

Would it be possible to add some variable in your script allowing to skip the typescript check ? I don't think I'll be able to get rid of it :/

yes, we added it for one of our eslint rules that ship TS, you can skip the check by setting skipTsDepCheck to true in the linux-unit-tests workflow like this:

https://github.com/salesforcecli/eslint-plugin-sf-plugin/blob/50072f8ccee2cd2585913ede52ac85d04d51407a/.github/workflows/test.yml#L10-L14

if: ${{ inputs.skipTsDepCheck == false }}

@cristiand391
Copy link
Member

I upgraded to the latest @salesforce/plugin-core , but... it does not accept the property flags on classes, even the hello/world.ts command of plugin is crying :/

I can see the errors on latest commit:
yarn tsc -p . --pretty --incremental
commit: d1de9e49e5e4c0e2f0e96551cf7de8562200138f

Screenshot 2024-09-02 at 8 20 14 PM

the error suggested it was likely a version mismatch between the versions of oclif/core and salesforce/core you have in your dependencies and what sf-plugins-core expected, after bumping both I can compile with tsc:
Screenshot 2024-09-02 at 8 22 31 PM

@nvuillam
Copy link
Author

nvuillam commented Sep 3, 2024

@cristiand391 thanks a lot for your investigations :)

But I still can't compile transpile :(

I reverted my commit, then:

  • tried to update only @oclif/core and @salesforce/core like on your example -> multiple errors
  • also update @salesforce/plugins-core

image

I find it's kind of strange to have to struggle to make the dependencies match... maybe there could be a way to embed all of them behind @salesforce/plugins-core and get the related types from there ?

image

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants
@cristiand391 @nvuillam @iam-py-test and others