Giter VIP home page Giter VIP logo

pnpm-sync's Issues

pnpm-sync-lib should provide a synchronous API to validate the content of .pnpm-sync.json

For integration with Rush, best practice with .pnpm-sync.json files would be to read them all up front before execution starts, validate that the files have the expected versions, and then error out early.

This helps clean up the logging output by reporting configuration errors with .pnpm-sync at the start of the process, rather than partway through a build. In the current configuration, the logging output can get buried when there are a large number of projects, e.g.

==[ FAILURE: 2 operations ]====================================================

--[ FAILURE: @rushstack/eslint-patch (build) ]--------------[ 14.38 seconds ]--


--[ FAILURE: @rushstack/tree-pattern (build) ]---------------[ 2.98 seconds ]--



Operations failed.

rush build (14.53 seconds)

[pnpm-sync-lib] Improve approach to console logging

From https://github.com/microsoft/rushstack/pull/4530/files#r1504932679:

image

  1. Also I would suggest to improve the formatting of the message:

    pnpm-sync: Copied 107 files in 95ms from C:\Git\rushstack\libraries\terminal
    
  2. It seems pnpmSyncCopy() is printing this message directly to the console. We should improve the API to provide a messaging callback that allows the output to be redirected and (ideally) optionally reformatted. Something like this:

    pnpmSyncCopy({
      pnpmSyncJsonPath,
      messageCallback: ({ message, messageKind: 'error'|'warning'|'info'|'verbose'|'timing', messageId, details }) => {
        if (messageKind === 'verbose' && !debug) {
          return;
        }
        switch (messageId) {
          case 'sync-finished':
            // customized logging; the structure of details can depend on messageId
            terminal.writeLine(colors.green('pnpm-sync') 
              + ` copied ${details.fileCount} files in ${details.totalMs} ms from ${details.sourcePath}`);
            break;
          default:
            // simple preformatted logging
            if (messageKind === 'error' | messageKind === 'warning') {
              console.error(message);
            } else {
              console.log(message);
            }
            break;
        }
      }
    })

    This would ensure that Rush (and in the future PNPM) has full ownership of its CLI UX.

`.pnpm-sync.json` should be versioned.

The .pnpm-sync.json file should contain a version field so it can be invalidated and regenerated if its schema changes between versions of the pnpm-sync-lib packages, or if an issue is identified and fixed.

I'm seeing an issue on my current local clone of https://github.com/microsoft/rushstack, where the build-tests-subspace/typescript-v4-test/node_modules/@rushstack/heft folder is linked to the wrong location (see screenshot below) because the sourceFolder property was generated with the wrong value.

The .pnpm-sync.json file should have been regenerated after the bug creating the incorrect path was fixed, and that would have been easily identified if it contained a version field.

apps/heft/node_modules/.pnpm-sync.json:

{
  "postbuildInjectedCopy": {
    "sourceFolder": "../..",
    "targetFolders": [
      {
        "folderPath": "../../../../common/temp/node_modules/.pnpm/file+..+..+apps+heft/node_modules/@rushstack/heft"
      },
      {
        "folderPath": "../../../common/temp/build-tests-subspace/node_modules/.pnpm/file+..+..+..+apps+heft_@[email protected]/node_modules/@rushstack/heft"
      }
    ]
  }
}

build-tests-subspace/typescript-v4-test/node_modules/@rushstack/heft structure:
image

pnpm-sync-lib should allow callers to directly provide the content of .pnpm-sync.json

Existence checking a file before reading it (especially asynchronously) allows for the existence of the file to change between the two file system calls. Additionally, for integration with Rush multi-phase builds, the sync file contents will not change between phases in the same project, and thus by allowing the content to be passed directly, we can avoid duplicate reads when pnpm-sync will be called after each phase.

As an example, the rushstack repository has phases build and test for all projects.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.