Skip to content

Commit 1f80e42

Browse files
authored
Merge pull request #396 from architect/node22
fix: node22 and latest rcs
2 parents 94a2b19 + 589b936 commit 1f80e42

7 files changed

Lines changed: 164 additions & 15 deletions

File tree

.github/workflows/build.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ jobs:
1515
runs-on: ${{ matrix.os }}
1616
strategy:
1717
matrix:
18-
node-version: [ 20.x, 22.x, 24.x ]
18+
node-version: [ 22.x, 24.x ]
1919
os: [ windows-latest, ubuntu-latest, macOS-latest ]
2020

2121
# Go

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,3 +5,4 @@ package-lock.json
55
scratch/
66
test/mocks/app-with-extensions/sam.json
77
test/mocks/app-with-extensions/public/static.json
8+
.kiro

package.json

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@architect/deploy",
3-
"version": "6.0.0",
3+
"version": "7.0.0",
44
"description": "Deploys @architect projects",
55
"main": "index.js",
66
"bin": {
@@ -17,7 +17,7 @@
1717
"rc": "npm version prerelease --preid RC"
1818
},
1919
"engines": {
20-
"node": ">=20"
20+
"node": ">=22"
2121
},
2222
"repository": {
2323
"type": "git",
@@ -33,11 +33,11 @@
3333
},
3434
"homepage": "https://github.com/architect/deploy#readme",
3535
"dependencies": {
36-
"@architect/create": "~6.0.0",
37-
"@architect/hydrate": "~5.0.0",
38-
"@architect/inventory": "~5.0.0",
39-
"@architect/package": "~10.0.0",
40-
"@architect/utils": "~5.0.0",
36+
"@architect/create": "~7.0.0",
37+
"@architect/hydrate": "~6.0.0",
38+
"@architect/inventory": "~6.0.0",
39+
"@architect/package": "~11.0.0",
40+
"@architect/utils": "~6.0.0",
4141
"@aws-lite/apigatewayv2": "^0.0.9",
4242
"@aws-lite/client": "^0.23.2",
4343
"@aws-lite/cloudformation": "^0.1.3",
@@ -53,7 +53,7 @@
5353
"devDependencies": {
5454
"@architect/eslint-config": "~3.0.0",
5555
"cross-env": "~10.0.0",
56-
"eslint": "~9.36.0",
56+
"eslint": "~9.39.1",
5757
"mock-tmp": "~0.0.4",
5858
"nyc": "~17.1.0",
5959
"proxyquire": "~2.1.3",

src/direct/zip.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
var { globSync } = require('@architect/utils/glob')
1+
let { globSync } = require('node:fs')
22
let { series, pathToUnix } = require('@architect/utils')
33

44
var zipit = require('zipit')
@@ -22,7 +22,7 @@ function nixzip (pathToCode, callback) {
2222
function _read (callback) {
2323
try {
2424
let path = pathToUnix(pathToCode + '/*')
25-
let files = globSync(path, { dot: true })
25+
let files = globSync(path)
2626
callback(null, files)
2727
}
2828
catch (err) {

src/static/publish/index.js

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
let { globSync } = require('@architect/utils/glob')
1+
let { globSync, statSync } = require('node:fs')
22
let { pathToUnix, chalk, waterfall } = require('@architect/utils')
33

44
let { join, sep } = require('path')
@@ -69,7 +69,16 @@ module.exports = function publishStaticAssets (params, callback) {
6969
function _globAndFilter (callback) {
7070
try {
7171
let path = pathToUnix(publicDir + '/**/*')
72-
let globbed = globSync(path, { dot: true, nodir: true, follow: true })
72+
let globbed = globSync(path)
73+
// Filter out directories (native fs.globSync doesn't have nodir option)
74+
globbed = globbed.filter(filePath => {
75+
try {
76+
return statSync(filePath).isFile()
77+
}
78+
catch {
79+
return false
80+
}
81+
})
7382
// Filter based on default and user-specified @static ignore rules
7483
filterFiles({ globbed, ignore }, callback)
7584
}
Lines changed: 130 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,130 @@
1+
let test = require('tape')
2+
let { join } = require('path')
3+
let { mkdirSync, writeFileSync, rmSync, globSync, statSync } = require('node:fs')
4+
let { pathToUnix } = require('@architect/utils')
5+
6+
/**
7+
* Feature: migrate-to-fs-globsync, Property 1: Directory exclusion correctness
8+
* Validates: Requirements 2.2
9+
*
10+
* Property: For any glob pattern that requires directory exclusion,
11+
* all returned paths should be files and not directories
12+
*/
13+
14+
test('Property test: Directory exclusion correctness (100 iterations)', t => {
15+
const iterations = 100
16+
const testRoot = join(process.cwd(), '.test-property-temp')
17+
18+
// Clean up any previous test artifacts
19+
try {
20+
rmSync(testRoot, { recursive: true, force: true })
21+
}
22+
catch {
23+
// Ignore cleanup errors
24+
}
25+
26+
let passedIterations = 0
27+
let failedIterations = []
28+
29+
for (let i = 0; i < iterations; i++) {
30+
const testDir = join(testRoot, `iteration-${i}`)
31+
32+
try {
33+
// Create a test directory structure with varying complexity
34+
mkdirSync(testDir, { recursive: true })
35+
36+
// Generate random structure: files and directories
37+
const numFiles = Math.floor(Math.random() * 5) + 1
38+
const numDirs = Math.floor(Math.random() * 3) + 1
39+
40+
// Create files
41+
for (let f = 0; f < numFiles; f++) {
42+
const fileName = `file-${i}-${f}.txt`
43+
writeFileSync(join(testDir, fileName), `content ${i}-${f}`)
44+
}
45+
46+
// Create directories (some empty, some with files)
47+
for (let d = 0; d < numDirs; d++) {
48+
const dirName = `dir-${i}-${d}`
49+
const dirPath = join(testDir, dirName)
50+
mkdirSync(dirPath, { recursive: true })
51+
52+
// Randomly add files to some directories
53+
if (Math.random() > 0.5) {
54+
const nestedFile = `nested-${i}-${d}.txt`
55+
writeFileSync(join(dirPath, nestedFile), `nested content ${i}-${d}`)
56+
}
57+
}
58+
59+
// Apply the same filtering logic as in src/static/publish/index.js
60+
let path = pathToUnix(testDir + '/**/*')
61+
let globbed = globSync(path)
62+
63+
// Filter out directories (this is the logic we're testing)
64+
let filtered = globbed.filter(filePath => {
65+
try {
66+
return statSync(filePath).isFile()
67+
}
68+
catch {
69+
return false
70+
}
71+
})
72+
73+
// Property check: All filtered results must be files, not directories
74+
let allAreFiles = true
75+
let failedPath = null
76+
77+
for (let filePath of filtered) {
78+
try {
79+
const stats = statSync(filePath)
80+
if (!stats.isFile()) {
81+
allAreFiles = false
82+
failedPath = filePath
83+
break
84+
}
85+
}
86+
catch {
87+
// If we can't stat it, it shouldn't have been in the results
88+
allAreFiles = false
89+
failedPath = filePath
90+
break
91+
}
92+
}
93+
94+
if (allAreFiles) {
95+
passedIterations++
96+
}
97+
else {
98+
failedIterations.push({
99+
iteration: i,
100+
failedPath,
101+
message: `Found non-file in filtered results: ${failedPath}`,
102+
})
103+
}
104+
}
105+
catch (err) {
106+
failedIterations.push({
107+
iteration: i,
108+
error: err.message,
109+
})
110+
}
111+
}
112+
113+
// Clean up test artifacts
114+
try {
115+
rmSync(testRoot, { recursive: true, force: true })
116+
}
117+
catch {
118+
// Ignore cleanup errors
119+
}
120+
121+
// Report results
122+
t.equal(passedIterations, iterations,
123+
`All ${iterations} iterations should pass directory exclusion property`)
124+
125+
if (failedIterations.length > 0) {
126+
console.log('\nFailed iterations:', JSON.stringify(failedIterations, null, 2))
127+
}
128+
129+
t.end()
130+
})

test/unit/static/publish/s3/put-files/format-key-test.js

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
let test = require('tape')
22
let { join } = require('path')
3+
let { globSync, statSync } = require('node:fs')
34
let inventory = require('@architect/inventory')
45
let { pathToUnix } = require('@architect/utils')
5-
let { globSync } = require('@architect/utils/glob')
66

77
let sut = join(process.cwd(), 'src', 'static', 'publish', 's3', 'put-files', 'format-key.js')
88
let formatKey = require(sut)
@@ -40,7 +40,16 @@ test('Key pathing is correct on each platform', async t => {
4040
let publicDir = join(cwd, inv.inv.static.folder)
4141

4242
let path = pathToUnix(cwd) + `/${inv.inv.static.folder}/**/*`
43-
let files = globSync(path, { dot: true, nodir: true, follow: true })
43+
let allPaths = globSync(path)
44+
// Filter out directories to match nodir: true behavior
45+
let files = allPaths.filter(p => {
46+
try {
47+
return statSync(p).isFile()
48+
}
49+
catch {
50+
return false
51+
}
52+
})
4453
console.log(`Found these assets to derive keys for:`, files)
4554
t.plan(files.length * 2)
4655

0 commit comments

Comments
 (0)