Skip to content

Commit

Permalink
fix: make helloworld skill installable
Browse files Browse the repository at this point in the history
addresses #14
  • Loading branch information
mikejgray committed Jan 17, 2024
1 parent e49d105 commit b6559b0
Show file tree
Hide file tree
Showing 4 changed files with 1,793 additions and 5 deletions.
2 changes: 1 addition & 1 deletion src/files/setup.py.ts
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ setup(
author="${author}",
author_email="${authorAddress}",
license="${license}",
package_dir={SKILL_PKG: ""},
package_dir={SKILL_PKG: "${packageDir ?? '.'}"},
package_data={SKILL_PKG: find_resource_files()},
packages=[SKILL_PKG],
include_package_data=True,
Expand Down
3 changes: 2 additions & 1 deletion src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -199,7 +199,7 @@ ${line}`;
new SampleFile(this, 'skill.json', {
contents: '{}',
});
let requirements = 'ovos-utils\novos-bus-client\novos-workshop\n# Your requirements here\n';
let requirements = 'ovos-utils\novos-bus-client\novos-workshop\novos-plugin-manager\n# Your requirements here\n';
let manifestReqs = '';
if (existsSync('manifest.yml')) {
// Load and parse YAML file
Expand Down Expand Up @@ -425,6 +425,7 @@ ${line}`;
const dirPath = join(sourceFolder, dir);

// Check if the directory exists before proceeding
console.debug(`Checking if ${dirPath} folder exists in original skill...`);
if (!existsSync(dirPath)) {
console.warn(`${dir} folder not found in original skill; skipping.`);
return; // Continue to the next iteration of the loop
Expand Down
63 changes: 62 additions & 1 deletion test/OVOSSkillProject.test.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { rmSync, writeFileSync } from 'fs';
import { existsSync, mkdirSync, rm, rmSync, writeFileSync } from 'fs';
import { Testing } from 'projen';
import { OVOSSkillProject } from '../src';

Expand All @@ -15,6 +15,32 @@ test('snapshot', () => {
expect(synth['requirements.txt']).toContain('ovos-utils\novos-bus-client\novos-workshop');
});

describe('packageDir snapshot', () => {
test('old style package in root', () => {
const project = new OVOSSkillProject({
name: 'test',
skillClass: 'TestSkill',
pypiName: 'test-skill',
packageDir: '.',
});

const synth = Testing.synth(project);
expect(synth).toMatchSnapshot();
expect(synth['setup.py']).toContain('package_dir={SKILL_PKG: "."},');
});
test('new style package in src', () => {
const project = new OVOSSkillProject({
name: 'test',
skillClass: 'TestSkill',
pypiName: 'test-skill',
});

const synth = Testing.synth(project);
expect(synth).toMatchSnapshot();
expect(synth['setup.py']).toContain('package_dir={SKILL_PKG: "src"},');
});
});

test('snapshot retrofit', () => {
const project = new OVOSSkillProject({
name: 'test',
Expand Down Expand Up @@ -53,4 +79,39 @@ test('snapshot retrofit with manifest.yml', () => {

rmSync('manifest.yml');
rmSync('TODO.md');
});

test('snapshot refactoring locale', () => {
try {

// Create directories and example files
mkdirSync('vocab/en-us', { recursive: true });
mkdirSync('dialog/en-us', { recursive: true });
mkdirSync('regex/en-us', { recursive: true });
mkdirSync('intents/en-us', { recursive: true });
writeFileSync('vocab/en-us/ExampleKeyword.voc', 'example', { flag: 'w' });
writeFileSync('dialog/en-us/hello.dialog', 'example', { flag: 'w' });
writeFileSync('regex/en-us/example.rx', '^example$', { flag: 'w' });
writeFileSync('intents/en-us/hello.intent', 'example', { flag: 'w' });
const project = new OVOSSkillProject({
name: 'test',
skillClass: 'TestSkill',
pypiName: 'test-skill',
retrofit: true,
});

const synth = Testing.synth(project);
expect(synth).toMatchSnapshot();
expect(existsSync('locale/en-us/vocab/ExampleKeyword.voc')).toBeTruthy();
expect(existsSync('locale/en-us/dialog/hello.dialog')).toBeTruthy();
expect(existsSync('locale/en-us/regex/example.rx')).toBeTruthy();
expect(existsSync('locale/en-us/intents/hello.intent')).toBeTruthy();
} finally {
rm('vocab', { recursive: true, force: true }, () => {});
rm('dialog', { recursive: true, force: true }, () => {});
rm('regex', { recursive: true, force: true }, () => {});
rm('intents', { recursive: true, force: true }, () => {});
rm('locale', { recursive: true, force: true }, () => {});
}

});
Loading

0 comments on commit b6559b0

Please sign in to comment.