Add initial Linux support #150

Key features of Linux support:
- It supports python 3 scripts execution.
- It supports Flatpak and Snap installation for software
  clean-up/configurations.
- Extensive documentation.
This commit is contained in:
undergroundwires
2023-07-30 22:54:24 +02:00
parent e8199932b4
commit c404dfebe2
19 changed files with 3847 additions and 36 deletions

View File

@@ -33,17 +33,18 @@ describe('collections', () => {
});
function collectUniqueUrls(app: IApplication): string[] {
return app
.collections
.flatMap((a) => a.getAllScripts())
.flatMap((script) => script.docs?.flatMap((doc) => parseUrls(doc)))
return [ // Get all nodes
...app.collections.flatMap((c) => c.getAllCategories()),
...app.collections.flatMap((c) => c.getAllScripts()),
]
// Get all docs
.flatMap((documentable) => documentable.docs)
// Parse all URLs
.flatMap((docString) => docString.match(/(https?:\/\/[^\s]+)/g) || [])
// Remove duplicates
.filter((url, index, array) => array.indexOf(url) === index);
}
function parseUrls(text: string): string[] {
return text?.match(/\bhttps?:\/\/\S+/gi) ?? [];
}
function printUrls(statuses: IUrlStatus[]): string {
/* eslint-disable prefer-template */
return '\n'

View File

@@ -12,16 +12,17 @@ describe('MarkdownRenderer', () => {
it(`${node.nodeLabel}`, () => {
// act
const html = renderer.render(node.docs);
const result = validateHtml(html);
// assert
expect(isValidHtml(html));
expect(result.isValid, result.generatedHtml);
});
}
});
});
interface IDocumentableNode {
nodeLabel: string
docs: string
readonly nodeLabel: string
readonly docs: string
}
function* collectAllDocumentableNodes(): Generator<IDocumentableNode> {
const app = parseApplication();
@@ -40,7 +41,16 @@ function* collectAllDocumentableNodes(): Generator<IDocumentableNode> {
}
}
function isValidHtml(value: string): boolean {
const doc = new window.DOMParser().parseFromString(value, 'text/html');
return Array.from(doc.body.childNodes).some((node) => node.nodeType === 1);
interface IHTMLValidationResult {
readonly isValid: boolean;
readonly generatedHtml: string;
}
function validateHtml(value: string): IHTMLValidationResult {
const doc = new window.DOMParser()
.parseFromString(value, 'text/html');
return {
isValid: Array.from(doc.body.childNodes).some((node) => node.nodeType === 1),
generatedHtml: doc.body.innerHTML,
};
}

View File

@@ -5,6 +5,7 @@ import { parseProjectInformation } from '@/application/Parser/ProjectInformation
import { CategoryCollectionParserType, parseApplication } from '@/application/Parser/ApplicationParser';
import WindowsData from '@/application/collections/windows.yaml';
import MacOsData from '@/application/collections/macos.yaml';
import LinuxData from '@/application/collections/linux.yaml';
import { IProjectInformation } from '@/domain/IProjectInformation';
import { ProjectInformation } from '@/domain/ProjectInformation';
import { ICategoryCollection } from '@/domain/ICategoryCollection';
@@ -101,7 +102,7 @@ describe('ApplicationParser', () => {
});
it('defaults to expected data', () => {
// arrange
const expected = [WindowsData, MacOsData];
const expected = [WindowsData, MacOsData, LinuxData];
const parserSpy = new CategoryCollectionParserSpy();
const parserMock = parserSpy.mockParser();
// act

View File

@@ -77,13 +77,20 @@ describe('CodeRunner', () => {
describe('executes as expected', () => {
// arrange
const filePath = 'expected-file-path';
const testData = [{
os: OperatingSystem.Windows,
expected: filePath,
}, {
os: OperatingSystem.macOS,
expected: `open -a Terminal.app ${filePath}`,
}];
const testData = [
{
os: OperatingSystem.Windows,
expected: filePath,
},
{
os: OperatingSystem.macOS,
expected: `open -a Terminal.app ${filePath}`,
},
{
os: OperatingSystem.Linux,
expected: `x-terminal-emulator -e '${filePath}'`,
},
];
for (const data of testData) {
it(`returns ${data.expected} on ${OperatingSystem[data.os]}`, async () => {
const context = new TestContext();