Skip to content

Commit

Permalink
Merge pull request #1 from piotr-oles/feature/initial-implementation
Browse files Browse the repository at this point in the history
feat: initial implementation
  • Loading branch information
piotr-oles authored Feb 22, 2021
2 parents 9f3c208 + cd4807e commit 78a145a
Show file tree
Hide file tree
Showing 7 changed files with 5,932 additions and 73 deletions.
78 changes: 78 additions & 0 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
name: CI/CD
on: [push]
jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v1

- name: Setup node
uses: actions/setup-node@v1
with:
node-version: 10

- name: Yarn cache directory
id: yarn-cache
run: echo "::set-output name=dir::$(yarn cache dir)"

- name: Yarn cache
uses: actions/cache@v2
with:
path: ${{ steps.yarn-cache.outputs.dir }}
key: ${{ runner.os }}-yarn-${{ hashFiles('**/yarn.lock') }}
restore-keys: |
${{ runner.os }}-yarn-
- name: Install dependencies
run: yarn install --frozen-lockfile

- name: Build
run: yarn build

- name: Upload build artifact
uses: actions/upload-artifact@v1
with:
name: lib
path: lib

release:
runs-on: ubuntu-latest
needs: build
if: "!contains(github.event.head_commit.message, 'ci skip') && !contains(github.event.head_commit.message, 'skip ci')"
steps:
- uses: actions/checkout@v2

- name: Prepare repository
run: git fetch --unshallow --tags

- name: Setup node
uses: actions/setup-node@v1
with:
node-version: 12

- name: Get yarn cache
id: yarn-cache
run: echo "::set-output name=dir::$(yarn cache dir)"

- uses: actions/cache@v1
with:
path: ${{ steps.yarn-cache.outputs.dir }}
key: ${{ runner.os }}-yarn-${{ hashFiles('**/yarn.lock') }}
restore-keys: |
${{ runner.os }}-yarn-
- name: Install dependencies
run: yarn install --frozen-lockfile

- name: Download build artifact
uses: actions/download-artifact@v1
with:
name: lib
path: lib

- name: Release
env:
GH_TOKEN: ${{ secrets.GH_TOKEN }}
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
run: yarn release

75 changes: 4 additions & 71 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,67 +1,28 @@
# Logs
logs
*.log
npm-debug.log*
yarn-debug.log*
yarn-error.log*
lerna-debug.log*

# Diagnostic reports (https://nodejs.org/api/report.html)
report.[0-9]*.[0-9]*.[0-9]*.[0-9]*.json

# Runtime data
pids
*.pid
*.seed
*.pid.lock

# Directory for instrumented libs generated by jscoverage/JSCover
lib-cov

# Coverage directory used by tools like istanbul
coverage
*.lcov

# nyc test coverage
.nyc_output

# Grunt intermediate storage (https://gruntjs.com/creating-plugins#storing-task-files)
.grunt

# Bower dependency directory (https://bower.io/)
bower_components

# node-waf configuration
.lock-wscript

# Compiled binary addons (https://nodejs.org/api/addons.html)
build/Release
# JetBrains files
.idea

# Dependency directories
node_modules/
jspm_packages/

# TypeScript v1 declaration files
typings/

# TypeScript cache
*.tsbuildinfo

# Optional npm cache directory
.npm

# Optional eslint cache
.eslintcache

# Microbundle cache
.rpt2_cache/
.rts2_cache_cjs/
.rts2_cache_es/
.rts2_cache_umd/

# Optional REPL history
.node_repl_history

# Output of 'npm pack'
*.tgz

Expand All @@ -72,33 +33,5 @@ typings/
.env
.env.test

# parcel-bundler cache (https://parceljs.org/)
.cache

# Next.js build output
.next

# Nuxt.js build / generate output
.nuxt
dist

# Gatsby files
.cache/
# Comment in the public line in if your project uses Gatsby and *not* Next.js
# https://nextjs.org/blog/next-9-1#public-directory-support
# public

# vuepress build output
.vuepress/dist

# Serverless directories
.serverless/

# FuseBox cache
.fusebox/

# DynamoDB Local files
.dynamodb/

# TernJS port file
.tern-port
# Built files
lib
63 changes: 61 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,2 +1,61 @@
# karton
Create sandbox for package e2e tests
<div align="center">

<h1>karton </h1>
<p>Create sandbox for E2E tests 📦</p>

</div>

## Installation

This loader requires minimum Node.js 10

```sh
# with npm
npm install --save-dev karton

# with yarn
yarn add --dev karton
```

## Usage

This package helps you with writing E2E tests for your packages.
Example:

```typescript
import { createSandbox, Sandbox } from "karton";
import path from 'path';
import fs from 'fs-extra';

describe('my-package', () => {
let sandbox: Sandbox;
beforeEach(async () => {
sandbox = await createSandbox();
});
afterEach(async () => {
await sandbox.destroy();
});

it.each([
'^4.0.0',
'^5.0.0'
])('works with webpack %p', async (webpackVersion) => {
const packageJSON = JSON.parse(
await fs.readFile('fixtures/package.json', 'utf-8')
);
packageJSON.dependencies['webpack'] = webpackVersion;
packageJSON.dependencies['my-package'] = path.resolve(__dirname, '../my-package-0.0.0.tgz');

await sandbox.write('package.json', JSON.stringify(packageJSON));
await sandbox.write('src/test.js', await fs.readFile('fixtures/src/test.js'));

await sandbox.exec('yarn install');
const result = await sandbox.exec('node src/test.js');

expect(result).toEqual('my-package awesome output');
});
})
```

## License
MIT
48 changes: 48 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
{
"name": "karton",
"version": "0.0.0",
"description": "Create sandbox for package e2e tests",
"main": "lib/index.js",
"types": "lib/index.d.ts",
"repository": "[email protected]:piotr-oles/karton.git",
"author": "Piotr Oleś <[email protected]>",
"license": "MIT",
"scripts": {
"build": "tsc",
"format": "prettier src --write",
"release": "auto shipit"
},
"files": [
"lib/*"
],
"dependencies": {
"chalk": "^4.1.0",
"cross-spawn": "^7.0.3",
"fs-extra": "^9.1.0",
"strip-ansi": "^6.0.0",
"tree-kill": "^1.2.2"
},
"devDependencies": {
"@types/cross-spawn": "^6.0.2",
"@types/fs-extra": "^9.0.7",
"auto": "^10.16.5",
"husky": "^4.0.0",
"prettier": "^2.2.1",
"typescript": "^4.1.5"
},
"auto": {
"plugins": [
"npm",
"released"
],
"onlyPublishWithReleaseLabel": true,
"shipit": {
"noChangelog": true
}
},
"husky": {
"hooks": {
"pre-commit": "yarn format && yarn build"
}
}
}
Loading

0 comments on commit 78a145a

Please sign in to comment.