Giter Club home page Giter Club logo

workspace-tools's Introduction

workspace-tools monorepo

Please see the workspace-tools README for more information.

Contributing

This project welcomes contributions and suggestions. Most contributions require you to agree to a Contributor License Agreement (CLA) declaring that you have the right to, and actually do, grant us the rights to use your contribution. For details, visit https://cla.opensource.microsoft.com.

When you submit a pull request, a CLA bot will automatically determine whether you need to provide a CLA and decorate the PR appropriately (e.g., status check, comment). Simply follow the instructions provided by the bot. You will only need to do this once across all repos using our CLA.

This project has adopted the Microsoft Open Source Code of Conduct. For more information see the Code of Conduct FAQ or contact [email protected] with any additional questions or comments.

workspace-tools's People

Contributors

abdoumoumen avatar akimalunar avatar asmundg avatar bilgedenizkocakk avatar bweggersen avatar dannyfritz avatar dannyvv avatar dependabot[bot] avatar dlannoye avatar dzearing avatar ecraig12345 avatar eren-murat avatar fcaminada avatar jaredpalmer avatar kenotron avatar nickymunga avatar renovate[bot] avatar sstchur avatar tido64 avatar vilaemail avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

workspace-tools's Issues

support yarn version 2

Projects which use Yarn version 2 are facing caching issue with lage because there is a logical dependency of parsing yarn lock file in workspace-tools. current workspace-tools can only parse lock files of yarn version 1, it breaks for yarn version 2 lock files.

#microsoft/lage#129

Action Required: Fix Renovate Configuration

There is an error with this repository's Renovate configuration that needs to be fixed. As a precaution, Renovate will stop PRs until it is resolved.

Error type: Cannot find preset's package (github>microsoft/m365-renovate-config:autoUpdateTypes)

getPackagePaths.js is requiring fast-glob but the latter is not a dev dependency

$ react-native rnx-bundle --dev false
info Bundling macos...
Welcome to Metro!
Fast - Scalable - Integrated

Failed to construct transformer: Error: Cannot find module 'fast-glob'
Require stack:

  • C:\Users\avipie\Repos\1JS\src\ooui.store\[email protected]\node_modules\workspace-tools\lib\getPackagePaths.js
  • C:\Users\avipie\Repos\1JS\src\ooui.store\[email protected]\node_modules\workspace-tools\lib\workspaces\implementations\pnpm.js
  • C:\Users\avipie\Repos\1JS\src\ooui.store\[email protected]\node_modules\workspace-tools\lib\index.js

Split workspace-tools package

To reduce the number of dependencies (and possible vulnerabilities) pulled in by other tools/packages that use workspace-tools, we'd like to split the package into more granular parts.

Possible parts include:

  • workspace-tools-git: git utilities (#179)
  • workspace-tools-paths: path utilities (#179)
  • workspace-tools-types: shared types such as PackageInfo
  • workspace-tools-graph: package dependency graph
  • others TBD: lock file parsing, getting workspace info, ?

Possible infinite loop in searchUp

When searchUp is passed a relative path or a path that doesn't start with /, e.g. the/path/to/a/start/point and the filePath is not found an infinite loop results.

Why

13  const root = path.parse(cwd).root;

root is set to "" and in

23 cwd = path.dirname(cwd)

at the last point of the path cwd is set to "."

"." never equals "" and the loop doesn't exit

Possible solution

  • Add a leading / to cwds passed in without it just for the loop's case

git.getUntrackedChanges() is not being parsed correctly

I'm using lage and trying to use the ignore field in the configuration.

Anyways, the error I'm seeing is the parser for git.getUntrackedChanges() is not working as expected.

In my repo, I modify 2 files (that are tracked already) and end up with [ 'README.md\n M lage.config.js' ] here.

Expected: []
Got: [ 'README.md\n M lage.config.js' ]

So it ends up causing lage to think every package has changed and it builds everything in the repo when I modify the README.md file at the root.

Some details:

node: 14.17.4
workspace-tools: 0.18.2
git: 2.35.1
OSX: 12.2.1
daniel.fritz ~/Dev/splat (master !$)
% git status --short
 M README.md
 M lage.config.js

daniel.fritz ~/Dev/splat (master !$)
% git status
On branch master
Your branch is up to date with 'origin/master'.

Changes not staged for commit:
  (use "git add <file>..." to update what will be committed)
  (use "git restore <file>..." to discard changes in working directory)
        modified:   README.md
        modified:   lage.config.js

no changes added to commit (use "git add" and/or "git commit -a")

daniel.fritz ~/Dev/splat (master !$)
%

Drop weighty dependencies to keep subsequent libraries light

Currently, the bulk of the dependencies come from the various lock file api's. They amount to nothing but two kinds of things:

  1. finding the right lock file with a find-up style convention
  2. parsing yaml
  3. stuffing the info obtained into a in-memory collection

I believe we can achieve these with much fewer dependencies so this library isn't so heavy

Should createDependencyMap be available?

It seems that the function createDependencyMap is not exported properly. I tried to use it in teams-modular-packages and I had to add an export statement for it locally. How can this be solved?

Security concern - fetch can accidentally allow users of the lib to allow command injection

git fetch has an extra parameter you could potentially use that executes arbitrary commands: --upload-pack. The issue is here:

const results = git(["fetch", remote], { cwd });

and

const results = git(["fetch", remote, remoteBranch], { cwd });

Fix is to add a -- in the arg list like this: fetch -- remote remotebranch. This may not be a big deal, but it has come up as a security issue with other git wrapper libs.

Version 1.0 planning doc

Overview

workspace-tools had been used by some of the key monorepo scripts & tools that manage some of the large Microsoft JS projects. This library really came from merging tooling from these repos: backfill, beachball, just-scripts, and lage.

Problems of v0.x

The library has these characteristics & problems:

  • the library is a LOOSELY defined set of functions surrounding getting workspace information and related git operations
  • the additions to the library are mainly static functions, not classes
  • some functions attempt to do caching but without standard ways to invalidate cache
  • ALL functions are synchronous ๐Ÿ‘Ž๐Ÿผ
  • packageInfos and workspaces are loosely used between different functions as the "state" to be passed between functions - these are not used consistently

Proposal

Goals

  1. API surface should be designed ahead of time before implementation
  2. No external dependencies (lockfiles implementation, etc. should be implemented JUST enough to gather the information needed)
  3. Prefer library calls over spawning processes
  4. Asynchronous and Synchronous API surface
  5. Leverage NAPI if it makes the operation fast
  6. Split repo into monorepo to clearly delineate different aspects of workspace-tools - e.g. git, lockfile, filtering (#229)

fetchRemoteBranch fails if using an SSH key with a passphrase to authenticate to remote

When trying to use beachball to generate a change file, I saw that the call to fetch changes from the upstream repo was failing in the call to the fetchRemoteBranch in workspace-tools:

Checking for changes against "origin/main"
fetching latest from remotes "origin/main"
beachball v2.16.0 - the sunniest version bumping tool
An error has been detected while running beachball!
Error: Cannot fetch remote: origin main
    at Object.fetchRemoteBranch (C:\code\react-native-windows\node_modules\beachball\node_modules\workspace-tools\lib\git.js:109:15)

However, removing the passphrase from the SSH key I used to authenticate to the origin remote repo fixes the command. It seems the the fetchRemoteBranch command fails when the git CLI prompts for the key passphrase.

Doesn't execute commands in all packages unless -p is provided

I have a yarn 2 monorepo with two packages, spe and editor; editor depends on spe:

$ yarn workspaces list --verbose --json
{"location":".","name":null,"workspaceDependencies":[],"mismatchedWorkspaceDependencies":[]}
{"location":"packages/editor","name":"spline-app","workspaceDependencies":["packages/spe"],"mismatchedWorkspaceDependencies":[]}
{"location":"packages/spe","name":"spe","workspaceDependencies":[],"mismatchedWorkspaceDependencies":[]}

I added a "hello" script to each package that just prints which package we are in:

packages/editor/package.json:

{...
        "name": "editor",
	"private": true,
	"scripts": {
		"hello": "echo hello from editor",
...
	},
	"dependencies": {
		"spe": "workspace:*",
...
	},
}

packages/spe/package.json:

{
	"name": "spe",
	"version": "0.3.0",
	"scripts": {
		"hello": "echo hello from spe",
...
	},
}

Running yarn workspaces foreach -t run hello I would expect both scripts to run, spe first. Instead This is the result:

yarn workspaces foreach -t run hello
โžค YN0000: hello from spe

the -A flag does not change anything about this. With -R no scripts are run at all. Only with -ip and -p do both packages run, but they run concurrently and so this is useless for the case of building packages.

What is going on here?

Dependency Dashboard

This issue lists Renovate updates and detected dependencies. Read the Dependency Dashboard docs to learn more.

Pending Approval

These branches will be created by Renovate only once you click their checkbox below.

  • Update devDependency typescript to ~5.4.0
  • Update actions/checkout action to v4
  • Update actions/setup-node action to v4
  • Update dependency commander to v12
  • Update dependency git-url-parse to v14
  • ๐Ÿ” Create all pending approval PRs at once ๐Ÿ”

Open

These updates have all been created already. Click a checkbox below to force a retry/rebase of any.

Detected dependencies

github-actions
.github/workflows/pr.yml
  • actions/checkout v3
  • actions/setup-node v3
.github/workflows/release.yml
  • actions/checkout v3
  • actions/setup-node v3
npm
package.json
  • @microsoft/api-extractor ^7.34.9
  • @types/fs-extra ^11.0.0
  • @types/git-url-parse ^9.0.1
  • @types/jest ^29.5.1
  • @types/jju ^1.4.2
  • @types/js-yaml ^4.0.5
  • @types/micromatch ^4.0.2
  • @types/node ^16.0.0
  • @types/tmp ^0.2.3
  • @types/yarnpkg__lockfile ^1.1.5
  • @types/lodash ^4.14.194
  • beachball ^2.31.12
  • cross-env ^7.0.3
  • fs-extra ^11.0.0
  • gh-pages ^6.0.0
  • jest ^29.5.0
  • lage ^2.6.2
  • prettier ^3.0.0
  • tmp ^0.2.1
  • ts-jest ^29.1.0
  • typedoc ^0.25.2
  • typescript ~5.2.2
packages/grapher/package.json
  • commander ^11.1.0
  • @types/node ^16.0.0
  • lodash ^4.17.21
packages/workspace-tools/package.json
  • @yarnpkg/lockfile ^1.1.0
  • fast-glob ^3.3.1
  • git-url-parse ^13.0.0
  • globby ^11.0.0
  • jju ^1.4.0
  • js-yaml ^4.1.0
  • micromatch ^4.0.0
  • lodash ^4.17.21
scripts/package.json
nvm
.nvmrc
  • node 16

  • Check this box to trigger a request for Renovate to run again on this repository

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.