@awsless/awsless 0.0.1 → 0.0.2
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.
- package/dist/bin.cjs +71 -23
- package/dist/bin.js +68 -20
- package/package.json +3 -8
package/dist/bin.cjs
CHANGED
|
@@ -206,6 +206,9 @@ var toStack = ({ config: config2, assets, app, stackConfig, plugins }) => {
|
|
|
206
206
|
],
|
|
207
207
|
resources: [
|
|
208
208
|
import_aws_cdk_lib.Arn.format({
|
|
209
|
+
region: config2.region,
|
|
210
|
+
account: config2.account,
|
|
211
|
+
partition: "aws",
|
|
209
212
|
service: "ssm",
|
|
210
213
|
resource: "parameter",
|
|
211
214
|
resourceName: configParameterPrefix(config2)
|
|
@@ -1194,7 +1197,7 @@ var footer = () => {
|
|
|
1194
1197
|
};
|
|
1195
1198
|
|
|
1196
1199
|
// src/config.ts
|
|
1197
|
-
var
|
|
1200
|
+
var import_path9 = require("path");
|
|
1198
1201
|
|
|
1199
1202
|
// src/util/account.ts
|
|
1200
1203
|
var import_client_sts = require("@aws-sdk/client-sts");
|
|
@@ -1212,9 +1215,6 @@ var getCredentials = (profile) => {
|
|
|
1212
1215
|
});
|
|
1213
1216
|
};
|
|
1214
1217
|
|
|
1215
|
-
// src/config.ts
|
|
1216
|
-
var import_ts_import = require("ts-import");
|
|
1217
|
-
|
|
1218
1218
|
// src/schema/app.ts
|
|
1219
1219
|
var import_zod23 = require("zod");
|
|
1220
1220
|
|
|
@@ -1268,17 +1268,64 @@ var AppSchema = import_zod23.z.object({
|
|
|
1268
1268
|
plugins: import_zod23.z.array(PluginSchema).optional()
|
|
1269
1269
|
});
|
|
1270
1270
|
|
|
1271
|
+
// src/util/import.ts
|
|
1272
|
+
var import_core3 = require("@swc/core");
|
|
1273
|
+
var import_path7 = require("path");
|
|
1274
|
+
var import_promises4 = require("fs/promises");
|
|
1275
|
+
var resolveFileNameExtension = async (path) => {
|
|
1276
|
+
const options = [
|
|
1277
|
+
"",
|
|
1278
|
+
".ts",
|
|
1279
|
+
".js",
|
|
1280
|
+
"/index.ts",
|
|
1281
|
+
"/index.js"
|
|
1282
|
+
];
|
|
1283
|
+
for (const option of options) {
|
|
1284
|
+
const file = path + option;
|
|
1285
|
+
let stat;
|
|
1286
|
+
try {
|
|
1287
|
+
stat = await (0, import_promises4.lstat)(file);
|
|
1288
|
+
} catch (error) {
|
|
1289
|
+
continue;
|
|
1290
|
+
}
|
|
1291
|
+
if (stat.isFile()) {
|
|
1292
|
+
return file;
|
|
1293
|
+
}
|
|
1294
|
+
}
|
|
1295
|
+
throw new Error(`Failed to load file: ${path}`);
|
|
1296
|
+
};
|
|
1297
|
+
var resolveDir = (path) => {
|
|
1298
|
+
return (0, import_path7.dirname)(path).replace(rootDir + "/", "");
|
|
1299
|
+
};
|
|
1300
|
+
var importFile = async (path) => {
|
|
1301
|
+
const load = async (file) => {
|
|
1302
|
+
let { code: code2 } = await (0, import_core3.transformFile)(file);
|
|
1303
|
+
const path2 = (0, import_path7.dirname)(file);
|
|
1304
|
+
const dir = resolveDir(file);
|
|
1305
|
+
code2 = code2.replaceAll("__dirname", `"${dir}"`);
|
|
1306
|
+
const matches = code2.match(/import\s*{\s*[a-z0-9_]+\s*}\s*from\s*('|")(\.[\/a-z0-9_]+)('|");?/ig);
|
|
1307
|
+
if (!matches)
|
|
1308
|
+
return code2;
|
|
1309
|
+
await Promise.all(matches?.map(async (match) => {
|
|
1310
|
+
const parts = /('|")(\.[\/a-z0-9_]+)('|")/ig.exec(match);
|
|
1311
|
+
const from = parts[2];
|
|
1312
|
+
const file2 = await resolveFileNameExtension((0, import_path7.join)(path2, from));
|
|
1313
|
+
const result = await load(file2);
|
|
1314
|
+
code2 = code2.replace(match, result);
|
|
1315
|
+
}));
|
|
1316
|
+
return code2;
|
|
1317
|
+
};
|
|
1318
|
+
const code = await load(path);
|
|
1319
|
+
const outputFile = (0, import_path7.join)(outDir, "config.js");
|
|
1320
|
+
await (0, import_promises4.writeFile)(outputFile, code);
|
|
1321
|
+
return import(outputFile);
|
|
1322
|
+
};
|
|
1323
|
+
|
|
1271
1324
|
// src/config.ts
|
|
1272
1325
|
var importConfig = async (options) => {
|
|
1273
1326
|
debug("Import config file");
|
|
1274
|
-
const fileName = (0,
|
|
1275
|
-
const module2 = await (
|
|
1276
|
-
transpileOptions: {
|
|
1277
|
-
cache: {
|
|
1278
|
-
dir: (0, import_path7.join)(outDir, "config")
|
|
1279
|
-
}
|
|
1280
|
-
}
|
|
1281
|
-
});
|
|
1327
|
+
const fileName = (0, import_path9.join)(process.cwd(), options.configFile || "awsless.config.ts");
|
|
1328
|
+
const module2 = await importFile(fileName);
|
|
1282
1329
|
const appConfig = typeof module2.default === "function" ? await module2.default({
|
|
1283
1330
|
profile: options.profile,
|
|
1284
1331
|
region: options.region,
|
|
@@ -1296,7 +1343,6 @@ var importConfig = async (options) => {
|
|
|
1296
1343
|
}
|
|
1297
1344
|
}
|
|
1298
1345
|
const config2 = await schema2.parseAsync(appConfig);
|
|
1299
|
-
debug("Final config:", config2.stacks);
|
|
1300
1346
|
debug("Load credentials", style.info(config2.profile));
|
|
1301
1347
|
const credentials = getCredentials(config2.profile);
|
|
1302
1348
|
debug("Load AWS account ID");
|
|
@@ -1391,16 +1437,18 @@ var createSpinner = () => {
|
|
|
1391
1437
|
};
|
|
1392
1438
|
|
|
1393
1439
|
// src/cli/ui/layout/dialog.ts
|
|
1440
|
+
var import_wrap_ansi = __toESM(require("wrap-ansi"), 1);
|
|
1394
1441
|
var dialog = (type, lines) => {
|
|
1395
1442
|
const padding = 3;
|
|
1396
1443
|
const icon = style[type](symbol[type].padEnd(padding));
|
|
1397
|
-
return
|
|
1398
|
-
|
|
1399
|
-
|
|
1400
|
-
|
|
1401
|
-
|
|
1402
|
-
|
|
1403
|
-
|
|
1444
|
+
return (term) => {
|
|
1445
|
+
term.out.write(lines.map((line, i) => {
|
|
1446
|
+
if (i === 0) {
|
|
1447
|
+
return icon + (0, import_wrap_ansi.default)(line, term.out.width(), { hard: true });
|
|
1448
|
+
}
|
|
1449
|
+
return (0, import_wrap_ansi.default)(" ".repeat(padding) + line, term.out.width(), { hard: true });
|
|
1450
|
+
}).join(br()) + br());
|
|
1451
|
+
};
|
|
1404
1452
|
};
|
|
1405
1453
|
var loadingDialog = (message) => {
|
|
1406
1454
|
const [icon, stop] = createSpinner();
|
|
@@ -1730,19 +1778,19 @@ var assetBuilder = (assets) => {
|
|
|
1730
1778
|
};
|
|
1731
1779
|
|
|
1732
1780
|
// src/util/cleanup.ts
|
|
1733
|
-
var
|
|
1781
|
+
var import_promises5 = require("fs/promises");
|
|
1734
1782
|
var cleanUp = async () => {
|
|
1735
1783
|
debug("Clean up assembly & asset files");
|
|
1736
1784
|
const paths = [
|
|
1737
1785
|
assemblyDir,
|
|
1738
1786
|
functionDir
|
|
1739
1787
|
];
|
|
1740
|
-
await Promise.all(paths.map((path) => (0,
|
|
1788
|
+
await Promise.all(paths.map((path) => (0, import_promises5.rm)(path, {
|
|
1741
1789
|
recursive: true,
|
|
1742
1790
|
force: true,
|
|
1743
1791
|
maxRetries: 2
|
|
1744
1792
|
})));
|
|
1745
|
-
await Promise.all(paths.map((path) => (0,
|
|
1793
|
+
await Promise.all(paths.map((path) => (0, import_promises5.mkdir)(path, {
|
|
1746
1794
|
recursive: true
|
|
1747
1795
|
})));
|
|
1748
1796
|
};
|
package/dist/bin.js
CHANGED
|
@@ -187,6 +187,9 @@ var toStack = ({ config: config2, assets, app, stackConfig, plugins }) => {
|
|
|
187
187
|
],
|
|
188
188
|
resources: [
|
|
189
189
|
Arn.format({
|
|
190
|
+
region: config2.region,
|
|
191
|
+
account: config2.account,
|
|
192
|
+
partition: "aws",
|
|
190
193
|
service: "ssm",
|
|
191
194
|
resource: "parameter",
|
|
192
195
|
resourceName: configParameterPrefix(config2)
|
|
@@ -1172,7 +1175,7 @@ var footer = () => {
|
|
|
1172
1175
|
};
|
|
1173
1176
|
|
|
1174
1177
|
// src/config.ts
|
|
1175
|
-
import { join as
|
|
1178
|
+
import { join as join5 } from "path";
|
|
1176
1179
|
|
|
1177
1180
|
// src/util/account.ts
|
|
1178
1181
|
import { STSClient, GetCallerIdentityCommand } from "@aws-sdk/client-sts";
|
|
@@ -1190,9 +1193,6 @@ var getCredentials = (profile) => {
|
|
|
1190
1193
|
});
|
|
1191
1194
|
};
|
|
1192
1195
|
|
|
1193
|
-
// src/config.ts
|
|
1194
|
-
import { load } from "ts-import";
|
|
1195
|
-
|
|
1196
1196
|
// src/schema/app.ts
|
|
1197
1197
|
import { z as z23 } from "zod";
|
|
1198
1198
|
|
|
@@ -1246,17 +1246,64 @@ var AppSchema = z23.object({
|
|
|
1246
1246
|
plugins: z23.array(PluginSchema).optional()
|
|
1247
1247
|
});
|
|
1248
1248
|
|
|
1249
|
+
// src/util/import.ts
|
|
1250
|
+
import { transformFile } from "@swc/core";
|
|
1251
|
+
import { dirname, join as join4 } from "path";
|
|
1252
|
+
import { lstat, writeFile as writeFile2 } from "fs/promises";
|
|
1253
|
+
var resolveFileNameExtension = async (path) => {
|
|
1254
|
+
const options = [
|
|
1255
|
+
"",
|
|
1256
|
+
".ts",
|
|
1257
|
+
".js",
|
|
1258
|
+
"/index.ts",
|
|
1259
|
+
"/index.js"
|
|
1260
|
+
];
|
|
1261
|
+
for (const option of options) {
|
|
1262
|
+
const file = path + option;
|
|
1263
|
+
let stat;
|
|
1264
|
+
try {
|
|
1265
|
+
stat = await lstat(file);
|
|
1266
|
+
} catch (error) {
|
|
1267
|
+
continue;
|
|
1268
|
+
}
|
|
1269
|
+
if (stat.isFile()) {
|
|
1270
|
+
return file;
|
|
1271
|
+
}
|
|
1272
|
+
}
|
|
1273
|
+
throw new Error(`Failed to load file: ${path}`);
|
|
1274
|
+
};
|
|
1275
|
+
var resolveDir = (path) => {
|
|
1276
|
+
return dirname(path).replace(rootDir + "/", "");
|
|
1277
|
+
};
|
|
1278
|
+
var importFile = async (path) => {
|
|
1279
|
+
const load = async (file) => {
|
|
1280
|
+
let { code: code2 } = await transformFile(file);
|
|
1281
|
+
const path2 = dirname(file);
|
|
1282
|
+
const dir = resolveDir(file);
|
|
1283
|
+
code2 = code2.replaceAll("__dirname", `"${dir}"`);
|
|
1284
|
+
const matches = code2.match(/import\s*{\s*[a-z0-9_]+\s*}\s*from\s*('|")(\.[\/a-z0-9_]+)('|");?/ig);
|
|
1285
|
+
if (!matches)
|
|
1286
|
+
return code2;
|
|
1287
|
+
await Promise.all(matches?.map(async (match) => {
|
|
1288
|
+
const parts = /('|")(\.[\/a-z0-9_]+)('|")/ig.exec(match);
|
|
1289
|
+
const from = parts[2];
|
|
1290
|
+
const file2 = await resolveFileNameExtension(join4(path2, from));
|
|
1291
|
+
const result = await load(file2);
|
|
1292
|
+
code2 = code2.replace(match, result);
|
|
1293
|
+
}));
|
|
1294
|
+
return code2;
|
|
1295
|
+
};
|
|
1296
|
+
const code = await load(path);
|
|
1297
|
+
const outputFile = join4(outDir, "config.js");
|
|
1298
|
+
await writeFile2(outputFile, code);
|
|
1299
|
+
return import(outputFile);
|
|
1300
|
+
};
|
|
1301
|
+
|
|
1249
1302
|
// src/config.ts
|
|
1250
1303
|
var importConfig = async (options) => {
|
|
1251
1304
|
debug("Import config file");
|
|
1252
|
-
const fileName =
|
|
1253
|
-
const module = await
|
|
1254
|
-
transpileOptions: {
|
|
1255
|
-
cache: {
|
|
1256
|
-
dir: join4(outDir, "config")
|
|
1257
|
-
}
|
|
1258
|
-
}
|
|
1259
|
-
});
|
|
1305
|
+
const fileName = join5(process.cwd(), options.configFile || "awsless.config.ts");
|
|
1306
|
+
const module = await importFile(fileName);
|
|
1260
1307
|
const appConfig = typeof module.default === "function" ? await module.default({
|
|
1261
1308
|
profile: options.profile,
|
|
1262
1309
|
region: options.region,
|
|
@@ -1274,7 +1321,6 @@ var importConfig = async (options) => {
|
|
|
1274
1321
|
}
|
|
1275
1322
|
}
|
|
1276
1323
|
const config2 = await schema2.parseAsync(appConfig);
|
|
1277
|
-
debug("Final config:", config2.stacks);
|
|
1278
1324
|
debug("Load credentials", style.info(config2.profile));
|
|
1279
1325
|
const credentials = getCredentials(config2.profile);
|
|
1280
1326
|
debug("Load AWS account ID");
|
|
@@ -1369,16 +1415,18 @@ var createSpinner = () => {
|
|
|
1369
1415
|
};
|
|
1370
1416
|
|
|
1371
1417
|
// src/cli/ui/layout/dialog.ts
|
|
1418
|
+
import wrapAnsi from "wrap-ansi";
|
|
1372
1419
|
var dialog = (type, lines) => {
|
|
1373
1420
|
const padding = 3;
|
|
1374
1421
|
const icon = style[type](symbol[type].padEnd(padding));
|
|
1375
|
-
return
|
|
1376
|
-
|
|
1377
|
-
|
|
1378
|
-
|
|
1379
|
-
|
|
1380
|
-
|
|
1381
|
-
|
|
1422
|
+
return (term) => {
|
|
1423
|
+
term.out.write(lines.map((line, i) => {
|
|
1424
|
+
if (i === 0) {
|
|
1425
|
+
return icon + wrapAnsi(line, term.out.width(), { hard: true });
|
|
1426
|
+
}
|
|
1427
|
+
return wrapAnsi(" ".repeat(padding) + line, term.out.width(), { hard: true });
|
|
1428
|
+
}).join(br()) + br());
|
|
1429
|
+
};
|
|
1382
1430
|
};
|
|
1383
1431
|
var loadingDialog = (message) => {
|
|
1384
1432
|
const [icon, stop] = createSpinner();
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@awsless/awsless",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.2",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"repository": {
|
|
@@ -30,20 +30,15 @@
|
|
|
30
30
|
"@aws-sdk/client-ssm": "3.329.0",
|
|
31
31
|
"@aws-sdk/client-sts": "^3.369.0",
|
|
32
32
|
"@aws-sdk/credential-providers": "^3.369.0",
|
|
33
|
-
"@
|
|
33
|
+
"@swc/core": "^1.3.70",
|
|
34
34
|
"aws-cdk-lib": "^2.87.0",
|
|
35
35
|
"aws-cron-expression-validator": "^1.0.5",
|
|
36
36
|
"chalk": "^5.3.0",
|
|
37
37
|
"change-case": "^4.1.2",
|
|
38
38
|
"commander": "^9.4.1",
|
|
39
39
|
"filesize": "^10.0.7",
|
|
40
|
-
"ink": "^4.3.0",
|
|
41
|
-
"ink-spinner": "^5.0.0",
|
|
42
|
-
"ink-table": "^3.0.0",
|
|
43
|
-
"ink-text-input": "^5.0.1",
|
|
44
40
|
"jszip": "^3.10.1",
|
|
45
|
-
"
|
|
46
|
-
"ts-import": "5.0.0-beta.0",
|
|
41
|
+
"wrap-ansi": "^8.1.0",
|
|
47
42
|
"zod": "^3.21.4",
|
|
48
43
|
"@awsless/code": "^0.0.10"
|
|
49
44
|
},
|