Skip to content

feat: Add config-manager push scripts command#87

Open
dallinjsevy wants to merge 1 commit into
mainfrom
feature/config-manager-push-scripts
Open

feat: Add config-manager push scripts command#87
dallinjsevy wants to merge 1 commit into
mainfrom
feature/config-manager-push-scripts

Conversation

@dallinjsevy

Copy link
Copy Markdown

No description provided.

Comment thread src/configManagerOps/FrConfigScriptOps.ts Outdated
Comment thread src/cli/config-manager/config-manager-push/config-manager-push-scripts.ts Outdated
Comment thread src/configManagerOps/FrConfigScriptOps.ts Outdated
@dallinjsevy
dallinjsevy force-pushed the feature/config-manager-push-scripts branch from d813027 to 4177d3d Compare March 26, 2026 20:49
Comment thread src/configManagerOps/FrConfigScriptOps.ts Outdated
Comment thread src/configManagerOps/FrConfigScriptOps.ts Outdated
@dallinjsevy
dallinjsevy force-pushed the feature/config-manager-push-scripts branch from 8cd7d8c to 246e418 Compare March 30, 2026 15:29
@phalestrivir
phalestrivir force-pushed the feature/config-manager-push-scripts branch from 246e418 to 850ed52 Compare April 6, 2026 20:27
Comment thread src/configManagerOps/FrConfigScriptOps.ts Outdated
Comment thread src/configManagerOps/FrConfigScriptOps.ts Outdated
Comment thread test/e2e/mocks/github_584874290/recording.har
Comment thread test/e2e/mocks/npmjs_1455397529/recording.har
@phalestrivir

Copy link
Copy Markdown

Note that I rebased this PR as well, so you will need to make sure to update your local branch with these changes

@dallinjsevy
dallinjsevy force-pushed the feature/config-manager-push-scripts branch 2 times, most recently from e30a786 to 4879317 Compare April 9, 2026 19:03
@dallinjsevy
dallinjsevy force-pushed the feature/config-manager-push-scripts branch from 4879317 to 7e67073 Compare May 28, 2026 15:58
CLOUD_DEPLOYMENT_TYPE_KEY,
FORGEOPS_DEPLOYMENT_TYPE_KEY,
];

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Revert this change

);

program
.description('Import scripts to forgeops.')

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is incorrect, I would just have it be Import scripts. since it works for other deployments as well


const deploymentTypes = [
CLOUD_DEPLOYMENT_TYPE_KEY,
FORGEOPS_DEPLOYMENT_TYPE_KEY,

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would not specify deployment type here since all deployment types support scripts since they are AM configuration

Comment on lines +30 to +35
.addOption(
new Option(
'-r, --realm <realm>',
'Realm name, import only specified realm'
)
);

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Remove the -r, --realm flag

Comment on lines +47 to +50
if (!(await getTokens(false, true, deploymentTypes))) {
process.exitCode = 1;
return;
}

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Small thing, but you can do this in one line:

if (!(await getTokens(false, true, deploymentTypes))) process.exit(1);

Comment on lines +235 to +241
const realmsDir = getFilePath('realms/');
const realms: string[] = realmName
? [realmName]
: fs
.readdirSync(realmsDir, { withFileTypes: true })
.filter((entry) => entry.isDirectory())
.map((entry) => entry.name);

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The root realm for forgeops gets exported to scripts, we should have it export to a directory called root because right now if we import with forgeops it will think that scripts is a realm. When reading it in, make sure root becomes / since / is the actual name of it.

.map((entry) => entry.name);

for (const realm of realms) {
if (!realmName) state.setRealm(realm);

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No need for the if check, I'd just do state.setRealm(realm)

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Revert this file

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Rever this file

const { stdout } = await exec(CMD, forgeopsEnv);
expect(removeAnsiEscapeCodes(stdout)).toMatchSnapshot();
});
test(`"frodo config-manager push scripts -n 832807d9-fb5d-4810-88ef-6e0a1aa89924 -D ${allDirectory} -m forgeops": should import the scripts into forgeops"`, async () => {

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The -n flag is actually not the ID, but the name of the script:

Image

As you can see in the image, if I use ID it can't find the script, but if I use the name it can. So, update this so that -n is the script name, not the script ID.

The other thing is that you'll notice if there isn't any script change no import will be attempted. We may want to do the same thing, as scripts contain a "lastUpdated" field that indicates when an update gets made, and it updates on import whether or not the actual script value changed, so preventing the update whenever possible would make sense.

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

On this same issue, once we have the library updated to support not importing changed scripts, it turns out config-manager supports with an ENV variable turning that off, so since we'll have a flag that we set on the library side to do this, we'll need a way to enable or disable that flag on the CLI side. We'll need another option for this, probably -f, --force is what I'm thinking, to force the udpate if they want to

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants