فینورا پرو - سامانه جامع حسابداری و صدور فاکتور
Add idempotent phase milestones, priority labels and issue metadata sync
davoodmehraban89 committed
Oct 14, 2026 at 08:24 UTC
5a3a19cc2581a4727b2e2b786d702b96f137d0be
1 file changed
+102
.github/scripts/sync-roadmap.ps1
new
+102
@@ -0,0 +1,102 @@
1
+# Idempotent GitHub metadata sync for Factor-easyPro's approved roadmap.
2
+# Does not change repository security rules, collaborators or release permissions.
3
+# Usage: GH_TOKEN with issues:write; GH_REPO (optional), otherwise GITHUB_REPOSITORY.
4
+$ErrorActionPreference = 'Stop'
5
+$repo = if ($env:GH_REPO) { $env:GH_REPO } else { $env:GITHUB_REPOSITORY }
6
+if ($repo -ne 'davoodmehraban89/Factor-easyPro') {
7
+ throw 'Unexpected repository. Roadmap metadata sync is limited to the designated repo.'
8
+}
9
+if (-not $env:GH_TOKEN) { throw 'Missing GH_TOKEN with issues:write permission' }
10
+
11
+$phaseDefs = @(
12
+ @{ Code='A'; Title='Phase A — Reliable Core'; Description='P0 accounting, immutable financial correction, audit, recovery, security and Windows acceptance.' }
13
+ @{ Code='B'; Title='Phase B — Retail Pro'; Description='P1 POS, cashier shifts, multi-tender settlement, price tiers, orders and retail reporting. Starts after A approval.' }
14
+ @{ Code='C'; Title='Phase C — Industry & Scale'; Description='P2/P3 manufacturing, distribution, assets, payroll, tax integrations and transactional multi-branch architecture. Starts after B approval.' }
15
+)
16
+$existingMilestones = @(gh api ("repos/{0}/milestones?state=all&per_page=100" -f $repo) | ConvertFrom-Json)
17
+foreach ($phase in $phaseDefs) {
18
+ $found = @($existingMilestones | Where-Object { $_.title -eq $phase.Title })
19
+ if ($found.Count -gt 1) { throw ('Duplicate milestone name: ' + $phase.Title) }
20
+ if ($found.Count -eq 0) {
21
+ $newMilestone = gh api -X POST ("repos/{0}/milestones" -f $repo) -f ('title=' + $phase.Title) -f ('description=' + $phase.Description) | ConvertFrom-Json
22
+ if ($LASTEXITCODE -ne 0 -or -not $newMilestone.number) { throw ('Cannot create milestone ' + $phase.Code) }
23
+ Write-Output ('CREATED_MILESTONE=' + $newMilestone.number + ' ' + $phase.Title)
24
+ } else {
25
+ Write-Output ('EXISTING_MILESTONE=' + $found[0].number + ' ' + $phase.Title)
26
+ }
27
+}
28
+
29
+$labels = @(
30
+ @{ Name='phase:A'; Color='d4c5f9'; Description='Reliability and financial core' },
31
+ @{ Name='phase:B'; Color='a2eeef'; Description='Professional retail features' },
32
+ @{ Name='phase:C'; Color='f9d0c4'; Description='Industry modules and scale' },
33
+ @{ Name='priority:P0'; Color='b60205'; Description='Release-blocking financial integrity and safety' },
34
+ @{ Name='priority:P1'; Color='d93f0b'; Description='High priority professional retail or operations' },
35
+ @{ Name='priority:P2'; Color='fbca04'; Description='Planned later module' },
36
+ @{ Name='priority:P3'; Color='c2e0c6'; Description='Optional specialized extension' },
37
+ @{ Name='area:accounting'; Color='5319e7'; Description='Financial ledger and document lifecycle' },
38
+ @{ Name='area:retail'; Color='0e8a16'; Description='Retail POS, ordering and price workflows' },
39
+ @{ Name='area:inventory'; Color='1d76db'; Description='Inventory and warehouse valuation' },
40
+ @{ Name='area:enterprise'; Color='006b75'; Description='Enterprise and manufacturing architecture' },
41
+ @{ Name='area:operations'; Color='bfdadc'; Description='GitHub, CI, release and delivery operations' },
42
+ @{ Name='area:security'; Color='e99695'; Description='Audit, permissions and licensing' },
43
+ @{ Name='area:data'; Color='c5def5'; Description='Data integrity, backup and migrations' },
44
+ @{ Name='type:epic'; Color='7057ff'; Description='Phase-level delivery epic' },
45
+ @{ Name='type:design'; Color='fef2c0'; Description='Architecture decision record' },
46
+ @{ Name='type:feature'; Color='84b6eb'; Description='Product feature to be implemented' },
47
+ @{ Name='type:qa'; Color='d4e8c4'; Description='Acceptance and quality engineering' },
48
+ @{ Name='type:security'; Color='ee0701'; Description='Security-critical change' },
49
+ @{ Name='type:operations'; Color='ededed'; Description='Repository/CI management' },
50
+ @{ Name='status:planned'; Color='e4e669'; Description='Planned; not an implemented feature' }
51
+)
52
+$existingLabels = @(gh api ("repos/{0}/labels?per_page=100" -f $repo) | ConvertFrom-Json)
53
+foreach ($l in $labels) {
54
+ if (@($existingLabels | Where-Object { $_.name -eq $l.Name }).Count -eq 0) {
55
+ gh label create $l.Name --repo $repo --color $l.Color --description $l.Description
56
+ if ($LASTEXITCODE -ne 0) { throw ('Cannot create label ' + $l.Name) }
57
+ Write-Output ('CREATED_LABEL=' + $l.Name)
58
+ }
59
+}
60
+
61
+# Phase, priority, functional ownership and type for existing canonical issues.
62
+$assignments = @(
63
+ @{ N=2; Phase='A'; P='P0'; Area='accounting'; Type='epic' }
64
+ @{ N=3; Phase='B'; P='P1'; Area='retail'; Type='epic' }
65
+ @{ N=4; Phase='C'; P='P2'; Area='enterprise'; Type='epic' }
66
+ @{ N=5; Phase='A'; P='P0'; Area='accounting'; Type='design' }
67
+ @{ N=7; Phase='A'; P='P0'; Area='data'; Type='feature' }
68
+ @{ N=8; Phase='A'; P='P0'; Area='data'; Type='feature' }
69
+ @{ N=9; Phase='A'; P='P0'; Area='accounting'; Type='feature' }
70
+ @{ N=10; Phase='A'; P='P0'; Area='security'; Type='security' }
71
+ @{ N=11; Phase='A'; P='P0'; Area='accounting'; Type='feature' }
72
+ @{ N=12; Phase='A'; P='P0'; Area='security'; Type='security' }
73
+ @{ N=13; Phase='A'; P='P0'; Area='operations'; Type='qa' }
74
+ @{ N=14; Phase='A'; P='P0'; Area='operations'; Type='qa' }
75
+ @{ N=15; Phase='B'; P='P1'; Area='retail'; Type='feature' }
76
+ @{ N=16; Phase='B'; P='P1'; Area='retail'; Type='feature' }
77
+ @{ N=17; Phase='C'; P='P2'; Area='enterprise'; Type='design' }
78
+ @{ N=18; Phase='C'; P='P2'; Area='enterprise'; Type='design' }
79
+ @{ N=19; Phase='A'; P='P0'; Area='operations'; Type='operations' }
80
+ @{ N=20; Phase='A'; P='P1'; Area='operations'; Type='operations' }
81
+)
82
+foreach ($item in $assignments) {
83
+ $phase = @($phaseDefs | Where-Object { $_.Code -eq $item.Phase })[0]
84
+ $nameList = @('phase:'+$item.Phase,'priority:'+$item.P,'area:'+$item.Area,
85
+ 'type:'+$item.Type,'status:planned')
86
+ gh issue edit $item.N --repo $repo --milestone $phase.Title --add-label ($nameList -join ',') 1>$null
87
+ if ($LASTEXITCODE -ne 0) { throw ('Failed to assign issue #' + $item.N) }
88
+ Write-Output ('ASSIGNED_ISSUE=' + $item.N + ' PHASE=' + $item.Phase)
89
+}
90
+
91
+# Verify the three phase epics and the first design issue against the remote API.
92
+foreach ($item in @($assignments | Where-Object { $_.N -in @(2,3,4,5) })) {
93
+ $issue = gh issue view $item.N --repo $repo --json milestone,labels | ConvertFrom-Json
94
+ $phase = @($phaseDefs | Where-Object { $_.Code -eq $item.Phase })[0]
95
+ $names = @($issue.labels | ForEach-Object { $_.name })
96
+ if ($issue.milestone.title -ne $phase.Title -or
97
+ $names -notcontains ('phase:' + $item.Phase) -or
98
+ $names -notcontains ('priority:' + $item.P)) {
99
+ throw ('Verification failed for issue #' + $item.N)
100
+ }
101
+}
102
+Write-Output ('ROADMAP_METADATA_SYNC=SUCCESS;ISSUES=' + $assignments.Count + ';MILESTONES=' + $phaseDefs.Count)