Skip to content

Commit

Permalink
Merge dev into master
Browse files Browse the repository at this point in the history
  • Loading branch information
paul.lecouteur committed Jan 30, 2021
2 parents 9e5b645 + d19a39f commit 8c1c737
Show file tree
Hide file tree
Showing 28 changed files with 211 additions and 810 deletions.
21 changes: 21 additions & 0 deletions .vscode/launch.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
{
// Use IntelliSense to learn about possible attributes.
// Hover to view descriptions of existing attributes.
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
"version": "0.2.0",
"configurations": [
{
"name": "debug",
"type": "node",
"request": "launch",
"runtimeExecutable": "${workspaceFolder}/node_modules/.bin/yalam",
"args": [
"--watch",
"example-1/",
"example-2/"
],
"cwd": "${workspaceFolder}/fixtures",
"console": "integratedTerminal",
},
]
}
13 changes: 13 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
# Changelog

All notable changes to this project will be documented in this file.

The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

## [0.1.0] - 2021-01-30

### Added

- Initial version of Yalam.

2 changes: 1 addition & 1 deletion lerna.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
{
"version": "1.0.0",
"version": "0.1.0",
"useWorkspaces": true
}
1 change: 1 addition & 0 deletions packages/babel/.npmignore
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ test*
.env
src/
tsconfig.json
tsconfig.tsbuildinfo
.nyc_output
.babelrc
.yalam
9 changes: 4 additions & 5 deletions packages/babel/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@yalam/babel",
"version": "1.0.0",
"version": "0.1.0",
"description": "Use Babel with Yalam",
"author": "Paul Le Couteur",
"license": "MIT",
Expand All @@ -10,10 +10,9 @@
},
"dependencies": {
"@babel/core": "^7.12.10",
"@babel/plugin-transform-typescript": "^7.12.1",
"@babel/preset-env": "^7.12.11",
"@yalam/core": "^1.0.0",
"@yalam/operators": "^1.0.0",
"@babel/preset-typescript": "^7.12.7",
"@yalam/core": "^0.1.0",
"@yalam/operators": "^0.1.0",
"replace-ext": "^2.0.0"
},
"devDependencies": {
Expand Down
14 changes: 2 additions & 12 deletions packages/babel/src/babel.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,27 +19,17 @@ type BabelOptions = Pick<Babel.TransformOptions,
>;

const getOptions = (asset: FileAsset, options: BabelOptions): Babel.TransformOptions => {
const plugins = [];
const presets = [
[
'@babel/preset-env'
]
'@babel/preset-typescript'
];

if (path.extname(asset.path) === '.ts') {
plugins.push(
[
'@babel/plugin-transform-typescript'
]);
}

return {
cwd: asset.entry,
filename: asset.sourcePath,
inputSourceMap: asset.sourceMap,
sourceMaps: true,
plugins,
presets,
babelrcRoots: asset.entry,
...options
};
}
Expand Down
1 change: 1 addition & 0 deletions packages/babel/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
"strict": true,
"skipLibCheck": true,
"removeComments": false,
"sourceMap": true,
"typeRoots": [
"./typings",
"node_modules/@types"
Expand Down
1 change: 1 addition & 0 deletions packages/cli/.npmignore
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ test*
.env
src/
tsconfig.json
tsconfig.tsbuildinfo
.nyc_output
.babelrc
.yalam
8 changes: 4 additions & 4 deletions packages/cli/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@yalam/cli",
"version": "1.0.0",
"version": "0.1.0",
"description": "A command line interface for Yalam",
"author": "Paul Le Couteur",
"license": "MIT",
Expand All @@ -12,9 +12,9 @@
"yalam": "./dist/bin.js"
},
"dependencies": {
"@yalam/core": "^1.0.0",
"@yalam/operators": "^1.0.0",
"@yalam/reporter": "^1.0.0",
"@yalam/core": "^0.1.0",
"@yalam/operators": "^0.1.0",
"@yalam/reporter": "^0.1.0",
"exits": "^2.0.1",
"md5-file": "^5.0.0",
"meow": "^7.1.1",
Expand Down
5 changes: 4 additions & 1 deletion packages/cli/src/runner.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,8 @@ import {

import {
initTTY,
getTask
getTask,
isSkipped
} from './utils';

export const enum RunnerMode {
Expand Down Expand Up @@ -45,6 +46,7 @@ export class Runner {

private async build() {
const promises = this.options.entries
.filter(entry => !isSkipped(entry))
.map(
entry => this.yalam.build({
task: getTask(entry, RunnerMode.BUILD),
Expand All @@ -63,6 +65,7 @@ export class Runner {
}

const promises = this.options.entries
.filter(entry => !isSkipped(entry))
.map(
entry => this.yalam.watch({
task: getTask(entry, RunnerMode.WATCH),
Expand Down
17 changes: 16 additions & 1 deletion packages/cli/src/utils/get-pkg.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,11 +25,26 @@ export const getTask = (directory: DirectoryPath, mode: RunnerMode): string => {
if (!pkg.config
|| !pkg.config.yalam
|| !pkg.config.yalam[mode]
|| typeof pkg.config.yalam[mode] !== 'string') {
|| typeof pkg.config.yalam[mode] !== 'string'
) {
throw new Error(
`Your "package.json" at ${directory} should provide a task name at path config.yalam.${mode}`
);
}

return pkg.config.yalam[mode];
}

export const isSkipped = (directory: DirectoryPath): boolean => {
const pkg = getPKG(directory);

if (!pkg.config
|| !pkg.config.yalam
) {
throw new Error(
`Your "package.json" at ${directory} should provide an object at config.yalam`
);
}

return pkg.config.yalam === "skip";
}
1 change: 1 addition & 0 deletions packages/cli/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
"strict": true,
"skipLibCheck": true,
"removeComments": false,
"sourceMap": true,
"typeRoots": [
"./typings",
"node_modules/@types"
Expand Down
1 change: 1 addition & 0 deletions packages/core/.npmignore
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ test*
.env
src/
tsconfig.json
tsconfig.tsbuildinfo
.nyc_output
.babelrc
.yalam
97 changes: 93 additions & 4 deletions packages/core/README.md
Original file line number Diff line number Diff line change
@@ -1,11 +1,9 @@
# Welcome to yalam 👋
![Version](https://img.shields.io/badge/version-1.0.0-blue.svg?cacheSeconds=2592000)
![Version](https://img.shields.io/badge/version-0.1.0-blue.svg?cacheSeconds=2592000)
[![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](#)

> A Gulp-inspired incremental build system
**WARNING: This software is in development and not yet published to NPM.**

### Feature Comparison

Here is a table comparing some javascript build systems:
Expand All @@ -18,7 +16,98 @@ Here is a table comparing some javascript build systems:

### Architecture

Yalam is a Gulp-inspired incremental build system with some differences to make it incremental. Thus the pipelines you are going to create with Yalam should be a bit different than the ones with Gulp, to make your build purely incremental.
Yalam is a Gulp-inspired **incremental** build system. The aim is to make your build purely incremental,
by using a caching strategy and a developper-friendly API.

### Yalamfile

Yalam is configured with a `Yalamfile.js`.
This file describes the list of pipelines that can be used to build your packages.

```javascript
const { pipe, apply } = require('@yalam/core');
const { source, destination , createAsset } = require('@yalam/operators');
const { tsCompiler } = require('@yalam/typescript');

const ts = pipe(
source({ glob: 'src/**/*' }),
createAsset(),
apply(['.ts'])(
tsCompiler.transpile(),
tsCompiler.generateTypes()
),
destination({ path: 'dist' })
);

module.exports = {
default: ts,
};
```

Here the `ts` pipeline will create a `.js` and a `.d.ts` asset for each `.ts` source file, using typescript.

### Package

Using the **CLI** provided by `@​yalam/cli`, you can build `packages` by providing a list like that:

```console
foo@bar:~$ yalam --watch example-1/ example-2/
```

Here a **package** is a folder containing a `package.json` file with a `config.yalam` field like for instance:

```json
{
"name": "@yalam/example-1",
"version": "1.0.0",
"main": "dist/index.js",
"config": {
"yalam": {
"build": "default",
"watch": "default"
}
}
}
```

As you can see, this `package.json` tells Yalam to use the `default` pipeline both for build mode and watch mode.

Note that you can mark a `package` to be skipped by using the value `"skip"` for the `yalam` field.

### Pipeline

**Pipeline**, also named **task**, is how you tell Yalam to do its job.

A pipeline is nothing else but an [operator](https://rxjs.dev/guide/operators "RXJS Operator"), ie. a function that map
an [observable](https://rxjs.dev/guide/observable "Observable") to an [observable](https://rxjs.dev/guide/observable "Observable").

So basically you can use all the power of [RxJS](https://rxjs.dev/guide/overview "RxJS") to construct your piplines.

A pipeline should map an observable of type `InputEvent` to an observable of type `Asset`.
This is directly inspired by how [Gulp](https://gulpjs.com/ "Gulp") works but the interface is a bit different.

Look at the `fixtures` folder to see examples of pipelines.

### Operator
To create your pipeline, you should use meta-operators that create an operator out of operators, and already existing operators.

- `@​yalam/core` exports some generic meta-operators: `pipe`, `apply`, `parallel` and `series`.
- `@​yalam/operators` exports some generic operators: `source`, `sink`, `oneToOne`, `destination` and `createAsset`.
- `@​yalam/babel` exports operator `babel`.
- `@​yalam/typescript` exports operators `tsCompiler.transpile`, `tsCompiler.generateTypes` and `tsCompiler.checkTypes`.

### The futur
Yalam current target in mind is a NodeJS mono-repository for backend. But it could be extended to support more compilers and maybe
with enough contribution extends to an eco-system.

There is so much to do, create a `documentation`, create a `test suite`, create new operators for different compilers,
enable built-in support for `dependancy graphs`, ...

So if you are willing to contribute, don't hesitate to contact-me/open an issue!

Cheers.

PS: Yalam is a reference to [Golden Sun](https://www.youtube.com/watch?v=qNvaMC_DRPA "Golden Sun") .

## Author

Expand Down
4 changes: 2 additions & 2 deletions packages/core/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@yalam/core",
"version": "1.0.0",
"version": "0.1.0",
"description": "A Gulp-inspired incremental build system",
"author": "Paul Le Couteur",
"license": "MIT",
Expand All @@ -15,7 +15,7 @@
"lockfile": "^1.0.4",
"mkdirp": "^1.0.4",
"p-queue": "^6.6.2",
"rxjs": "^7.0.0-beta.9",
"rxjs": "7.0.0-beta.10",
"set-immediate-promise": "^1.0.7"
},
"devDependencies": {
Expand Down
10 changes: 7 additions & 3 deletions packages/core/src/services/request/request-runner.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,14 @@ import PQueue from 'p-queue';
import watcher from '@parcel/watcher';
import setImmediatePromise from 'set-immediate-promise';
import { inject } from '@loopback/context';
import { from } from 'rxjs';
import {
from,
connectable,
Subject
} from 'rxjs';
import {
map,
mergeAll,
publish,
} from 'rxjs/operators';

import {
Expand Down Expand Up @@ -97,7 +100,8 @@ export class RequestRunner implements IRequestRunner {

private async buildEvents(events: InputEvent[], throwOnFail: boolean) {
this.onInput(events);
const input = publish<InputEvent>()(from(events));

const input = connectable(from(events), new Subject());

const onAsset = (asset: Asset) => {
if (throwOnFail
Expand Down
1 change: 1 addition & 0 deletions packages/core/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
"removeComments": false,
"emitDecoratorMetadata": true,
"experimentalDecorators": true,
"sourceMap": true,
"typeRoots": [
"./typings",
"node_modules/@types"
Expand Down
1 change: 1 addition & 0 deletions packages/operators/.npmignore
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ test*
.env
src/
tsconfig.json
tsconfig.tsbuildinfo
.nyc_output
.babelrc
.yalam
Loading

0 comments on commit 8c1c737

Please sign in to comment.