Skip to content

Commit

Permalink
Merge branch 'feature/console'
Browse files Browse the repository at this point in the history
  • Loading branch information
whalemare committed Mar 8, 2023
2 parents d3c0041 + 8006673 commit 98b909e
Show file tree
Hide file tree
Showing 27 changed files with 445 additions and 458 deletions.
30 changes: 30 additions & 0 deletions .vscode/launch.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
{
"version": "0.2.0",
"configurations": [
{
"type": "node",
"request": "launch",
"name": "Debug node-example",
"cwd": "${workspaceFolder}",
"runtimeExecutable": "${workspaceFolder}/node_modules/.bin/nx",
"runtimeArgs": [
"serve",
"node-example",
"--inspect"
],
"skipFiles": [
"<node_internals>/**",
"${workspaceFolder}/node_modules/*"
],
"outFiles": [
"${workspaceFolder}/dist/**/*.js"
]
},
{
"name": "Debug Node App",
"type": "node",
"request": "attach",
"port": 7777
}
]
}
3 changes: 2 additions & 1 deletion apps/node-example/project.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,8 @@
"serve": {
"executor": "@nrwl/js:node",
"options": {
"buildTarget": "node-example:build"
"buildTarget": "node-example:build",
"inspect": true
},
"configurations": {
"production": {
Expand Down
79 changes: 79 additions & 0 deletions apps/node-example/src/app/11. renderToConsole.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
/* eslint-disable no-console */
import { createStep } from '@ts-pipeline/core'
import { renderToConsole } from '@ts-pipeline/renderer-core'
import { parallel } from '@ts-pipeline/runner-parallel'
import { sequence, setupStep } from '@ts-pipeline/runner-sequence'

import { simulateWork } from './utils/simulateWork'
import { steps } from './utils/steps'

const deployPath = createStep({
name: 'deploy-path',
action: async (ui, props: { artifactPath: string; registry: 'yarn' | 'npm' }) => {
ui.onData(`deploying ${props.artifactPath}`)
await simulateWork(200, ui)

return props.artifactPath
},
})

const build = createStep({
name: 'build',
action: async (ui, props: { platform: 'android' | 'ios' | 'web' }) => {
ui.onData(`start building for platform ${props.platform}`)
await simulateWork(10000 * props.platform.length, ui)

return {
platform: props.platform,
buildPath: `some/path/to/my/build/${props.platform}.zip`,
}
},
})

const upload = createStep({
name: 'upload',
action: async (ui, props: { buildPath: string; retryCount?: number }) => {
ui.onData(`uploading ${props.buildPath}`)
await simulateWork(1000 * props.buildPath.length, ui)

return {
url: `https://my-build-server.com/${props.buildPath}`,
}
},
})

export async function renderToConsoleApp() {
const lint = steps.lint
const tests = setupStep(steps.tests, { allowPercentage: 30 })

await renderToConsole(
sequence(
'deploy react-native application',

parallel('lint and tests', lint, tests),

parallel(
'build for all platforms',

sequence(
'build and upload android app to server <3',
setupStep(build, { platform: 'android' }),
// android can hangup sometimes, so we retry 10 times
setupStep(upload, { retryCount: 10 }),
),

sequence(
'build and upload ios to server <3',
setupStep(build, { platform: 'ios' }),
upload,
),

sequence(
'build and upload web to server <3',
setupStep(build, { platform: 'web' }),
upload,
),
),
),
)
}
4 changes: 2 additions & 2 deletions apps/node-example/src/app/7. parallelApp.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/* eslint-disable no-console */
import { createStep } from '@ts-pipeline/core'
import { render } from '@ts-pipeline/renderer-react-ink'
import { renderToConsole } from '@ts-pipeline/renderer-core'
import { parallel } from '@ts-pipeline/runner-parallel'
import { sequence, setupStep } from '@ts-pipeline/runner-sequence'

Expand All @@ -18,7 +18,7 @@ const deployPath = createStep({
})

export async function parallelApp() {
await render(
await renderToConsole(
sequence(
'parallel app',
// create sequence of steps
Expand Down
5 changes: 4 additions & 1 deletion apps/node-example/src/main.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { workflowApp } from './app/1. workflowApp'
import { errorablesApp } from './app/10. errorablesApp'
import { renderToConsoleApp } from './app/11. renderToConsole'
import { endlessApp } from './app/2. endlessApp'
import { nestedApp } from './app/3. nestedApp'
import { deployApp } from './app/4. deployApp'
Expand All @@ -23,9 +24,11 @@ async function run() {
complexApp,
ddosStdout,
errorablesApp,
renderToConsoleApp,
}

const program = examples['errorablesApp']
// const program = examples['renderToConsoleApp']
const program = examples['parallelApp']

await program()
}
Expand Down
9 changes: 8 additions & 1 deletion libs/core/.babelrc
Original file line number Diff line number Diff line change
@@ -1,3 +1,10 @@
{
"presets": [["@nrwl/web/babel", { "useBuiltIns": "usage" }]]
"presets": [
[
"@nrwl/js/babel",
{
"useBuiltIns": "usage"
}
]
]
}
6 changes: 0 additions & 6 deletions libs/core/src/internal/renderer/Renderers.ts

This file was deleted.

30 changes: 0 additions & 30 deletions libs/core/src/internal/renderer/terminal/TerminalRenderStore.ts

This file was deleted.

3 changes: 0 additions & 3 deletions libs/core/src/internal/renderer/terminal/TerminalRenderers.ts

This file was deleted.

This file was deleted.

This file was deleted.

9 changes: 8 additions & 1 deletion libs/renderer-core/.babelrc
Original file line number Diff line number Diff line change
@@ -1,3 +1,10 @@
{
"presets": [["@nrwl/web/babel", { "useBuiltIns": "usage" }]]
"presets": [
[
"@nrwl/js/babel",
{
"useBuiltIns": "usage"
}
]
]
}
2 changes: 1 addition & 1 deletion libs/renderer-core/src/index.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// @index(['./shared/**/*.(ts|tsx)', '!./**/*.d.(ts|tsx)'], f => `export * from '${f.path}'`)
export * from './shared/entity/AppRender'
export * from './shared/entity/Renderable'
export * from './shared/renderToConsole'
// @endindex
3 changes: 0 additions & 3 deletions libs/renderer-core/src/shared/entity/Renderable.ts

This file was deleted.

37 changes: 37 additions & 0 deletions libs/renderer-core/src/shared/model/PlainConsoleRender.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
/* eslint-disable no-console */
import { Registry } from '@ts-pipeline/core'
import { composeSubscribe, Unsubscriber } from '@ts-pipeline/ts-core'
import { reaction } from 'mobx'

import { AppRender } from '../entity/AppRender'

import { TaskStringRenderable } from './TaskStringRenderable'

export class PlainConsoleRender implements AppRender {
render = (registry: Registry<any, any>): Unsubscriber => {
console.log('PlainConsoleRender.render()')
console.log(registry.name)
const renderable = new TaskStringRenderable()

const historyReactions = registry.nested.map(store => {
console.log('registry.nested', store.name)
renderable.render(store, 0)
reaction(
() => [store, store.history, store.name, store.args],
() => {
renderable.render(store, 0)
},
{ fireImmediately: true },
)

return () => {
console.log('unsubscribe')
}
})

return composeSubscribe([
//
...historyReactions,
])
}
}
Loading

0 comments on commit 98b909e

Please sign in to comment.