salesforcecli / github-workflows

reusable shared CI scripts
BSD 3-Clause "New" or "Revised" License
15 stars 8 forks source link

job prevent-typescript-dependency error #127

Open nvuillam opened 3 months ago

nvuillam commented 3 months ago

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 "typescript@5.4.5"
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 commented 3 months ago

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

iam-py-test commented 3 months ago

@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 commented 3 months ago

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
typescript@5.4.5
node_modules/typescript
  dev typescript@"^5.4.5" from the root project
  peerOptional typescript@">=4.9.5" from cosmiconfig@9.0.0
  node_modules/cosmiconfig
    cosmiconfig@"^9.0.0" from the root project
    cosmiconfig@"^9.0.0" from puppeteer@23.2.0
    node_modules/puppeteer
      puppeteer@"^23.2.0" from the root project
    cosmiconfig@"^9.0.0" from @oclif/core@4.0.3
    node_modules/@oclif/core
      @oclif/core@"^4" from the root project
      @oclif/core@"^4" from @salesforce/sf-plugins-core@10.0.0
      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): https://github.com/oclif/core/pull/1108

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

nvuillam commented 3 months ago

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

nvuillam commented 3 months ago

@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 commented 3 months ago

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
typescript@5.4.5
node_modules/typescript
  dev typescript@"^5.4.5" from the root project
  peerOptional typescript@">=4.9.5" from cosmiconfig@9.0.0
  node_modules/cosmiconfig
    cosmiconfig@"^9.0.0" from the root project
    cosmiconfig@"^9.0.0" from puppeteer@23.2.0
    node_modules/puppeteer
      puppeteer@"^23.2.0" from the root project
    cosmiconfig@"^9.0.0" from @oclif/core@4.0.3
    node_modules/@oclif/core
      @oclif/core@"^4" from the root project
      @oclif/core@"^4" from oclif@4.14.0
      node_modules/oclif
        dev oclif@"^4.14.0" from the root project
      @oclif/core@"^4" from @oclif/plugin-warn-if-update-available@3.1.8
      node_modules/@oclif/plugin-warn-if-update-available
        @oclif/plugin-warn-if-update-available@"^3.0.19" from oclif@4.14.0
        node_modules/oclif
          dev oclif@"^4.14.0" from the root project
      @oclif/core@"^4" from @oclif/plugin-not-found@3.2.10
      node_modules/@oclif/plugin-not-found
        @oclif/plugin-not-found@"^3.2.3" from oclif@4.14.0
        node_modules/oclif
          dev oclif@"^4.14.0" from the root project
      @oclif/core@"^4" from @oclif/plugin-help@6.2.5
      node_modules/@oclif/plugin-help
        @oclif/plugin-help@"^6.2.2" from oclif@4.14.0
        node_modules/oclif
          dev oclif@"^4.14.0" from the root project
    cosmiconfig@"*" from @types/cosmiconfig@6.0.0
    node_modules/@types/cosmiconfig
      dev @types/cosmiconfig@"^6.0.0" from the root project
  peer typescript@">=4.2.0" from ts-api-utils@1.0.3
  node_modules/ts-api-utils
    ts-api-utils@"^1.0.1" from @typescript-eslint/eslint-plugin@6.21.0
    node_modules/@typescript-eslint/eslint-plugin
      @typescript-eslint/eslint-plugin@"^6.21.0" from eslint-config-salesforce-typescript@3.3.0
      node_modules/eslint-config-salesforce-typescript
        eslint-config-salesforce-typescript@"^3.3.0" from @salesforce/dev-scripts@10.1.0
        node_modules/@salesforce/dev-scripts
          dev @salesforce/dev-scripts@"^10" from the root project
    ts-api-utils@"^1.0.1" from @typescript-eslint/typescript-estree@6.21.0
    node_modules/@typescript-eslint/typescript-estree
      @typescript-eslint/typescript-estree@"6.21.0" from @typescript-eslint/parser@6.21.0
      node_modules/@typescript-eslint/parser
        @typescript-eslint/parser@"^6.21.0" from eslint-config-salesforce-typescript@3.3.0
        node_modules/eslint-config-salesforce-typescript
          eslint-config-salesforce-typescript@"^3.3.0" from @salesforce/dev-scripts@10.1.0
          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/eslint-plugin@6.21.0
        node_modules/@typescript-eslint/eslint-plugin
          @typescript-eslint/eslint-plugin@"^6.21.0" from eslint-config-salesforce-typescript@3.3.0
          node_modules/eslint-config-salesforce-typescript
            eslint-config-salesforce-typescript@"^3.3.0" from @salesforce/dev-scripts@10.1.0
            node_modules/@salesforce/dev-scripts
              dev @salesforce/dev-scripts@"^10" from the root project
      @typescript-eslint/typescript-estree@"6.21.0" from @typescript-eslint/type-utils@6.21.0
      node_modules/@typescript-eslint/type-utils
        @typescript-eslint/type-utils@"6.21.0" from @typescript-eslint/eslint-plugin@6.21.0
        node_modules/@typescript-eslint/eslint-plugin
          @typescript-eslint/eslint-plugin@"^6.21.0" from eslint-config-salesforce-typescript@3.3.0
          node_modules/eslint-config-salesforce-typescript
            eslint-config-salesforce-typescript@"^3.3.0" from @salesforce/dev-scripts@10.1.0
            node_modules/@salesforce/dev-scripts
              dev @salesforce/dev-scripts@"^10" from the root project
      @typescript-eslint/typescript-estree@"6.21.0" from @typescript-eslint/utils@6.21.0
      node_modules/@typescript-eslint/utils
        @typescript-eslint/utils@"^6.17.0" from eslint-plugin-sf-plugin@1.18.6
        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/eslint-plugin@6.21.0
        node_modules/@typescript-eslint/eslint-plugin
          @typescript-eslint/eslint-plugin@"^6.21.0" from eslint-config-salesforce-typescript@3.3.0
          node_modules/eslint-config-salesforce-typescript
            eslint-config-salesforce-typescript@"^3.3.0" from @salesforce/dev-scripts@10.1.0
            node_modules/@salesforce/dev-scripts
              dev @salesforce/dev-scripts@"^10" from the root project
        @typescript-eslint/utils@"6.21.0" from @typescript-eslint/type-utils@6.21.0
        node_modules/@typescript-eslint/type-utils
          @typescript-eslint/type-utils@"6.21.0" from @typescript-eslint/eslint-plugin@6.21.0
          node_modules/@typescript-eslint/eslint-plugin
            @typescript-eslint/eslint-plugin@"^6.21.0" from eslint-config-salesforce-typescript@3.3.0
            node_modules/eslint-config-salesforce-typescript
              eslint-config-salesforce-typescript@"^3.3.0" from @salesforce/dev-scripts@10.1.0
              node_modules/@salesforce/dev-scripts
                dev @salesforce/dev-scripts@"^10" from the root project
    ts-api-utils@"^1.0.1" from @typescript-eslint/type-utils@6.21.0
    node_modules/@typescript-eslint/type-utils
      @typescript-eslint/type-utils@"6.21.0" from @typescript-eslint/eslint-plugin@6.21.0
      node_modules/@typescript-eslint/eslint-plugin
        @typescript-eslint/eslint-plugin@"^6.21.0" from eslint-config-salesforce-typescript@3.3.0
        node_modules/eslint-config-salesforce-typescript
          eslint-config-salesforce-typescript@"^3.3.0" from @salesforce/dev-scripts@10.1.0
          node_modules/@salesforce/dev-scripts
            dev @salesforce/dev-scripts@"^10" from the root project
  peer typescript@">=2.7" from ts-node@10.9.2
  node_modules/ts-node
    dev ts-node@"^10.9.2" from the root project
    ts-node@"^10.8.1" from @commitlint/load@17.8.1
    node_modules/@commitlint/load
      @commitlint/load@"^17.8.1" from @commitlint/cli@17.8.1
      node_modules/@commitlint/cli
        @commitlint/cli@"^17.1.2" from @salesforce/dev-scripts@10.1.0
        node_modules/@salesforce/dev-scripts
          dev @salesforce/dev-scripts@"^10" from the root project
    ts-node@"^10.9.2" from @salesforce/dev-scripts@10.1.0
    node_modules/@salesforce/dev-scripts
      dev @salesforce/dev-scripts@"^10" from the root project
    peer ts-node@">=10" from cosmiconfig-typescript-loader@4.4.0
    node_modules/@commitlint/load/node_modules/cosmiconfig-typescript-loader
      cosmiconfig-typescript-loader@"^4.0.0" from @commitlint/load@17.8.1
      node_modules/@commitlint/load
        @commitlint/load@"^17.8.1" from @commitlint/cli@17.8.1
        node_modules/@commitlint/cli
          @commitlint/cli@"^17.1.2" from @salesforce/dev-scripts@10.1.0
          node_modules/@salesforce/dev-scripts
            dev @salesforce/dev-scripts@"^10" from the root project
  typescript@"~5.4.2" from ts-json-schema-generator@1.5.1
  node_modules/ts-json-schema-generator
    ts-json-schema-generator@"^1.5.1" from @oclif/plugin-command-snapshot@5.1.9
    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 typedoc@0.25.13
  node_modules/typedoc
    typedoc@"^0.25.12" from @salesforce/dev-scripts@10.1.0
    node_modules/@salesforce/dev-scripts
      dev @salesforce/dev-scripts@"^10" from the root project
  typescript@"^4.6.4 || ^5.2.2" from @commitlint/load@17.8.1
  node_modules/@commitlint/load
    @commitlint/load@"^17.8.1" from @commitlint/cli@17.8.1
    node_modules/@commitlint/cli
      @commitlint/cli@"^17.1.2" from @salesforce/dev-scripts@10.1.0
      node_modules/@salesforce/dev-scripts
        dev @salesforce/dev-scripts@"^10" from the root project
  typescript@"^5.4.3" from @salesforce/dev-scripts@10.1.0
  node_modules/@salesforce/dev-scripts
    dev @salesforce/dev-scripts@"^10" from the root project
  peerOptional typescript@">=4.9.5" from cosmiconfig@8.3.6
  node_modules/@commitlint/load/node_modules/cosmiconfig
    cosmiconfig@"^8.0.0" from @commitlint/load@17.8.1
    node_modules/@commitlint/load
      @commitlint/load@"^17.8.1" from @commitlint/cli@17.8.1
      node_modules/@commitlint/cli
        @commitlint/cli@"^17.1.2" from @salesforce/dev-scripts@10.1.0
        node_modules/@salesforce/dev-scripts
          dev @salesforce/dev-scripts@"^10" from the root project
    peer cosmiconfig@">=7" from cosmiconfig-typescript-loader@4.4.0
    node_modules/@commitlint/load/node_modules/cosmiconfig-typescript-loader
      cosmiconfig-typescript-loader@"^4.0.0" from @commitlint/load@17.8.1
      node_modules/@commitlint/load
        @commitlint/load@"^17.8.1" from @commitlint/cli@17.8.1
        node_modules/@commitlint/cli
          @commitlint/cli@"^17.1.2" from @salesforce/dev-scripts@10.1.0
          node_modules/@salesforce/dev-scripts
            dev @salesforce/dev-scripts@"^10" from the root project
  peer typescript@">=4" from cosmiconfig-typescript-loader@4.4.0
  node_modules/@commitlint/load/node_modules/cosmiconfig-typescript-loader
    cosmiconfig-typescript-loader@"^4.0.0" from @commitlint/load@17.8.1
    node_modules/@commitlint/load
      @commitlint/load@"^17.8.1" from @commitlint/cli@17.8.1
      node_modules/@commitlint/cli
        @commitlint/cli@"^17.1.2" from @salesforce/dev-scripts@10.1.0
        node_modules/@salesforce/dev-scripts
          dev @salesforce/dev-scripts@"^10" from the root project
  peerOptional typescript@">=4.9.5" from cosmiconfig@8.3.6
  node_modules/@salesforce/dev-scripts/node_modules/cosmiconfig
    cosmiconfig@"^8.3.6" from @salesforce/dev-scripts@10.1.0
    node_modules/@salesforce/dev-scripts
      dev @salesforce/dev-scripts@"^10" from the root project
cristiand391 commented 3 months ago

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

https://github.com/salesforcecli/github-workflows/blob/c79b9ba642348bc928b970429d7aa4de09cba6ad/.github/workflows/unitTestsLinux.yml#L24

cristiand391 commented 3 months ago

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 commented 3 months ago

@cristiand391 thanks a lot for your investigations :)

But I still can't compile transpile :(

I reverted my commit, then:

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