@diquattro/cfnassets 0.6.6 → 0.6.7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"getPackageEntries.d.ts","sourceRoot":"","sources":["../../../src/core/zip/getPackageEntries.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"getPackageEntries.d.ts","sourceRoot":"","sources":["../../../src/core/zip/getPackageEntries.ts"],"names":[],"mappings":"AAMA,OAAO,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAC;AAEnD,MAAM,WAAW,qBAAqB;IACpC,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,WAAW,CAAC,EAAE,MAAM,EAAE,CAAC;IACvB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,eAAe,EAAE,MAAM,CAAC;IACxB,eAAe,CAAC,EAAE,MAAM,CAAC;IACzB,eAAe,EAAE,MAAM,CAAC;IACxB,YAAY,EAAE,MAAM,EAAE,CAAC;CACxB;AAED,wBAAuB,iBAAiB,CAAC,EACvC,WAA4B,EAC5B,WAAW,EACX,eAAe,EACf,eAAe,EACf,WAAW,EACX,eAAe,EACf,YAAY,GACb,EAAE,qBAAqB,GAAG,qBAAqB,CAAC,aAAa,CAAC,CAoF9D"}
|
|
@@ -3,10 +3,10 @@ import childProc from 'child_process';
|
|
|
3
3
|
import { copyFile, readFile, writeFile } from 'fs/promises';
|
|
4
4
|
import { basename, join } from 'path';
|
|
5
5
|
import { temporaryDirectory } from 'tempy';
|
|
6
|
-
import { parse as parseYaml } from 'yaml';
|
|
7
6
|
import { getFolderEntries } from './getFolderEntries.js';
|
|
8
7
|
export async function* getPackageEntries({ archivePath = 'node_modules', ignorePaths, packageLockPath, packageFilePath, packageArch, packagePlatform, packageNames, }) {
|
|
9
8
|
let exec;
|
|
9
|
+
let copyLockfile = true;
|
|
10
10
|
const npmConfig = [];
|
|
11
11
|
const lockBasename = basename(packageLockPath);
|
|
12
12
|
if (lockBasename === 'package-lock.json') {
|
|
@@ -16,7 +16,10 @@ export async function* getPackageEntries({ archivePath = 'node_modules', ignoreP
|
|
|
16
16
|
exec = ['yarn', '--frozen-lockfile'];
|
|
17
17
|
}
|
|
18
18
|
else if (lockBasename === 'pnpm-lock.yaml') {
|
|
19
|
-
|
|
19
|
+
// Use npm install for pnpm projects - creates a flat node_modules structure
|
|
20
|
+
// that works reliably on Lambda without needing to replicate pnpm's symlink structure
|
|
21
|
+
exec = ['npm', 'install'];
|
|
22
|
+
copyLockfile = false;
|
|
20
23
|
}
|
|
21
24
|
else {
|
|
22
25
|
throw new Error(`unknown lockfile type for path '${packageLockPath}'`);
|
|
@@ -43,7 +46,9 @@ export async function* getPackageEntries({ archivePath = 'node_modules', ignoreP
|
|
|
43
46
|
}
|
|
44
47
|
const outDir = temporaryDirectory();
|
|
45
48
|
await writeFile(join(outDir, 'package.json'), JSON.stringify(newPackageJson));
|
|
46
|
-
|
|
49
|
+
if (copyLockfile) {
|
|
50
|
+
await copyFile(packageLockPath, join(outDir, lockBasename));
|
|
51
|
+
}
|
|
47
52
|
if (npmConfig.length) {
|
|
48
53
|
await writeFile(join(outDir, '.npmrc'), npmConfig.join('\n') + '\n');
|
|
49
54
|
}
|
|
@@ -65,40 +70,10 @@ export async function* getPackageEntries({ archivePath = 'node_modules', ignoreP
|
|
|
65
70
|
});
|
|
66
71
|
});
|
|
67
72
|
console.log(`\n`);
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
// and lists what should be hoisted in .modules.yaml
|
|
74
|
-
const modulesYamlPath = join(nodeModulesDir, '.modules.yaml');
|
|
75
|
-
const modulesYaml = parseYaml(await readFile(modulesYamlPath, 'utf-8'));
|
|
76
|
-
const hoisted = modulesYaml.hoistedDependencies || {};
|
|
77
|
-
// First yield the .pnpm directory contents (the actual package files)
|
|
78
|
-
yield* getFolderEntries({
|
|
79
|
-
source: join(nodeModulesDir, '.pnpm'),
|
|
80
|
-
archivePath: join(archivePath, '.pnpm'),
|
|
81
|
-
ignore: ignorePaths,
|
|
82
|
-
});
|
|
83
|
-
// Then yield entries for each hoisted dependency at root level
|
|
84
|
-
for (const [packageAtVersion, aliases] of Object.entries(hoisted)) {
|
|
85
|
-
for (const packageName of Object.keys(aliases)) {
|
|
86
|
-
const sourcePath = join(nodeModulesDir, '.pnpm', packageAtVersion, 'node_modules', packageName);
|
|
87
|
-
yield* getFolderEntries({
|
|
88
|
-
source: sourcePath,
|
|
89
|
-
archivePath: join(archivePath, packageName),
|
|
90
|
-
ignore: ignorePaths,
|
|
91
|
-
});
|
|
92
|
-
}
|
|
93
|
-
}
|
|
94
|
-
}
|
|
95
|
-
else {
|
|
96
|
-
// For npm/yarn, just copy the whole node_modules directory
|
|
97
|
-
yield* getFolderEntries({
|
|
98
|
-
source: nodeModulesDir,
|
|
99
|
-
archivePath,
|
|
100
|
-
ignore: ignorePaths,
|
|
101
|
-
});
|
|
102
|
-
}
|
|
73
|
+
yield* getFolderEntries({
|
|
74
|
+
source: join(outDir, 'node_modules'),
|
|
75
|
+
archivePath,
|
|
76
|
+
ignore: ignorePaths,
|
|
77
|
+
});
|
|
103
78
|
}
|
|
104
79
|
//# sourceMappingURL=getPackageEntries.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"getPackageEntries.js","sourceRoot":"","sources":["../../../src/core/zip/getPackageEntries.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,SAAS,MAAM,eAAe,CAAC;AACtC,OAAO,EAAE,QAAQ,EAAE,QAAQ,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AAC5D,OAAO,EAAE,QAAQ,EAAE,IAAI,EAAE,MAAM,MAAM,CAAC;AACtC,OAAO,EAAE,kBAAkB,EAAE,MAAM,OAAO,CAAC;AAC3C,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"getP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CAAC,IAAI,CAAC,CAAC;IACnC,OAAO,CAAC,GAAG,CAAC,KAAK,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,GAAG,GAAG,UAAU,CAAC,IAAI,KAAK,CAAC,IAAI,CAAC,KAAK,CAAC,EAAE,CAAC,CAAC;IAE3E,MAAM,IAAI,GAAG,SAAS,CAAC,KAAK,CAAC,GAAG,EAAE,IAAI,EAAE;QACtC,GAAG,EAAE,MAAM;QACX,KAAK,EAAE,SAAS;KACjB,CAAC,CAAC;IAEH,MAAM,IAAI,OAAO,CAAO,CAAC,OAAO,EAAE,MAAM,EAAE,EAAE;QAC1C,IAAI,CAAC,EAAE,CAAC,OAAO,EAAE,CAAC,IAAI,EAAE,EAAE;YACxB,IAAI,IAAI,KAAK,CAAC,EAAE;gBACd,OAAO,EAAE,CAAC;aACX;iBAAM;gBACL,MAAM,CAAC,IAAI,KAAK,CAAC,uCAAuC,IAAI,EAAE,CAAC,CAAC,CAAC;aAClE;QACH,CAAC,CAAC,CAAC;IACL,CAAC,CAAC,CAAC;IAEH,OAAO,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC;IAElB,KAAK,CAAC,CAAC,gBAAgB,CAAC;QACtB,MAAM,EAAE,IAAI,CAAC,MAAM,EAAE,cAAc,CAAC;QACpC,WAAW;QACX,MAAM,EAAE,WAAW;KACpB,CAAC,CAAC;AACL,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@diquattro/cfnassets",
|
|
3
|
-
"version": "0.6.
|
|
3
|
+
"version": "0.6.7",
|
|
4
4
|
"description": "Build asset zip packages for deployment. Fork of @awboost/cfnassets with pnpm support.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"repository": {
|
|
@@ -66,7 +66,6 @@
|
|
|
66
66
|
"ignore": "^5.2.0",
|
|
67
67
|
"rollup": "^2.73.0",
|
|
68
68
|
"tempy": "^3.0.0",
|
|
69
|
-
"tiny-typed-emitter": "^2.1.0"
|
|
70
|
-
"yaml": "^2.8.2"
|
|
69
|
+
"tiny-typed-emitter": "^2.1.0"
|
|
71
70
|
}
|
|
72
71
|
}
|
|
@@ -3,7 +3,6 @@ import childProc from 'child_process';
|
|
|
3
3
|
import { copyFile, readFile, writeFile } from 'fs/promises';
|
|
4
4
|
import { basename, join } from 'path';
|
|
5
5
|
import { temporaryDirectory } from 'tempy';
|
|
6
|
-
import { parse as parseYaml } from 'yaml';
|
|
7
6
|
import { getFolderEntries } from './getFolderEntries.js';
|
|
8
7
|
import { ZipAssetEntry } from './ZipAssetEntry.js';
|
|
9
8
|
|
|
@@ -27,6 +26,7 @@ export async function* getPackageEntries({
|
|
|
27
26
|
packageNames,
|
|
28
27
|
}: PackageEntriesOptions): AsyncIterableIterator<ZipAssetEntry> {
|
|
29
28
|
let exec: string[];
|
|
29
|
+
let copyLockfile = true;
|
|
30
30
|
const npmConfig: string[] = [];
|
|
31
31
|
|
|
32
32
|
const lockBasename = basename(packageLockPath);
|
|
@@ -35,7 +35,10 @@ export async function* getPackageEntries({
|
|
|
35
35
|
} else if (lockBasename === 'yarn.lock') {
|
|
36
36
|
exec = ['yarn', '--frozen-lockfile'];
|
|
37
37
|
} else if (lockBasename === 'pnpm-lock.yaml') {
|
|
38
|
-
|
|
38
|
+
// Use npm install for pnpm projects - creates a flat node_modules structure
|
|
39
|
+
// that works reliably on Lambda without needing to replicate pnpm's symlink structure
|
|
40
|
+
exec = ['npm', 'install'];
|
|
41
|
+
copyLockfile = false;
|
|
39
42
|
} else {
|
|
40
43
|
throw new Error(`unknown lockfile type for path '${packageLockPath}'`);
|
|
41
44
|
}
|
|
@@ -69,7 +72,10 @@ export async function* getPackageEntries({
|
|
|
69
72
|
|
|
70
73
|
const outDir = temporaryDirectory();
|
|
71
74
|
await writeFile(join(outDir, 'package.json'), JSON.stringify(newPackageJson));
|
|
72
|
-
|
|
75
|
+
|
|
76
|
+
if (copyLockfile) {
|
|
77
|
+
await copyFile(packageLockPath, join(outDir, lockBasename));
|
|
78
|
+
}
|
|
73
79
|
|
|
74
80
|
if (npmConfig.length) {
|
|
75
81
|
await writeFile(join(outDir, '.npmrc'), npmConfig.join('\n') + '\n');
|
|
@@ -97,50 +103,9 @@ export async function* getPackageEntries({
|
|
|
97
103
|
|
|
98
104
|
console.log(`\n`);
|
|
99
105
|
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
// pnpm stores packages in .pnpm/{name}@{version}/node_modules/{name}/
|
|
106
|
-
// and lists what should be hoisted in .modules.yaml
|
|
107
|
-
const modulesYamlPath = join(nodeModulesDir, '.modules.yaml');
|
|
108
|
-
const modulesYaml = parseYaml(await readFile(modulesYamlPath, 'utf-8')) as {
|
|
109
|
-
hoistedDependencies?: Record<string, Record<string, string>>;
|
|
110
|
-
};
|
|
111
|
-
|
|
112
|
-
const hoisted = modulesYaml.hoistedDependencies || {};
|
|
113
|
-
|
|
114
|
-
// First yield the .pnpm directory contents (the actual package files)
|
|
115
|
-
yield* getFolderEntries({
|
|
116
|
-
source: join(nodeModulesDir, '.pnpm'),
|
|
117
|
-
archivePath: join(archivePath, '.pnpm'),
|
|
118
|
-
ignore: ignorePaths,
|
|
119
|
-
});
|
|
120
|
-
|
|
121
|
-
// Then yield entries for each hoisted dependency at root level
|
|
122
|
-
for (const [packageAtVersion, aliases] of Object.entries(hoisted)) {
|
|
123
|
-
for (const packageName of Object.keys(aliases)) {
|
|
124
|
-
const sourcePath = join(
|
|
125
|
-
nodeModulesDir,
|
|
126
|
-
'.pnpm',
|
|
127
|
-
packageAtVersion,
|
|
128
|
-
'node_modules',
|
|
129
|
-
packageName,
|
|
130
|
-
);
|
|
131
|
-
yield* getFolderEntries({
|
|
132
|
-
source: sourcePath,
|
|
133
|
-
archivePath: join(archivePath, packageName),
|
|
134
|
-
ignore: ignorePaths,
|
|
135
|
-
});
|
|
136
|
-
}
|
|
137
|
-
}
|
|
138
|
-
} else {
|
|
139
|
-
// For npm/yarn, just copy the whole node_modules directory
|
|
140
|
-
yield* getFolderEntries({
|
|
141
|
-
source: nodeModulesDir,
|
|
142
|
-
archivePath,
|
|
143
|
-
ignore: ignorePaths,
|
|
144
|
-
});
|
|
145
|
-
}
|
|
106
|
+
yield* getFolderEntries({
|
|
107
|
+
source: join(outDir, 'node_modules'),
|
|
108
|
+
archivePath,
|
|
109
|
+
ignore: ignorePaths,
|
|
110
|
+
});
|
|
146
111
|
}
|