@projectdochelp/s3te 3.1.3 → 3.1.4
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/README.md +23 -7
- package/package.json +1 -1
- package/packages/cli/src/project.mjs +45 -1
package/README.md
CHANGED
|
@@ -430,19 +430,35 @@ That workflow is meant for source publishing only:
|
|
|
430
430
|
|
|
431
431
|
Use a full `deploy` only when the infrastructure, environment config, or runtime package changes.
|
|
432
432
|
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
1.
|
|
436
|
-
2.
|
|
437
|
-
3.
|
|
438
|
-
4.
|
|
433
|
+
GitHub preparation checklist:
|
|
434
|
+
|
|
435
|
+
1. Push the project to GitHub together with `.github/workflows/s3te-sync.yml`.
|
|
436
|
+
2. Make sure GitHub Actions are allowed for the repository or organization.
|
|
437
|
+
3. Run the first real `npx s3te deploy --env <name>` so the code bucket already exists.
|
|
438
|
+
4. In AWS IAM, create an access key for a CI user that may sync only the S3TE code bucket for that environment.
|
|
439
|
+
5. In GitHub open `Settings -> Secrets and variables -> Actions -> Secrets`.
|
|
440
|
+
6. Add these repository secrets:
|
|
439
441
|
- `AWS_ACCESS_KEY_ID`
|
|
440
442
|
- `AWS_SECRET_ACCESS_KEY`
|
|
441
|
-
|
|
443
|
+
7. Open `.github/workflows/s3te-sync.yml` and adjust:
|
|
442
444
|
- the branch under `on.push.branches`
|
|
443
445
|
- `aws-region`
|
|
444
446
|
- `npx s3te sync --env dev` to your target environment such as `prod` or `test`
|
|
445
447
|
|
|
448
|
+
No GitHub variables are required by the scaffolded workflow. The code bucket name is resolved by S3TE from `s3te.config.json`, so you do not have to store bucket names in GitHub.
|
|
449
|
+
|
|
450
|
+
For projects with multiple environments such as `test` and `prod`, the simplest setup is usually one workflow file per target environment, for example:
|
|
451
|
+
|
|
452
|
+
- `.github/workflows/s3te-sync-test.yml` with `npx s3te sync --env test`
|
|
453
|
+
- `.github/workflows/s3te-sync-prod.yml` with `npx s3te sync --env prod`
|
|
454
|
+
|
|
455
|
+
First verification in GitHub:
|
|
456
|
+
|
|
457
|
+
1. Open the `Actions` tab in the repository.
|
|
458
|
+
2. Select `S3TE Sync`.
|
|
459
|
+
3. Start it once manually with `Run workflow`.
|
|
460
|
+
4. Check that the run reaches the `Configure AWS credentials`, `Validate project`, and `Sync project sources to the S3TE code bucket` steps without error.
|
|
461
|
+
|
|
446
462
|
Minimal IAM policy example for one code bucket:
|
|
447
463
|
|
|
448
464
|
```json
|
package/package.json
CHANGED
|
@@ -32,6 +32,21 @@ function normalizePath(value) {
|
|
|
32
32
|
return String(value).replace(/\\/g, "/");
|
|
33
33
|
}
|
|
34
34
|
|
|
35
|
+
function unknownEnvironmentMessage(config, environmentName) {
|
|
36
|
+
const knownEnvironments = Object.keys(config?.environments ?? {});
|
|
37
|
+
return `Unknown environment ${environmentName}. Known environments: ${knownEnvironments.length > 0 ? knownEnvironments.join(", ") : "(none)"}.`;
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
function assertKnownEnvironment(config, environmentName) {
|
|
41
|
+
if (!environmentName) {
|
|
42
|
+
return;
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
if (!config?.environments?.[environmentName]) {
|
|
46
|
+
throw new S3teError("CONFIG_CONFLICT_ERROR", unknownEnvironmentMessage(config, environmentName));
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
|
|
35
50
|
function normalizeBaseUrl(value) {
|
|
36
51
|
const trimmed = String(value).trim();
|
|
37
52
|
if (!trimmed) {
|
|
@@ -235,7 +250,11 @@ function schemaTemplate() {
|
|
|
235
250
|
}
|
|
236
251
|
|
|
237
252
|
function githubSyncWorkflowTemplate() {
|
|
238
|
-
return
|
|
253
|
+
return `# Before first use:
|
|
254
|
+
# 1. Run "npx s3te deploy --env dev" once so the S3TE code bucket already exists.
|
|
255
|
+
# 2. Add GitHub Actions secrets AWS_ACCESS_KEY_ID and AWS_SECRET_ACCESS_KEY.
|
|
256
|
+
# 3. Adjust branch, aws-region, and the target environment below.
|
|
257
|
+
name: S3TE Sync
|
|
239
258
|
|
|
240
259
|
on:
|
|
241
260
|
workflow_dispatch:
|
|
@@ -459,6 +478,18 @@ export async function loadResolvedConfig(projectDir, configPath) {
|
|
|
459
478
|
}
|
|
460
479
|
|
|
461
480
|
export async function validateProject(projectDir, config, options = {}) {
|
|
481
|
+
if (options.environment && !config?.environments?.[options.environment]) {
|
|
482
|
+
return {
|
|
483
|
+
ok: false,
|
|
484
|
+
errors: [{
|
|
485
|
+
code: "CONFIG_CONFLICT_ERROR",
|
|
486
|
+
message: unknownEnvironmentMessage(config, options.environment)
|
|
487
|
+
}],
|
|
488
|
+
warnings: [],
|
|
489
|
+
checkedTemplates: []
|
|
490
|
+
};
|
|
491
|
+
}
|
|
492
|
+
|
|
462
493
|
const templateRepository = new FileSystemTemplateRepository(projectDir, config);
|
|
463
494
|
const contentRepository = await loadLocalContent(projectDir, config);
|
|
464
495
|
const warnings = [];
|
|
@@ -595,6 +626,7 @@ export async function scaffoldProject(projectDir, options = {}) {
|
|
|
595
626
|
}
|
|
596
627
|
|
|
597
628
|
export async function renderProject(projectDir, config, options = {}) {
|
|
629
|
+
assertKnownEnvironment(config, options.environment);
|
|
598
630
|
const templateRepository = new FileSystemTemplateRepository(projectDir, config);
|
|
599
631
|
const contentRepository = await loadLocalContent(projectDir, config);
|
|
600
632
|
const outputRoot = path.join(projectDir, options.outputDir ?? config.rendering.outputDir);
|
|
@@ -700,6 +732,7 @@ export async function runProjectTests(projectDir) {
|
|
|
700
732
|
}
|
|
701
733
|
|
|
702
734
|
export async function packageProject(projectDir, config, options = {}) {
|
|
735
|
+
assertKnownEnvironment(config, options.environment);
|
|
703
736
|
return packageAwsProject({
|
|
704
737
|
projectDir,
|
|
705
738
|
config,
|
|
@@ -711,6 +744,7 @@ export async function packageProject(projectDir, config, options = {}) {
|
|
|
711
744
|
}
|
|
712
745
|
|
|
713
746
|
export async function deployProject(projectDir, config, options = {}) {
|
|
747
|
+
assertKnownEnvironment(config, options.environment);
|
|
714
748
|
return deployAwsProject({
|
|
715
749
|
projectDir,
|
|
716
750
|
config,
|
|
@@ -725,6 +759,7 @@ export async function deployProject(projectDir, config, options = {}) {
|
|
|
725
759
|
}
|
|
726
760
|
|
|
727
761
|
export async function syncProject(projectDir, config, options = {}) {
|
|
762
|
+
assertKnownEnvironment(config, options.environment);
|
|
728
763
|
return syncAwsProject({
|
|
729
764
|
projectDir,
|
|
730
765
|
config,
|
|
@@ -767,6 +802,15 @@ export async function doctorProject(projectDir, configPath, options = {}) {
|
|
|
767
802
|
}
|
|
768
803
|
|
|
769
804
|
if (options.environment && options.config) {
|
|
805
|
+
if (!options.config.environments?.[options.environment]) {
|
|
806
|
+
checks.push({
|
|
807
|
+
name: "environment",
|
|
808
|
+
ok: false,
|
|
809
|
+
message: unknownEnvironmentMessage(options.config, options.environment)
|
|
810
|
+
});
|
|
811
|
+
return checks;
|
|
812
|
+
}
|
|
813
|
+
|
|
770
814
|
try {
|
|
771
815
|
await ensureAwsCredentials({
|
|
772
816
|
region: options.config.environments[options.environment].awsRegion,
|