Skip to content

Commit 990e334

Browse files
aledbfclaude
andcommitted
fix(features): resolve Features in the configuration's declaration order
The reference builds its Feature list from Object.keys(config.features) followed by the --additional-features ids the configuration does not name, so integer-like ids come first, ascending, and the others keep their declaration order. Go sorted the ids, and features resolve-dependencies took Go map order. That decides which Feature is processed first: the first failing Feature reported, the order of the log lines and of the dependency graph's worklist. The loader now records the order of the features keys across the configuration and its override, mergeAdditionalFeatures appends the additional ids after them, and every resolution (up, build, read-configuration, upgrade, features resolve-dependencies) follows it. build no longer checks every id for a legacy one before resolving: the reference reports the first failing Feature in that order, after the image pull. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
1 parent 4660f5f commit 990e334

21 files changed

Lines changed: 238 additions & 58 deletions

‎docs/migration.md‎

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -201,6 +201,13 @@ runs the official CLI is unaffected:
201201
- Only a registry whose host is `localhost` is reached over plain HTTP. Earlier
202202
releases also used plain HTTP for `127.0.0.1`, which is now addressed over HTTPS
203203
like any other host. Refer to a local plain-HTTP registry as `localhost:<port>`.
204+
- Features are resolved in the order the configuration declares them, as the
205+
official CLI resolves them: integer-like ids such as `"9"` first, ascending,
206+
then the others in declaration order, followed by the `--additional-features`
207+
ids the configuration does not name. When several Features fail, the one
208+
reported is the first in that order; earlier releases reported the first by
209+
sorted id. `build` no longer reports a legacy Feature id before trying the
210+
Features declared ahead of it, or before pulling the image.
204211

205212
## Rollback
206213

‎docs/parity/parity-matrix.yaml‎

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -962,6 +962,58 @@ initial_cases:
962962
current_status: match
963963
notes: "With the configuration at the workspace root (.devcontainer.json), './feat' resolves outside the .devcontainer folder, which processFeatureIdentifier refuses; build reports the plain Error buildDependencyGraph throws as its message: {\"outcome\":\"error\",\"message\":\"ERR: Feature './feat' could not be processed. You may not have permission ...\",\"description\":\"An error occurred building the container.\"}, exit 1. Go used to build the Feature."
964964

965+
- id: features.resolve-dependencies-declaration-order-success
966+
lane: contract
967+
command: features
968+
priority: p1
969+
docker_required: false
970+
setup_cmd: "WORKSPACE=/tmp/parity-${PARITY_CASE_ID}-${PARITY_SIDE}; rm -rf $WORKSPACE; mkdir -p $WORKSPACE/.devcontainer/zeta $WORKSPACE/.devcontainer/alpha $WORKSPACE/.devcontainer/mid $WORKSPACE/.devcontainer/beta $WORKSPACE/.devcontainer/omega; printf '%s' '{\"id\":\"zeta\",\"version\":\"1.0.0\"}' > $WORKSPACE/.devcontainer/zeta/devcontainer-feature.json; printf '%s' '{\"id\":\"alpha\",\"version\":\"1.0.0\"}' > $WORKSPACE/.devcontainer/alpha/devcontainer-feature.json; printf '%s' '{\"id\":\"mid\",\"version\":\"1.0.0\"}' > $WORKSPACE/.devcontainer/mid/devcontainer-feature.json; printf '%s' '{\"id\":\"beta\",\"version\":\"1.0.0\"}' > $WORKSPACE/.devcontainer/beta/devcontainer-feature.json; printf '%s' '{\"id\":\"omega\",\"version\":\"1.0.0\"}' > $WORKSPACE/.devcontainer/omega/devcontainer-feature.json; printf '%s' '{\"image\":\"alpine:3\",\"features\":{\"./zeta\":{},\"./alpha\":{},\"./mid\":{},\"./beta\":{},\"./omega\":{}}}' > $WORKSPACE/.devcontainer/devcontainer.json; echo WORKSPACE=$WORKSPACE"
971+
cleanup_cmd: "rm -rf /tmp/parity-${PARITY_CASE_ID}-${PARITY_SIDE}"
972+
ts_cmd: "features resolve-dependencies --workspace-folder ${WORKSPACE}"
973+
asserts: [exit_code, stdout_text]
974+
class: features
975+
current_status: match
976+
notes: "userFeaturesToArray (containerFeaturesConfiguration.ts) lists the configuration's Features in Object.keys order, and the mermaid graph lists the dependency graph's worklist in that order: ./zeta, ./alpha, ./mid, ./beta, ./omega. Go used to take them in Go map order."
977+
978+
- id: build.features-first-failure-in-declaration-order-error
979+
lane: runtime
980+
command: build
981+
priority: p1
982+
docker_required: true
983+
setup_cmd: "WORKSPACE=/tmp/parity-${PARITY_CASE_ID}-${PARITY_SIDE}; rm -rf $WORKSPACE; mkdir -p $WORKSPACE/.devcontainer $WORKSPACE/zeta; printf '%s' '{\"image\":\"alpine:3\",\"features\":{\"../zeta\":{},\"zz\":{}}}' > $WORKSPACE/.devcontainer/devcontainer.json; echo WORKSPACE=$WORKSPACE"
984+
cleanup_cmd: "rm -rf /tmp/parity-${PARITY_CASE_ID}-${PARITY_SIDE}"
985+
ts_cmd: "build --workspace-folder ${WORKSPACE}"
986+
asserts: [exit_code, stdout_normalized]
987+
class: features
988+
current_status: match
989+
notes: "Features are processed in Object.keys order and the first that fails is reported: '../zeta' is refused (outside .devcontainer) before the legacy id 'zz' is classified, so build reports ERR: Feature '../zeta' could not be processed. Go used to check every id for a legacy one before resolving any Feature and reported 'Legacy feature 'zz' not supported.'."
990+
991+
- id: build.features-integer-like-ids-first-error
992+
lane: runtime
993+
command: build
994+
priority: p1
995+
docker_required: true
996+
setup_cmd: "WORKSPACE=/tmp/parity-${PARITY_CASE_ID}-${PARITY_SIDE}; rm -rf $WORKSPACE; mkdir -p $WORKSPACE/.devcontainer; printf '%s' '{\"image\":\"alpine:3\",\"features\":{\"../zeta\":{},\"10\":{},\"9\":{}}}' > $WORKSPACE/.devcontainer/devcontainer.json; echo WORKSPACE=$WORKSPACE"
997+
cleanup_cmd: "rm -rf /tmp/parity-${PARITY_CASE_ID}-${PARITY_SIDE}"
998+
ts_cmd: "build --workspace-folder ${WORKSPACE}"
999+
asserts: [exit_code, stdout_normalized]
1000+
class: features
1001+
current_status: match
1002+
notes: "Object.keys lists integer-like keys first, ascending, so '9' is processed first and build reports 'Legacy feature '9' not supported.'. Go used to sort the ids and reported '10'."
1003+
1004+
- id: build.additional-features-after-config-error
1005+
lane: runtime
1006+
command: build
1007+
priority: p1
1008+
docker_required: true
1009+
setup_cmd: "WORKSPACE=/tmp/parity-${PARITY_CASE_ID}-${PARITY_SIDE}; rm -rf $WORKSPACE; mkdir -p $WORKSPACE/.devcontainer $WORKSPACE/zeta $WORKSPACE/alpha; printf '%s' '{\"image\":\"alpine:3\",\"features\":{\"../zeta\":{}}}' > $WORKSPACE/.devcontainer/devcontainer.json; echo WORKSPACE=$WORKSPACE"
1010+
cleanup_cmd: "rm -rf /tmp/parity-${PARITY_CASE_ID}-${PARITY_SIDE}"
1011+
ts_cmd: "build --workspace-folder ${WORKSPACE} --additional-features '{\"../alpha\":{}}'"
1012+
asserts: [exit_code, stdout_normalized]
1013+
class: features
1014+
current_status: match
1015+
notes: "userFeaturesToArray appends the --additional-features ids after the configuration's, so '../zeta' is processed and refused first. Go used to sort the merged ids and reported '../alpha'."
1016+
9651017
- id: up.update-uid-remote-user-from-image-metadata-success
9661018
lane: runtime
9671019
command: up

‎internal/cli/build.go‎

Lines changed: 1 addition & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@ import (
1212
"github.com/devcontainers/cli/internal/config"
1313
"github.com/devcontainers/cli/internal/docker"
1414
coreerrors "github.com/devcontainers/cli/internal/errors"
15-
"github.com/devcontainers/cli/internal/features"
1615
"github.com/devcontainers/cli/internal/imagemeta"
1716
"github.com/devcontainers/cli/internal/log"
1817
"github.com/devcontainers/cli/internal/stringify"
@@ -329,10 +328,6 @@ func (r *buildRunner) buildImage(ctx context.Context, cfg *config.DevContainer,
329328
return nil, fmt.Errorf("no image specified in devcontainer.json")
330329
}
331330

332-
if err := checkLegacyFeatures(cfg.Features); err != nil {
333-
return nil, err
334-
}
335-
336331
logger.Write(fmt.Sprintf("Using image: %s", cfg.Image), log.LevelInfo)
337332

338333
folderImage := folderImageName(resolvePath(opts.workspaceFolder))
@@ -456,17 +451,6 @@ func imageBuildFor(cfg *config.DevContainer, opts *buildOpts) imageBuild {
456451
return imageAsIs
457452
}
458453

459-
func checkLegacyFeatures(feats map[string]any) error {
460-
userFeatures, _ := features.UpdateDeprecatedFeaturesIntoOptions(sortedUserFeatures(feats, nil))
461-
for _, f := range userFeatures {
462-
id, _ := features.BackwardCompatibleID(f.UserFeatureID)
463-
if features.ClassifyID(id) == features.SourceLegacyShorthand {
464-
return &coreerrors.ContainerError{Description: fmt.Sprintf(msgLegacyFeature, id)}
465-
}
466-
}
467-
return nil
468-
}
469-
470454
func imageNamesOr(names []string, fallback string) []string {
471455
if len(names) == 0 {
472456
return []string{fallback}
@@ -693,6 +677,7 @@ func (r *buildRunner) featureBuildOptions(cfg *config.DevContainer, hostSub *con
693677
Output: opts.output,
694678
ContainerEnv: cfg.ContainerEnv,
695679
ContainerEnvOrder: cfg.ContainerEnvOrder,
680+
FeatureOrder: cfg.FeatureOrder,
696681
FeatureOptionOrder: cfg.FeatureOptionOrder,
697682
FrozenLockfile: opts.experimentalFrozenLockfile,
698683
NoLockfile: opts.noLockfile,

‎internal/cli/build_held_test.go‎

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -106,14 +106,14 @@ func TestImageBuildFor(t *testing.T) {
106106
}
107107
}
108108

109-
func TestCheckLegacyFeatures(t *testing.T) {
110-
for _, id := range []string{"node", "golang", "gradle", "ghcr.io/devcontainers/features/node:1", "./local-feature", "owner/repo/feature"} {
111-
if err := checkLegacyFeatures(map[string]any{id: true}); err != nil {
109+
func TestResolveFeatureIDRefusesLegacyIDs(t *testing.T) {
110+
for _, id := range []string{"node", "golang", "ghcr.io/devcontainers/features/node:1", "./local-feature", "owner/repo/feature"} {
111+
if _, _, err := resolveFeatureID(log.Null, id); err != nil {
112112
t.Errorf("%s: unexpected error %v", id, err)
113113
}
114114
}
115115
for _, id := range []string{"not-a-feature", "not-a-feature:1", "node:1", "node:18", "gradle:1"} {
116-
err := checkLegacyFeatures(map[string]any{id: true})
116+
_, _, err := resolveFeatureID(log.Null, id)
117117
if err == nil || !strings.Contains(err.Error(), "Legacy feature '"+id+"' not supported") {
118118
t.Errorf("%s: error = %v, want the legacy feature error naming it", id, err)
119119
}

‎internal/cli/compose_up.go‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -274,7 +274,7 @@ func (r *upRunner) composeFeatureSets(ctx context.Context, cfg *config.DevContai
274274
return nil, "", err
275275
}
276276
}
277-
res, err := fetchFeatureSetsWithOrder(ctx, r.log, cfg.Features, cfg.FeatureOptionOrder, localFeatureRoots{filepath.Dir(cfg.ConfigFilePath), opts.workspaceFolder}, lockfile, cfg.OverrideFeatureInstallOrder)
277+
res, err := fetchFeatureSetsWithOrder(ctx, r.log, cfg.Features, cfg.FeatureOrder, cfg.FeatureOptionOrder, localFeatureRoots{filepath.Dir(cfg.ConfigFilePath), opts.workspaceFolder}, lockfile, cfg.OverrideFeatureInstallOrder)
278278
if err != nil {
279279
return nil, "", err
280280
}

‎internal/cli/feature_install.go‎

Lines changed: 6 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@ import (
1818
"path/filepath"
1919
"regexp"
2020
"slices"
21-
"sort"
2221
"strconv"
2322
"strings"
2423
"time"
@@ -48,6 +47,7 @@ type FeatureBuildOptions struct {
4847
CABundle string
4948
ContainerEnv map[string]string
5049
ContainerEnvOrder []string
50+
FeatureOrder []string
5151
FeatureOptionOrder map[string][]string
5252
SkipPersistCustoms bool
5353
FeaturesBasePath string
@@ -67,16 +67,8 @@ type fetchFeatureResult struct {
6767
TmpDir string
6868
}
6969

70-
func fetchFeatureSets(ctx context.Context, logger log.Logger, featuresCfg map[string]any, optionOrder map[string][]string, local localFeatureRoots) (*fetchFeatureResult, error) {
71-
return fetchFeatureSetsWithOrder(ctx, logger, featuresCfg, optionOrder, local, nil, nil)
72-
}
73-
74-
func sortedUserFeatures(featuresCfg map[string]any, optionOrder map[string][]string) []features.DevContainerFeature {
75-
userFeatures := features.UserFeaturesToArray(featuresCfg, optionOrder)
76-
sort.Slice(userFeatures, func(i, j int) bool {
77-
return userFeatures[i].UserFeatureID < userFeatures[j].UserFeatureID
78-
})
79-
return userFeatures
70+
func fetchFeatureSets(ctx context.Context, logger log.Logger, featuresCfg map[string]any, order []string, optionOrder map[string][]string, local localFeatureRoots) (*fetchFeatureResult, error) {
71+
return fetchFeatureSetsWithOrder(ctx, logger, featuresCfg, order, optionOrder, local, nil, nil)
8072
}
8173

8274
type localFeatureRoots struct {
@@ -113,13 +105,12 @@ func createFeaturesFolder() (string, error) {
113105
}
114106
}
115107

116-
func fetchFeatureSetsWithOrder(ctx context.Context, logger log.Logger, featuresCfg map[string]any, optionOrder map[string][]string, local localFeatureRoots, lockfile *features.Lockfile, overrideOrder []string) (*fetchFeatureResult, error) {
108+
func fetchFeatureSetsWithOrder(ctx context.Context, logger log.Logger, featuresCfg map[string]any, order []string, optionOrder map[string][]string, local localFeatureRoots, lockfile *features.Lockfile, overrideOrder []string) (*fetchFeatureResult, error) {
117109
if len(featuresCfg) == 0 {
118110
return nil, nil
119111
}
120112

121-
userFeatures := sortedUserFeatures(featuresCfg, optionOrder)
122-
userFeatures, warnings := features.UpdateDeprecatedFeaturesIntoOptions(userFeatures)
113+
userFeatures, warnings := features.UpdateDeprecatedFeaturesIntoOptions(features.UserFeaturesToArray(featuresCfg, order, optionOrder))
123114
for _, w := range warnings {
124115
logger.Write(w, log.LevelWarning)
125116
}
@@ -588,7 +579,7 @@ func fetchBuildFeatures(ctx context.Context, logger log.Logger, featuresCfg map[
588579
return nil, err
589580
}
590581
}
591-
result, err := fetchFeatureSetsWithOrder(ctx, logger, featuresCfg, fbOpts.FeatureOptionOrder, localFeatureRoots{fbOpts.FeaturesBasePath, fbOpts.WorkspaceFolder}, lockfile, fbOpts.OverrideFeatureInstallOrder)
582+
result, err := fetchFeatureSetsWithOrder(ctx, logger, featuresCfg, fbOpts.FeatureOrder, fbOpts.FeatureOptionOrder, localFeatureRoots{fbOpts.FeaturesBasePath, fbOpts.WorkspaceFolder}, lockfile, fbOpts.OverrideFeatureInstallOrder)
592583
if err != nil {
593584
return nil, err
594585
}

‎internal/cli/feature_install_held_test.go‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -429,7 +429,7 @@ func TestTarballFeatureIDUsesTheURLPath(t *testing.T) {
429429

430430
func TestFetchFeatureSetsReportsTheFirstSortedFailure(t *testing.T) {
431431
for range 5 {
432-
_, err := fetchFeatureSets(t.Context(), log.Null, map[string]any{"./b-missing": true, "./a-missing": true, "./c-missing": true}, nil, devcontainerRoots(t))
432+
_, err := fetchFeatureSets(t.Context(), log.Null, map[string]any{"./b-missing": true, "./a-missing": true, "./c-missing": true}, nil, nil, devcontainerRoots(t))
433433
if err == nil || !strings.Contains(err.Error(), "'./a-missing'") {
434434
t.Fatalf("err = %v, want the failure of ./a-missing", err)
435435
}

‎internal/cli/feature_install_test.go‎

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -148,7 +148,7 @@ func TestFetchFeatureSets(t *testing.T) {
148148
t.Run(tt.name, func(t *testing.T) {
149149
roots := devcontainerRoots(t)
150150
tt.setup(t, roots.configDir)
151-
result, err := fetchFeatureSets(t.Context(), log.Null, tt.entries, nil, roots)
151+
result, err := fetchFeatureSets(t.Context(), log.Null, tt.entries, nil, nil, roots)
152152
if result != nil && result.TmpDir != "" {
153153
defer os.RemoveAll(result.TmpDir)
154154
}
@@ -232,7 +232,7 @@ func TestFetchFeatureSets_StagingLayout(t *testing.T) {
232232
if err := os.WriteFile(filepath.Join(dirB, "install.sh"), []byte("#!/bin/sh\n"), 0o755); err != nil {
233233
t.Fatal(err)
234234
}
235-
result, err := fetchFeatureSets(t.Context(), log.Null, map[string]any{"./dir-a": true}, nil, roots)
235+
result, err := fetchFeatureSets(t.Context(), log.Null, map[string]any{"./dir-a": true}, nil, nil, roots)
236236
if err != nil {
237237
t.Fatal(err)
238238
}
@@ -396,7 +396,7 @@ func TestFetchFeatureSetsRefusesLocalFeaturesOutsideDevcontainer(t *testing.T) {
396396
t.Run(tc.id, func(t *testing.T) {
397397
var logs bytes.Buffer
398398
logger := log.New(log.Options{Level: log.LevelInfo, Format: "text", Writer: &logs})
399-
result, err := fetchFeatureSets(t.Context(), logger, map[string]any{tc.id: true}, nil, roots)
399+
result, err := fetchFeatureSets(t.Context(), logger, map[string]any{tc.id: true}, nil, nil, roots)
400400
if result != nil {
401401
t.Fatalf("result = %+v, want none", result)
402402
}
@@ -420,7 +420,7 @@ func TestFetchFeatureSetsRefusesLocalFeaturesOutsideDevcontainer(t *testing.T) {
420420
func TestFetchFeatureSetsMovesDeprecatedFeaturesIntoOptions(t *testing.T) {
421421
var logs bytes.Buffer
422422
logger := log.New(log.Options{Level: log.LevelInfo, Format: "text", Writer: &logs})
423-
result, err := fetchFeatureSets(t.Context(), logger, map[string]any{"gradle": map[string]any{}, "node:18": map[string]any{}}, nil, devcontainerRoots(t))
423+
result, err := fetchFeatureSets(t.Context(), logger, map[string]any{"gradle": map[string]any{}, "node:18": map[string]any{}}, nil, nil, devcontainerRoots(t))
424424
if result != nil || err == nil || err.Error() != fmt.Sprintf(msgLegacyFeature, "node:18") {
425425
t.Fatalf("result = %+v, err = %v; want the legacy Feature error for node:18", result, err)
426426
}
@@ -480,7 +480,7 @@ func TestFetchedFeaturesKeepTheDeclaredOrder(t *testing.T) {
480480
write("dep", `{"id": "dep", "version": "1.0.0"}`)
481481

482482
result, err := fetchFeatureSets(t.Context(), log.Null,
483-
map[string]any{"./sdk": map[string]any{"zz": "1", "version": "2", "aa": "3"}},
483+
map[string]any{"./sdk": map[string]any{"zz": "1", "version": "2", "aa": "3"}}, nil,
484484
map[string][]string{"./sdk": {"zz", "version", "aa"}}, roots)
485485
if err != nil {
486486
t.Fatal(err)

‎internal/cli/feature_order_test.go‎

Lines changed: 75 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,75 @@
1+
package cli
2+
3+
import (
4+
"path/filepath"
5+
"strings"
6+
"testing"
7+
)
8+
9+
func TestReadConfigurationReportsTheFirstFeatureInDeclarationOrder(t *testing.T) {
10+
legacy9 := "Legacy feature '9' not supported."
11+
refusedZeta := "ERR: Feature '../zeta' could not be processed."
12+
for name, tc := range map[string]struct {
13+
features, override, additional string
14+
want string
15+
}{
16+
"declaration order": {features: `{"../zeta":{},"../alpha":{}}`, want: refusedZeta},
17+
"integer-like ids first": {features: `{"../zeta":{},"10":{},"9":{}}`, want: legacy9},
18+
"override adds a Feature after": {features: `{"../zeta":{}}`, override: `{"features":{"../alpha":{}}}`, want: refusedZeta},
19+
"override integer-like id first": {features: `{"../zeta":{}}`, override: `{"features":{"9":{}}}`, want: legacy9},
20+
"additional Features after config": {features: `{"../zeta":{}}`, additional: `{"9":{},"../alpha":{}}`, want: refusedZeta},
21+
"additional integer-like id first": {features: `{"../zeta":{}}`, additional: `{"../alpha":{},"10":{},"9":{}}`, want: refusedZeta},
22+
} {
23+
t.Run(name, func(t *testing.T) {
24+
startFakeEngine(t, nil)
25+
files := map[string]string{".devcontainer/devcontainer.json": `{"image":"alpine:3","features":` + tc.features + `}`}
26+
if tc.override != "" {
27+
files["override.json"] = tc.override
28+
}
29+
ws := writeConfigFixture(t, files)
30+
args := []string{"--workspace-folder", ws, "--include-features-configuration"}
31+
if tc.override != "" {
32+
args = append(args, "--override-config", filepath.Join(ws, "override.json"))
33+
}
34+
if tc.additional != "" {
35+
args = append(args, "--additional-features", tc.additional)
36+
}
37+
stdout, err := readConfigurationStdout(args...)
38+
if err == nil || !strings.HasPrefix(err.Error(), tc.want) || stdout != "" {
39+
t.Fatalf("stdout = %q, err = %v; want %q", stdout, err, tc.want)
40+
}
41+
})
42+
}
43+
}
44+
45+
func TestReadConfigurationReportsAnAdditionalIntegerLikeIDAfterTheConfigs(t *testing.T) {
46+
startFakeEngine(t, nil)
47+
ws := writeConfigFixture(t, map[string]string{".devcontainer/devcontainer.json": `{"image":"alpine:3","features":{"zz":{}}}`})
48+
_, err := readConfigurationStdout("--workspace-folder", ws, "--include-features-configuration", "--additional-features", `{"9":{}}`)
49+
if err == nil || !strings.HasPrefix(err.Error(), "Legacy feature 'zz' not supported.") {
50+
t.Fatalf("err = %v; want the config's legacy Feature zz first", err)
51+
}
52+
}
53+
54+
func TestFeaturesResolveDependenciesListsFeaturesInDeclarationOrder(t *testing.T) {
55+
ids := []string{"zeta", "alpha", "mid", "beta", "omega"}
56+
local := map[string]string{}
57+
var decl []string
58+
for _, id := range ids {
59+
local[id] = `{"id":"` + id + `","version":"1.0.0"}`
60+
decl = append(decl, `"./`+id+`":{}`)
61+
}
62+
ws, _ := resolveDepsWorkspace(t, "{"+strings.Join(decl, ",")+"}", local)
63+
out, err := runResolveDeps(t, "--workspace-folder", ws)
64+
if err != nil {
65+
t.Fatal(err)
66+
}
67+
prev := -1
68+
for _, id := range ids {
69+
i := strings.Index(out, "[./"+id+"<")
70+
if i <= prev {
71+
t.Fatalf("mermaid nodes not in declaration order %v:\n%s", ids, out)
72+
}
73+
prev = i
74+
}
75+
}

‎internal/cli/features_resolve_deps.go‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ func realFeaturesResolveDepsCmd() *cobra.Command {
3838
}
3939

4040
cfg := loadResult.Config
41-
userFeatures := features.UserFeaturesToArray(cfg.Features, cfg.FeatureOptionOrder)
41+
userFeatures := features.UserFeaturesToArray(cfg.Features, cfg.FeatureOrder, cfg.FeatureOptionOrder)
4242
if len(userFeatures) == 0 {
4343
logger.Write(fmt.Sprintf("Could not parse features object in configuration '%s'", cfg.ConfigFilePath), log.LevelError)
4444
return &coreerrors.ExitCodeError{Code: 1}

0 commit comments

Comments
 (0)