Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add catalogue and npmrc to App bound instances #246

Merged
merged 2 commits into from
Apr 10, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
31 changes: 24 additions & 7 deletions lib/launcher.js
Original file line number Diff line number Diff line change
Expand Up @@ -223,8 +223,14 @@ class Launcher {

// if licensed, add palette catalogues
if (this.config.licensed) {
if (this.snapshot?.settings?.palette?.catalogue !== undefined) {
settings.editorTheme.palette.catalogue = this.snapshot.settings.palette.catalogue
if (this.project) {
if (this.snapshot?.settings?.palette?.catalogue !== undefined) {
settings.editorTheme.palette.catalogues = this.snapshot.settings.palette.catalogue
}
} else if (this.application) {
if (this.settings.palette?.catalogues) {
settings.editorTheme.palette.catalogues = this.settings.palette.catalogues
}
}
}

Expand Down Expand Up @@ -284,11 +290,21 @@ class Launcher {
* Write .npmrc file
*/
async writeNPMRCFile () {
if (this.snapshot.settings?.palette?.npmrc) {
await fs.writeFile(this.files.npmrc, this.snapshot.settings.palette.npmrc)
} else {
if (existsSync(this.files.npmrc)) {
await fs.rm(this.files.npmrc)
if (this.project) {
if (this.snapshot.settings?.palette?.npmrc) {
await fs.writeFile(this.files.npmrc, this.snapshot.settings.palette.npmrc)
} else {
if (existsSync(this.files.npmrc)) {
await fs.rm(this.files.npmrc)
}
}
} else if (this.application) {
if (this.settings.palette?.npmrc) {
await fs.writeFile(this.files.npmrc, this.settings.palette.npmrc)
} else {
if (existsSync(this.files.npmrc)) {
await fs.rm(this.files.npmrc)
}
Comment on lines +293 to +307
Copy link
Contributor

Choose a reason for hiding this comment

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

Unsure why snapshot is not considered when application bound?

I may need to pull and test locally to do this pair of PRs any justice.

I have another PR to review and my own PR to adjust all within the next 1h30m - i may not get this done today (sorry Ben)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Hi @Steve-Mcl I'm trying to get the Forge app side of this fixed up today, can you finish looking at this bit as well please

}
}
}
Expand All @@ -312,6 +328,7 @@ class Launcher {
}
if (!options || options.updateSettings === true) {
await this.writeSettings()
await this.writeNPMRCFile()
}
}

Expand Down
12 changes: 6 additions & 6 deletions test/unit/lib/launcher_spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -210,11 +210,11 @@ describe('Launcher', function () {
const settings = JSON.parse(setFile)
settings.should.have.property('editorTheme')
settings.editorTheme.should.have.property('palette')
settings.editorTheme.palette.should.have.a.property('catalogue').and.be.an.Array()
settings.editorTheme.palette.catalogue.should.have.a.lengthOf(3)
settings.editorTheme.palette.catalogue[0].should.eql('foo')
settings.editorTheme.palette.catalogue[1].should.eql('bar')
settings.editorTheme.palette.catalogue[2].should.eql('baz')
settings.editorTheme.palette.should.have.a.property('catalogues').and.be.an.Array()
settings.editorTheme.palette.catalogues.should.have.a.lengthOf(3)
settings.editorTheme.palette.catalogues[0].should.eql('foo')
settings.editorTheme.palette.catalogues[1].should.eql('bar')
settings.editorTheme.palette.catalogues[2].should.eql('baz')
})
it('ignores custom catalogue when NOT licensed', async function () {
const launcher = newLauncher({ config }, null, 'projectId', setup.snapshot)
Expand All @@ -223,7 +223,7 @@ describe('Launcher', function () {
const settings = JSON.parse(setFile)
settings.should.have.property('editorTheme')
settings.editorTheme.should.have.property('palette')
settings.editorTheme.palette.should.not.have.a.property('catalogue')
settings.editorTheme.palette.should.not.have.a.property('catalogues')
})
it('sets up audit logging for the node-red instance', async function () {
const launcher = newLauncher({ config: configWithPlatformInfo }, null, 'projectId', setup.snapshot)
Expand Down
Loading