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

chore(publish): improve with upcoming changesets workspace support #222

Open
wants to merge 11 commits into
base: main
Choose a base branch
from
8 changes: 8 additions & 0 deletions .changeset/large-bears-try.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
---
'@soluble/cache-interop': patch
'@soluble/cache-ioredis': patch
'@soluble/cache-redis': patch
'@soluble/dsn-parser': patch
---

Remove publish hack in favour of https://github.com/atlassian/changesets/pull/674
14 changes: 14 additions & 0 deletions .changeset/pre.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
{
"mode": "pre",
"tag": "canary",
"initialVersions": {
"@soluble/cache-e2e-tests": "0.8.1",
"@soluble/cache-interop": "0.8.1",
"@soluble/cache-ioredis": "0.8.3",
"@soluble/cache-redis": "0.8.3",
"@soluble/dsn-parser": "1.3.2"
},
"changesets": [
"large-bears-try"
]
}
17 changes: 13 additions & 4 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -47,9 +47,20 @@ jobs:
restore-keys: |
yarn-cache-folder-

# TEMPORARY JUST TO TEST OUT https://github.com/atlassian/changesets/pull/674
- uses: actions/checkout@v2
with:
repository: atlassian/changesets
path: ${{ github.workspace }}/tmp/changesets
ref: publish-refactor

# TEMPORARY JUST TO TEST OUT https://github.com/atlassian/changesets/pull/674
- name: Install dependencies
run: |
yarn install --immutable
yarn install --immutable || cat /tmp/xfs*/*.log
env:
HACK_CHANGESET_DIR: ${{ github.workspace }}/tmp/changesets
SKIP_CLONE_CHANGESET_REPO: 1

- name: Linter
run: |
Expand Down Expand Up @@ -85,9 +96,7 @@ jobs:
bash <(curl -s https://codecov.io/bash) -F e2e -s ./packages/cache-e2e-tests/coverage

- name: Build (only changed)
# Till https://github.com/atlassian/changesets/issues/432 has a solution we can remove the
# build-publishable-release and replace with a regular build command
run: |
yarn workspaces foreach --topological --since=origin/main --recursive run build-publishable-release
yarn workspaces foreach --topological --since=origin/main --recursive run build


35 changes: 35 additions & 0 deletions .yarn/plugins/@yarnpkg/plugin-exec.cjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
/* eslint-disable */
//prettier-ignore
module.exports = {
name: "@yarnpkg/plugin-exec",
factory: function (require) {
var plugin=(()=>{var V=Object.create,d=Object.defineProperty,_=Object.defineProperties,G=Object.getOwnPropertyDescriptor,z=Object.getOwnPropertyDescriptors,J=Object.getOwnPropertyNames,j=Object.getOwnPropertySymbols,Y=Object.getPrototypeOf,S=Object.prototype.hasOwnProperty,B=Object.prototype.propertyIsEnumerable;var U=(r,e,t)=>e in r?d(r,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):r[e]=t,u=(r,e)=>{for(var t in e||(e={}))S.call(e,t)&&U(r,t,e[t]);if(j)for(var t of j(e))B.call(e,t)&&U(r,t,e[t]);return r},T=(r,e)=>_(r,z(e)),K=r=>d(r,"__esModule",{value:!0});var C=(r,e)=>{for(var t in e)d(r,t,{get:e[t],enumerable:!0})},Q=(r,e,t)=>{if(e&&typeof e=="object"||typeof e=="function")for(let a of J(e))!S.call(r,a)&&a!=="default"&&d(r,a,{get:()=>e[a],enumerable:!(t=G(e,a))||t.enumerable});return r},h=r=>Q(K(d(r!=null?V(Y(r)):{},"default",r&&r.__esModule&&"default"in r?{get:()=>r.default,enumerable:!0}:{value:r,enumerable:!0})),r);var Z={};C(Z,{default:()=>te,execUtils:()=>y});var l=h(require("@yarnpkg/core")),O=h(require("@yarnpkg/core")),n=h(require("@yarnpkg/fslib"));var p="exec:";var y={};C(y,{loadGeneratorFile:()=>P,makeLocator:()=>x,makeSpec:()=>A,parseSpec:()=>v});var f=h(require("@yarnpkg/core")),c=h(require("@yarnpkg/fslib"));function v(r){let{params:e,selector:t}=f.structUtils.parseRange(r),a=c.npath.toPortablePath(t);return{parentLocator:e&&typeof e.locator=="string"?f.structUtils.parseLocator(e.locator):null,path:a}}function A({parentLocator:r,path:e,generatorHash:t,protocol:a}){let o=r!==null?{locator:f.structUtils.stringifyLocator(r)}:{},i=typeof t!="undefined"?{hash:t}:{};return f.structUtils.makeRange({protocol:a,source:e,selector:e,params:u(u({},i),o)})}function x(r,{parentLocator:e,path:t,generatorHash:a,protocol:o}){return f.structUtils.makeLocator(r,A({parentLocator:e,path:t,generatorHash:a,protocol:o}))}async function P(r,e,t){let{parentLocator:a,path:o}=f.structUtils.parseFileStyleRange(r,{protocol:e}),i=c.ppath.isAbsolute(o)?{packageFs:new c.CwdFS(c.PortablePath.root),prefixPath:c.PortablePath.dot,localPath:c.PortablePath.root}:await t.fetcher.fetch(a,t),s=i.localPath?{packageFs:new c.CwdFS(c.PortablePath.root),prefixPath:c.ppath.relative(c.PortablePath.root,i.localPath)}:i;i!==s&&i.releaseFs&&i.releaseFs();let g=s.packageFs,b=c.ppath.join(s.prefixPath,o);return await g.readFilePromise(b,"utf8")}var L=class{supports(e,t){return!!e.reference.startsWith(p)}getLocalPath(e,t){let{parentLocator:a,path:o}=l.structUtils.parseFileStyleRange(e.reference,{protocol:p});if(n.ppath.isAbsolute(o))return o;let i=t.fetcher.getLocalPath(a,t);return i===null?null:n.ppath.resolve(i,o)}async fetch(e,t){let a=t.checksums.get(e.locatorHash)||null,[o,i,s]=await t.cache.fetchPackageFromCache(e,a,u({onHit:()=>t.report.reportCacheHit(e),onMiss:()=>t.report.reportCacheMiss(e),loader:()=>this.fetchFromDisk(e,t),skipIntegrityCheck:t.skipIntegrityCheck},t.cacheOptions));return{packageFs:o,releaseFs:i,prefixPath:l.structUtils.getIdentVendorPath(e),localPath:this.getLocalPath(e,t),checksum:s}}async fetchFromDisk(e,t){let a=await P(e.reference,p,t);return n.xfs.mktempPromise(async o=>{let i=n.ppath.join(o,"generator.js");return await n.xfs.writeFilePromise(i,a),n.xfs.mktempPromise(async s=>{if(await this.generatePackage(s,e,i,t),!n.xfs.existsSync(n.ppath.join(s,"build")))throw new Error("The script should have generated a build directory");return await l.tgzUtils.makeArchiveFromDirectory(n.ppath.join(s,"build"),{prefixPath:l.structUtils.getIdentVendorPath(e),compressionLevel:t.project.configuration.get("compressionLevel")})})})}async generatePackage(e,t,a,o){return await n.xfs.mktempPromise(async i=>{let s=await l.scriptUtils.makeScriptEnv({project:o.project,binFolder:i}),g=n.ppath.join(e,"runtime.js");return await n.xfs.mktempPromise(async b=>{let E=n.ppath.join(b,"buildfile.log"),I=null,F=n.xfs.createWriteStream(E),W=F,R=n.ppath.join(e,"generator"),D=n.ppath.join(e,"build");await n.xfs.mkdirPromise(R),await n.xfs.mkdirPromise(D);let $={tempDir:n.npath.fromPortablePath(R),buildDir:n.npath.fromPortablePath(D),locator:l.structUtils.stringifyLocator(t)};await n.xfs.writeFilePromise(g,`
// Expose 'Module' as a global variable
Object.defineProperty(global, 'Module', {
get: () => require('module'),
configurable: true,
enumerable: false,
});

// Expose non-hidden built-in modules as global variables
for (const name of Module.builtinModules.filter((name) => name !== 'module' && !name.startsWith('_'))) {
Object.defineProperty(global, name, {
get: () => require(name),
configurable: true,
enumerable: false,
});
}

// Expose the 'execEnv' global variable
Object.defineProperty(global, 'execEnv', {
value: {
...${JSON.stringify($)},
},
enumerable: true,
});
`);let k=s.NODE_OPTIONS||"",q=/\s*--require\s+\S*\.pnp\.c?js\s*/g;k=k.replace(q," ").trim(),s.NODE_OPTIONS=k,F.write(`# This file contains the result of Yarn generating a package (${l.structUtils.stringifyLocator(t)})
`),F.write(`
`);let{code:M}=await l.execUtils.pipevp(process.execPath,["--require",n.npath.fromPortablePath(g),n.npath.fromPortablePath(a),l.structUtils.stringifyIdent(t)],{cwd:e,env:s,stdin:I,stdout:F,stderr:W});if(M!==0)throw n.xfs.detachTemp(b),new Error(`Package generation failed (exit code ${M}, logs can be found here: ${O.formatUtils.pretty(o.project.configuration,E,O.formatUtils.Type.PATH)})`)})})}};var N=h(require("@yarnpkg/core")),H=h(require("@yarnpkg/core")),m=h(require("@yarnpkg/core"));var X=2,w=class{supportsDescriptor(e,t){return!!e.range.startsWith(p)}supportsLocator(e,t){return!!e.reference.startsWith(p)}shouldPersistResolution(e,t){return!1}bindDescriptor(e,t,a){return m.structUtils.bindDescriptor(e,{locator:m.structUtils.stringifyLocator(t)})}getResolutionDependencies(e,t){return[]}async getCandidates(e,t,a){if(!a.fetchOptions)throw new Error("Assertion failed: This resolver cannot be used unless a fetcher is configured");let{path:o,parentLocator:i}=v(e.range);if(i===null)throw new Error("Assertion failed: The descriptor should have been bound");let s=await P(m.structUtils.makeRange({protocol:p,source:o,selector:o,params:{locator:m.structUtils.stringifyLocator(i)}}),p,a.fetchOptions),g=m.hashUtils.makeHash(`${X}`,s).slice(0,6);return[x(e,{parentLocator:i,path:o,generatorHash:g,protocol:p})]}async getSatisfying(e,t,a){return null}async resolve(e,t){if(!t.fetchOptions)throw new Error("Assertion failed: This resolver cannot be used unless a fetcher is configured");let a=await t.fetchOptions.fetcher.fetch(e,t.fetchOptions),o=await m.miscUtils.releaseAfterUseAsync(async()=>await N.Manifest.find(a.prefixPath,{baseFs:a.packageFs}),a.releaseFs);return T(u({},e),{version:o.version||"0.0.0",languageName:o.languageName||t.project.configuration.get("defaultLanguageName"),linkType:H.LinkType.HARD,conditions:o.getConditions(),dependencies:o.dependencies,peerDependencies:o.peerDependencies,dependenciesMeta:o.dependenciesMeta,peerDependenciesMeta:o.peerDependenciesMeta,bin:o.bin})}};var ee={fetchers:[L],resolvers:[w]},te=ee;return Z;})();
return plugin;
}
};
2 changes: 2 additions & 0 deletions .yarnrc.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,5 +16,7 @@ plugins:
spec: "@yarnpkg/plugin-interactive-tools"
- path: .yarn/plugins/@yarnpkg/plugin-constraints.cjs
spec: "@yarnpkg/plugin-constraints"
- path: .yarn/plugins/@yarnpkg/plugin-exec.cjs
spec: "@yarnpkg/plugin-exec"

yarnPath: .yarn/releases/yarn-3.2.0-rc.5.cjs
32 changes: 32 additions & 0 deletions bin/changeset-publish-refactor.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
// Temporary install of https://github.com/atlassian/changesets/pull/674
// atlassian/changesets#head=publish-refactor&workspace=@changesets/cli

const hackChangetsetsDir = process.env.HACK_CHANGESET_DIR;
const skipCloneRepo = process.env.SKIP_CLONE_CHANGESET_REPO === '1';

const pathToRepo = hackChangetsetsDir ? hackChangetsetsDir : path.join(execEnv.tempDir, 'changesets');
const pathToArchive = path.join(execEnv.tempDir, 'archive.tgz');
const pathToSubpackage = path.join(pathToRepo, 'packages/cli');

if (!skipCloneRepo) {
child_process.execFileSync(`git`, [
`clone`,
`-b`,
//`publish-refactor`,
//`[email protected]:atlassian/changesets.git`,
`publish-refactor-extra`,
`[email protected]:belgattitude/changesets.git`,
pathToRepo,
]);
//child_process.execFileSync(`git`, [`pull`]);
}

child_process.execFileSync(`yarn`, [`install`], { cwd: pathToRepo });
child_process.execFileSync(`yarn`, [`build`], { cwd: pathToRepo });

child_process.execFileSync(`yarn`, [`pack`, `--out`, pathToArchive], { cwd: pathToSubpackage });

// Send the package content into the build directory
child_process.execFileSync(`tar`, [`-x`, `-z`, `--strip-components=1`, `-f`, pathToArchive, `-C`, execEnv.buildDir]);

child_process.execFileSync(`rm`, [`-rf`], { cwd: pathToRepo });
8 changes: 4 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,15 +18,14 @@
},
"scripts": {
"postinstall": "is-ci || husky install",
"?build-publishable-release": "When https://github.com/atlassian/changesets/issues/432 has a solution we can remove this trick",
"build-publishable-release": "yarn workspaces foreach -tv run build-publishable-release",
"build": "yarn workspaces foreach -tv run build",
"clean": "yarn workspaces foreach -ptv run clean",
"test": "run-s 'test:*'",
"test:unit": "yarn workspaces foreach -ptv --exclude '@soluble/*e2e*' --exclude 'cache-interop-docs' run test:unit",
"test:e2e": "yarn clean && yarn workspaces foreach -ptv --include '@soluble/*e2e*' --exclude 'cache-interop-docs' run test:e2e",
"changeset": "changeset",
"version-packages": "changeset version",
"release": "yarn build-publishable-release && changeset publish",
"release": "yarn build && changeset publish",
"typecheck": "yarn workspaces foreach -ptv run typecheck",
"lint": "yarn workspaces foreach -ptv run lint",
"fix:staged": "yarn workspaces foreach -t run fix:staged",
Expand All @@ -48,9 +47,10 @@
},
"devDependencies": {
"@changesets/changelog-github": "0.4.1",
"@changesets/cli": "2.18.0",
"@changesets/cli": "exec:./bin/changeset-publish-refactor.js",
"@commitlint/cli": "15.0.0",
"@commitlint/config-conventional": "15.0.0",
"@preconstruct/cli": "1.1.26",
"@types/node": "16.11.10",
"@typescript-eslint/eslint-plugin": "5.4.0",
"@typescript-eslint/parser": "5.4.0",
Expand Down
6 changes: 6 additions & 0 deletions packages/cache-interop/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
# @soluble/cache-interop

## 0.8.2-canary.0

### Patch Changes

- [#222](https://github.com/soluble-io/cache-interop/pull/222) [`2a58d22`](https://github.com/soluble-io/cache-interop/commit/2a58d22217f845dd17adfdd18dcd88d2b2469cda) Thanks [@belgattitude](https://github.com/belgattitude)! - Remove publish hack in favour of https://github.com/atlassian/changesets/pull/674

## 0.8.1

### Patch Changes
Expand Down
4 changes: 1 addition & 3 deletions packages/cache-interop/package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "@soluble/cache-interop",
"description": "Async cache interop contracts",
"version": "0.8.1",
"version": "0.8.2-canary.0",
"license": "MIT",
"homepage": "https://github.com/soluble-io/cache-interop/tree/main/packages/cache-interop",
"repository": {
Expand Down Expand Up @@ -31,8 +31,6 @@
"scripts": {
"start": "cross-env NODE_ENV=development tsdx watch",
"build": "cross-env NODE_ENV=production microbundle --tsconfig ./tsconfig.build.json --format esm,cjs,umd --target node --compress",
"?build-publishable-release": "When https://github.com/atlassian/changesets/issues/432 has a solution we can remove this trick",
"build-publishable-release": "yarn build",
"clean": "rimraf --no-glob ./dist ./build ./coverage ./out",
"test": "run-s test:* --",
"test:unit": "jest --config jest.config.js --color $@",
Expand Down
10 changes: 10 additions & 0 deletions packages/cache-ioredis/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,15 @@
# @soluble/cache-ioredis

## 0.8.4-canary.0

### Patch Changes

- [#222](https://github.com/soluble-io/cache-interop/pull/222) [`2a58d22`](https://github.com/soluble-io/cache-interop/commit/2a58d22217f845dd17adfdd18dcd88d2b2469cda) Thanks [@belgattitude](https://github.com/belgattitude)! - Remove publish hack in favour of https://github.com/atlassian/changesets/pull/674

- Updated dependencies [[`2a58d22`](https://github.com/soluble-io/cache-interop/commit/2a58d22217f845dd17adfdd18dcd88d2b2469cda)]:
- @soluble/[email protected]
- @soluble/[email protected]

## 0.8.3

### Patch Changes
Expand Down
9 changes: 2 additions & 7 deletions packages/cache-ioredis/package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "@soluble/cache-ioredis",
"description": "IORedis cache interop adapter",
"version": "0.8.3",
"version": "0.8.4-canary.0",
"license": "MIT",
"homepage": "https://github.com/soluble-io/cache-interop/tree/main/packages/cache-ioredis",
"repository": {
Expand All @@ -28,15 +28,10 @@
"dist"
],
"sideEffects": false,
"publishConfig": {
"directory": "_release/package"
},
"scripts": {
"start": "cross-env NODE_ENV=development microbundle watch",
"build": "rimraf ./dist && cross-env NODE_ENV=production microbundle --tsconfig tsconfig.build.json --target node --format esm,cjs,umd --compress",
"?build-publishable-release": "When https://github.com/atlassian/changesets/issues/432 has a solution we can remove this trick",
"build-publishable-release": "yarn build && rimraf ./_release && yarn pack && mkdir ./_release && tar zxvf ./package.tgz --directory ./_release && rm ./package.tgz",
"clean": "rimraf --no-glob ./dist ./build ./coverage ./out ./_release",
"clean": "rimraf --no-glob ./dist ./build ./coverage ./out",
"test": "run-s test:unit -- {@}",
"test:unit": "jest --config jest.config.js --color $@",
"typecheck": "tsc --project tsconfig.json --noEmit",
Expand Down
10 changes: 10 additions & 0 deletions packages/cache-redis/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,15 @@
# @soluble/cache-node-redis

## 0.8.4-canary.0

### Patch Changes

- [#222](https://github.com/soluble-io/cache-interop/pull/222) [`2a58d22`](https://github.com/soluble-io/cache-interop/commit/2a58d22217f845dd17adfdd18dcd88d2b2469cda) Thanks [@belgattitude](https://github.com/belgattitude)! - Remove publish hack in favour of https://github.com/atlassian/changesets/pull/674

- Updated dependencies [[`2a58d22`](https://github.com/soluble-io/cache-interop/commit/2a58d22217f845dd17adfdd18dcd88d2b2469cda)]:
- @soluble/[email protected]
- @soluble/[email protected]

## 0.8.3

### Patch Changes
Expand Down
9 changes: 2 additions & 7 deletions packages/cache-redis/package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "@soluble/cache-redis",
"description": "Node redis cache interop adapter",
"version": "0.8.3",
"version": "0.8.4-canary.0",
"license": "MIT",
"homepage": "https://github.com/soluble-io/cache-interop/tree/main/packages/cache-redis",
"repository": {
Expand Down Expand Up @@ -29,15 +29,10 @@
"dist"
],
"sideEffects": false,
"publishConfig": {
"directory": "_release/package"
},
"scripts": {
"start": "cross-env NODE_ENV=development microbundle watch",
"build": "rimraf ./dist && cross-env NODE_ENV=production microbundle --tsconfig tsconfig.build.json --format esm,cjs,umd --target node --compress",
"?build-publishable-release": "When https://github.com/atlassian/changesets/issues/432 has a solution we can remove this trick",
"build-publishable-release": "yarn build && rimraf ./_release && yarn pack && mkdir ./_release && tar zxvf ./package.tgz --directory ./_release && rm ./package.tgz",
"clean": "rimraf --no-glob ./dist ./build ./coverage ./out ./_release",
"clean": "rimraf --no-glob ./dist ./build ./coverage ./out",
"test": "run-s test:unit -- {@}",
"test:unit": "jest --config jest.config.js --color $@",
"typecheck": "tsc --noEmit",
Expand Down
6 changes: 6 additions & 0 deletions packages/dsn-parser/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
# @soluble/dsn-parser

## 1.3.3-canary.0

### Patch Changes

- [#222](https://github.com/soluble-io/cache-interop/pull/222) [`2a58d22`](https://github.com/soluble-io/cache-interop/commit/2a58d22217f845dd17adfdd18dcd88d2b2469cda) Thanks [@belgattitude](https://github.com/belgattitude)! - Remove publish hack in favour of https://github.com/atlassian/changesets/pull/674

## 1.3.2

### Patch Changes
Expand Down
4 changes: 1 addition & 3 deletions packages/dsn-parser/package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "@soluble/dsn-parser",
"description": "Utility parser for DSN",
"version": "1.3.2",
"version": "1.3.3-canary.0",
"license": "MIT",
"homepage": "https://github.com/soluble-io/cache-interop/tree/main/packages/dsn-parser",
"repository": {
Expand Down Expand Up @@ -34,8 +34,6 @@
"scripts": {
"start": "cross-env NODE_ENV=development microbundle watch",
"build": "rimraf ./dist && cross-env NODE_ENV=production microbundle --tsconfig tsconfig.build.json --format esm,cjs,umd --target node --compress",
"?build-publishable-release": "When https://github.com/atlassian/changesets/issues/432 has a solution we can remove this trick",
"build-publishable-release": "yarn build",
"clean": "rimraf --no-glob ./dist ./build ./coverage ./out",
"test": "run-s test:unit -- {@}",
"test:unit": "jest --config jest.config.js --color $@",
Expand Down
Loading