Skip to content

Commit

Permalink
fix: make requirements.txt a SampleFile so it persists
Browse files Browse the repository at this point in the history
We are not bringing this file under projen management, so TextFile is an inappropriate choice
partially fulfills #16
  • Loading branch information
mikejgray committed Jan 17, 2024
1 parent 9b222f2 commit e49d105
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 16 deletions.
4 changes: 2 additions & 2 deletions src/files/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,15 +13,15 @@
}

class HelloWorldSkill(OVOSSkill):
def __init__(self, *args, **kwargs):
def __init__(self, *args, bus=None, **kwargs):
"""The __init__ method is called when the Skill is first constructed.
Note that self.bus, self.skill_id, self.settings, and
other base class settings are only available after the call to super().
This is a good place to load and pre-process any data needed by your
Skill, ideally after the super() call.
"""
super().__init__(*args, **kwargs)
super().__init__(*args, bus=bus, **kwargs)
self.learning = True

def initialize(self):
Expand Down
6 changes: 3 additions & 3 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -212,10 +212,10 @@ ${line}`;
}
if (existsSync('requirements.txt')) {
const existingRequirements = readFileSync('requirements.txt').toString();
requirements = `${existingRequirements}\n${manifestReqs ?? ''}${requirements}`;
requirements = `${existingRequirements}\n${manifestReqs ?? ''}\n${requirements}`;
} else {
new TextFile(this, 'requirements.txt', {
lines: [...requirements.split('\n'), ...manifestReqs.split('\n')],
new SampleFile(this, 'requirements.txt', {
contents: requirements + '\n' + manifestReqs,
});
}
if (!existsSync('version.py') && retrofit) {
Expand Down
8 changes: 8 additions & 0 deletions test/OVOSSkillProject.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@ test('snapshot', () => {

const synth = Testing.synth(project);
expect(synth).toMatchSnapshot();
expect(synth['requirements.txt']).toBeDefined();
expect(synth['requirements.txt']).toContain('ovos-utils\novos-bus-client\novos-workshop');
});

test('snapshot retrofit', () => {
Expand All @@ -23,6 +25,8 @@ test('snapshot retrofit', () => {

const synth = Testing.synth(project);
expect(synth).toMatchSnapshot();
expect(synth['requirements.txt']).toBeDefined();
expect(synth['requirements.txt']).toContain('ovos-utils\novos-bus-client\novos-workshop');

rmSync('TODO.md');
});
Expand All @@ -42,6 +46,10 @@ test('snapshot retrofit with manifest.yml', () => {

const synth = Testing.synth(project);
expect(synth).toMatchSnapshot();
expect(synth['requirements.txt']).toBeDefined();
expect(synth['requirements.txt']).toContain('akinator');
expect(synth['requirements.txt']).toContain('rapidfuzz');
expect(synth['requirements.txt']).toContain('ovos-utils\novos-bus-client\novos-workshop');

rmSync('manifest.yml');
rmSync('TODO.md');
Expand Down
13 changes: 2 additions & 11 deletions test/__snapshots__/OVOSSkillProject.test.ts.snap

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit e49d105

Please sign in to comment.