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

$mol_build refactor extracted graph #708

Merged
merged 80 commits into from
Dec 21, 2024
Merged
Changes from 1 commit
Commits
Show all changes
80 commits
Select commit Hold shift + click to select a range
3d0537b
$mol_build refactor extracted graph
zerkalica Oct 9, 2024
82975ca
$mol_build_graph fixes
zerkalica Oct 10, 2024
dcbd80d
$mol_build_grap fix
zerkalica Oct 10, 2024
d864bca
$mol_file no watch if mol_run affects something in wathing path deep
zerkalica Oct 11, 2024
0b600ab
$mol_file lock watcher while running dirty command
zerkalica Oct 12, 2024
4d1438d
$mol_file locking variant 2
zerkalica Oct 12, 2024
65160b0
$mol_build_graph fix checkdep: used mol_mem_key
zerkalica Oct 12, 2024
3b029b4
$mol_build object keys to tuple keys
zerkalica Oct 12, 2024
1c839a9
$mol_run waits running $mol_file resets, file resets waiting dirty $m…
zerkalica Oct 13, 2024
eb8bbaa
$mol_file run locking improved
zerkalica Oct 14, 2024
a9926f0
$mol_file run locking improved 2
zerkalica Oct 14, 2024
8bff094
$mol_run, $mol_file locks alt
zerkalica Oct 16, 2024
0a91631
$mol_run lock fixed
zerkalica Oct 16, 2024
8d72bf2
$mol_file safe push-style reset
zerkalica Oct 16, 2024
f45c3b8
$mol_run_lock type fix
zerkalica Oct 16, 2024
9904ccb
$mol_run graph improvement fixes
zerkalica Oct 18, 2024
48d0c91
$mol_file fix place name
zerkalica Oct 18, 2024
787b316
$mol_build_server simplify middleware
zerkalica Oct 18, 2024
f02cf61
$mol_build reload fixes
zerkalica Oct 20, 2024
f6bc8fa
$mol_build, refactor
zerkalica Oct 20, 2024
e34f24a
$mol_build minimal refactor, support git bisect
zerkalica Oct 20, 2024
43126ad
$mol_build refactor repo text
zerkalica Oct 21, 2024
545650f
$mol_lock refactor, moved to mol root
zerkalica Oct 21, 2024
e420598
$mol_build, fix process exit code
zerkalica Oct 21, 2024
d95f397
$mol_build_server fix reload page on files changed
zerkalica Oct 21, 2024
24da36d
$mol_build copy sync
zerkalica Oct 21, 2024
87435ef
$mol_file improve copy api
zerkalica Oct 21, 2024
d745dd3
$mol_file improve copy api 2
zerkalica Oct 21, 2024
ff38c94
$mol_file improve copy api 3
zerkalica Oct 21, 2024
7701c8a
$mol_file use stat, not buffer
zerkalica Oct 21, 2024
10ac8b2
$mol_file copy api refactor
zerkalica Oct 21, 2024
b4a0e28
$mol_file copy api refactor 2
zerkalica Oct 21, 2024
93bd347
$mol_build web.js restart fix
zerkalica Oct 22, 2024
a8896b6
$mol_build refactor extracted $mol_build_ensure
zerkalica Oct 23, 2024
ae6976b
$mol_run fallback to sync spawn otside fiber
zerkalica Oct 23, 2024
c385d04
$mol_run fallback to sync spawn otside fiber - fix
zerkalica Oct 23, 2024
680ede4
$mol_run more error handling
zerkalica Oct 23, 2024
19019d8
$mol_exec fix type
zerkalica Oct 23, 2024
fa8897c
$mol_build_ensurer plugins, async fixes
zerkalica Oct 23, 2024
7cafb64
$mol_build_ensure fix reset after clone
zerkalica Oct 23, 2024
2626c91
$mol_build refactor, better git pull
zerkalica Oct 25, 2024
6639b3b
$mol_build_server wait middleware promise groupped by url
zerkalica Oct 25, 2024
92fefe7
$mol_build git ensure fixes
zerkalica Nov 7, 2024
2ce6e03
$mol_run, check env
zerkalica Nov 7, 2024
f85d863
$mol_file fix remove directory
zerkalica Nov 10, 2024
a011a48
$mol_file refactor
zerkalica Nov 11, 2024
03baf24
$mol_file use this type
zerkalica Nov 12, 2024
a039ae2
$mol_file webdav
zerkalica Nov 12, 2024
d9648f3
$mol_file webdav
zerkalica Nov 13, 2024
30c5ac3
$mol_file webdav 2
zerkalica Nov 13, 2024
0b98ef2
$mol_build refactor git pull
zerkalica Nov 14, 2024
2d6216e
$mol_build_server refactor, restart bugs with request
zerkalica Nov 14, 2024
c7666cb
$mol_build_server fixes
zerkalica Nov 14, 2024
ce72866
$mol_view_tre2_to_dts fix idempotency, this? fix
zerkalica Nov 14, 2024
9540ab3
tmp
zerkalica Nov 14, 2024
565164f
$mol_view_tree2_to_dts fix unique prefix
zerkalica Nov 14, 2024
24ab884
$mol_build fixes
zerkalica Nov 14, 2024
30bc340
$mol_view_tree2_to_dts fix simplify args
zerkalica Nov 14, 2024
b04f90c
$mol_build_server keep bundle files between reloads
zerkalica Nov 14, 2024
48301eb
$mol_build fix naming, better keep bundle
zerkalica Nov 14, 2024
1e3f94f
Merge branch 'master' of github.com:hyoo-ru/mam_mol into fix-run
zerkalica Nov 15, 2024
1742d9e
Merge branch 'master' of github.com:hyoo-ru/mam_mol into fix-run
zerkalica Nov 15, 2024
8186ecc
$mol_file watcher native fix
zerkalica Nov 15, 2024
47ef4b4
$mol_file fix root dir detection
zerkalica Nov 15, 2024
8b8cef1
Merge branch 'master' of github.com:hyoo-ru/mam_mol into fix-run
zerkalica Nov 17, 2024
bd93d41
$mol_file comments
zerkalica Nov 19, 2024
e3a232e
$mol_build_server keep bundles if page opened
zerkalica Nov 19, 2024
71c539e
$mol_build_server comment change
zerkalica Nov 20, 2024
a8a8612
Merge branch 'master' of github.com:hyoo-ru/mam_mol into fix-run
zerkalica Nov 20, 2024
84c1e4a
Merge branch 'master' of github.com:hyoo-ru/mam_mol into fix-run
zerkalica Nov 25, 2024
237a60e
Merge branch 'master' of github.com:hyoo-ru/mam_mol into fix-run
zerkalica Nov 26, 2024
12aab4d
$mol_build git version fix
zerkalica Nov 26, 2024
d0270c8
Merge branch 'master' of github.com:hyoo-ru/mam_mol into fix-run
zerkalica Dec 13, 2024
419ca32
Merge branch 'master' of github.com:hyoo-ru/mam_mol into fix-run
zerkalica Dec 17, 2024
2281465
Merge branch 'master' of github.com:hyoo-ru/mam_mol into fix-run
zerkalica Dec 18, 2024
4a0d062
$mol_file fix ts 5.7 typings
zerkalica Dec 18, 2024
bb93e68
$mol_file disabe verbose logs, fix typings
zerkalica Dec 18, 2024
4555a7a
$mol_file_transaction added
zerkalica Dec 19, 2024
0dbeaff
Merge branch 'master' of github.com:hyoo-ru/mam_mol into fix-run
zerkalica Dec 19, 2024
e75f34c
$mol_file_transaction write support array of buffer and string
zerkalica Dec 19, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
$mol_file lock watcher while running dirty command
zerkalica committed Nov 14, 2024
commit 0b600ab135868b34d6a00a5cc42e83c22a2a99ff
4 changes: 2 additions & 2 deletions build/build.node.ts
Original file line number Diff line number Diff line change
@@ -655,7 +655,7 @@ namespace $ {
// fatal: unable to set up work tree using invalid config
command.push( this.gitDeepenSupported() ? '--deepen=1' : '--depth=1' )
}
return this.run_safe( { command, dir: path, affects: [ path ] } )
return this.run_safe( { command, dir: path, dirty: true } )
}

static git_enabled = true
@@ -748,7 +748,7 @@ namespace $ {
if( repo ) {
this._clone_stack = new $mol_error_mix('clone stack', { path })
const command = ['git', 'clone' , '--depth', '1' , repo.text() , mod.relate( this.root() ) ]
this.$.$mol_run( { command, dir: this.root().path(), affects: [ path ] })
this.$.$mol_run( { command, dir: this.root().path(), dirty: true })
this._clone_stack = null
mod.reset()
return true
45 changes: 30 additions & 15 deletions file/file.node.ts
Original file line number Diff line number Diff line change
@@ -53,7 +53,6 @@ namespace $ {

@ $mol_mem
override watcher() {

const watcher = $node.chokidar.watch( this.path() , {
persistent : true ,
ignored: path => /([\/\\]\.|___$)/.test( path ),
@@ -65,7 +64,7 @@ namespace $ {
} )

watcher
.on( 'all' , (type, path) => this.watcher_event(type, path) )
.on( 'all' , (type, path) => this.watch_event(type, path) )
.on( 'error' , $mol_fail_log )

return {
@@ -76,34 +75,50 @@ namespace $ {

}

protected watcher_event(type: string, path: string) {
let part = path
const affected = this.$.$mol_run_affected
do {
if (affected[part]) return
part = part.slice(0, part.lastIndexOf('/'))
} while(part)
protected watch_changed = null as null | Set<string>
protected watch_affected = null as null | Set<string>

const file = $mol_file.relative( path.replace( /\\/g , '/' ) )
protected watch_event(type: string, path: string) {
const locked = this.$.$mol_run_locks.locked()
if (locked) {
if (type === 'change') {
( this.watch_changed = this.watch_changed ?? new Set() ).add(path)
} else {
( this.watch_affected = this.watch_changed ?? new Set() ).add(path)
}

return
}

const file = $mol_file.relative( path.replace( /\\/g , '/' ) )

file.reset()

if( type === 'change' ) {
this.stat( null )
this.reset()
} else {
file.parent().reset()
}
}

override lock_sync( ) {
if (! this.$.$mol_run_locks.locked()) {
this.watch_changed?.forEach(path => this.watch_event('change', path))
this.watch_changed = null
this.watch_affected?.forEach(path => this.watch_event('', path))
this.watch_affected = null
}
return null
}

@ $mol_mem
stat( next? : $mol_file_stat | null, virt?: 'virt' ) {

override stat_actual( next? : $mol_file_stat | null, virt?: 'virt' ) {
let stat = next
const path = this.path()

this.parent().watcher()

if( virt ) return next!
if( virt ) return next ?? null

try {
stat = next ?? stat_convert($node.fs.statSync( path, { throwIfNoEntry: false } ))
@@ -170,7 +185,7 @@ namespace $ {
this.parent().exists( true )

const now = new Date
this.stat( {
this.stat_actual( {
type: 'file',
size: next.length,
atime: now,
16 changes: 12 additions & 4 deletions file/file.ts
Original file line number Diff line number Diff line change
@@ -33,11 +33,19 @@ namespace $ {
return this.resolve( '..' )
}

abstract stat( next? : $mol_file_stat | null, virt?: 'virt' ): $mol_file_stat | null
abstract lock_sync(): void

reset(): void {
@ $mol_mem
stat() {
this.lock_sync()
return this.stat_actual()
}

abstract stat_actual( next? : $mol_file_stat | null, virt?: 'virt' ): $mol_file_stat | null

reset() {
try {
this.stat( null )
this.stat_actual( null )
} catch( error: any ) {
if (error instanceof $mol_file_not_found) return
return $mol_fail_hidden(error)
@@ -99,7 +107,7 @@ namespace $ {
text(next?: string, virt?: 'virt') {
if( virt ) {
const now = new Date
this.stat( {
this.stat_actual( {
type: 'file',
size: 0,
atime: now,
27 changes: 19 additions & 8 deletions run/run.node.ts
Original file line number Diff line number Diff line change
@@ -18,17 +18,30 @@ namespace $ {
command : readonly string[] | string
dir : string
timeout?: number
affects?: readonly string[]
dirty?: boolean
env?: Record<string, string | undefined>
}

export const $mol_run_affected = {} as Record<string, number | undefined>
export class $mol_run_locks extends $mol_object {
protected static counter = 0
static increase() {
this.counter++
this.locked(null)
}

static decrease() {
this.counter--
this.locked(null)
}

@ $mol_mem
static locked(reset?: null) { return this.counter > 0 }
}

export function $mol_run_async(
this : $ ,
{ dir, timeout, command, env, affects }: $mol_run_options
{ dir, timeout, command, env, dirty }: $mol_run_options
) {
const affected = this.$mol_run_affected
const args_raw = typeof command === 'string' ? command.split( ' ' ) : command
const [ app, ...args ] = args_raw

@@ -84,14 +97,12 @@ namespace $ {
sub.stdout?.on('data', data => add(data) )
sub.stderr?.on('data', data => add(undefined, data) )

affects?.forEach(path => affected[path] = (affected[path] ?? 0) + 1)
if (dirty) this.$mol_run_locks.increase()

const promise = new Promise<$mol_run_error_context>((done, fail) => {
const close = (error: Error | null, status: number | null = null, signal: NodeJS.Signals | null = null) => {
for (const path of affects ?? []) {
if (! --affected[path]! ) delete affected[path]
}
if (! timer && timeout) return
if (dirty) this.$mol_run_locks.decrease()

clearTimeout(timer)
timer = undefined