@teambit/builder 0.0.568 → 0.0.572
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/artifact/artifact-definition.ts +52 -0
- package/artifact/artifact-extractor.ts +116 -0
- package/artifact/artifact-factory.ts +119 -0
- package/artifact/artifact-list.ts +64 -0
- package/artifact/artifact.ts +81 -0
- package/artifact/artifacts.cmd.ts +68 -0
- package/artifact/extension-artifact.ts +12 -0
- package/artifact/index.ts +5 -0
- package/builder.service.tsx +163 -0
- package/dist/builder.main.runtime.d.ts +4 -2
- package/dist/builder.main.runtime.js +23 -2
- package/dist/builder.main.runtime.js.map +1 -1
- package/dist/templates/build-task/files/index-file.d.ts +2 -0
- package/dist/templates/build-task/files/index-file.js +15 -0
- package/dist/templates/build-task/files/index-file.js.map +1 -0
- package/dist/templates/build-task/files/task-file.d.ts +2 -0
- package/dist/templates/build-task/files/task-file.js +67 -0
- package/dist/templates/build-task/files/task-file.js.map +1 -0
- package/dist/templates/build-task/index.d.ts +2 -0
- package/dist/templates/build-task/index.js +45 -0
- package/dist/templates/build-task/index.js.map +1 -0
- package/exceptions/artifact-storage-error.ts +7 -0
- package/exceptions/capsule-not-found.ts +7 -0
- package/exceptions/index.ts +3 -0
- package/exceptions/invalid-task.ts +7 -0
- package/package-tar/teambit-builder-0.0.572.tgz +0 -0
- package/package.json +18 -32
- package/pipeline/index.ts +1 -0
- package/pipeline/pipeline-results.ts +1 -0
- package/storage/default-resolver.ts +13 -0
- package/storage/index.ts +2 -0
- package/storage/s3-resolver.ts +40 -0
- package/storage/storage-resolver.ts +18 -0
- package/templates/build-task/files/index-file.ts +5 -0
- package/templates/build-task/files/task-file.ts +58 -0
- package/templates/build-task/index.ts +22 -0
- package/types/asset.d.ts +29 -0
- package/types/style.d.ts +42 -0
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
import { ComponentContext } from '@teambit/generator';
|
|
2
|
+
|
|
3
|
+
export function taskFile({ namePascalCase }: ComponentContext) {
|
|
4
|
+
return `import {
|
|
5
|
+
BuildTask,
|
|
6
|
+
BuildContext,
|
|
7
|
+
BuiltTaskResult,
|
|
8
|
+
ComponentResult,
|
|
9
|
+
} from '@teambit/builder';
|
|
10
|
+
import path from 'path';
|
|
11
|
+
import fs from 'fs';
|
|
12
|
+
|
|
13
|
+
export class ${namePascalCase} implements BuildTask {
|
|
14
|
+
constructor(readonly aspectId: string) {}
|
|
15
|
+
readonly name = '${namePascalCase}';
|
|
16
|
+
|
|
17
|
+
async execute(context: BuildContext): Promise<BuiltTaskResult> {
|
|
18
|
+
// Prepare the component results array which will be used to report back the components proccessed
|
|
19
|
+
// as well as any additional data regarding this build task execution
|
|
20
|
+
const componentsResults: ComponentResult[] = [];
|
|
21
|
+
// The 'seeder capsules' are capsules for components that are built for their own sake -
|
|
22
|
+
// not for the sake of other components that have them as their dependencies
|
|
23
|
+
const capsules = context.capsuleNetwork.seedersCapsules;
|
|
24
|
+
capsules.forEach((capsule) => {
|
|
25
|
+
// Preprate an 'errors' array to report back of any erros during execution (this will be part of the 'Component Results' data)
|
|
26
|
+
const errors: Error[] = [];
|
|
27
|
+
// Each 'capsule' provides data regarding the component as well as the capsule itself
|
|
28
|
+
const componentName = capsule.component.id.name;
|
|
29
|
+
const capsuleDir = capsule.path;
|
|
30
|
+
|
|
31
|
+
const artifactContent = \`The component name is \${componentName}\`
|
|
32
|
+
|
|
33
|
+
try {
|
|
34
|
+
// Generate the artifact inside the capsule's diretory
|
|
35
|
+
fs.writeFileSync(
|
|
36
|
+
path.join(capsuleDir, 'output.my-artifact.txt'),
|
|
37
|
+
artifactContent
|
|
38
|
+
);
|
|
39
|
+
} catch (err: any) {
|
|
40
|
+
errors.push(err);
|
|
41
|
+
}
|
|
42
|
+
componentsResults.push({ component: capsule.component, errors });
|
|
43
|
+
});
|
|
44
|
+
|
|
45
|
+
return {
|
|
46
|
+
artifacts: [
|
|
47
|
+
{
|
|
48
|
+
generatedBy: this.aspectId,
|
|
49
|
+
name: this.name,
|
|
50
|
+
// The glob pattern for artifacts to include in the comoponent version
|
|
51
|
+
globPatterns: ['**/*.my-artifact.txt'],
|
|
52
|
+
},
|
|
53
|
+
],
|
|
54
|
+
componentsResults,
|
|
55
|
+
};
|
|
56
|
+
}
|
|
57
|
+
}`;
|
|
58
|
+
}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { ComponentContext, ComponentTemplate } from '@teambit/generator';
|
|
2
|
+
import { indexFile } from './files/index-file';
|
|
3
|
+
import { taskFile } from './files/task-file';
|
|
4
|
+
|
|
5
|
+
export const buildTaskTemplate: ComponentTemplate = {
|
|
6
|
+
name: 'build-task',
|
|
7
|
+
description: 'create a custom build task for your component pipelines',
|
|
8
|
+
hidden: false,
|
|
9
|
+
generateFiles: (context: ComponentContext) => {
|
|
10
|
+
return [
|
|
11
|
+
{
|
|
12
|
+
relativePath: 'index.ts',
|
|
13
|
+
content: indexFile(context),
|
|
14
|
+
isMain: true,
|
|
15
|
+
},
|
|
16
|
+
{
|
|
17
|
+
relativePath: `${context.name}.task.ts`,
|
|
18
|
+
content: taskFile(context),
|
|
19
|
+
},
|
|
20
|
+
];
|
|
21
|
+
},
|
|
22
|
+
};
|
package/types/asset.d.ts
ADDED
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
declare module '*.png' {
|
|
2
|
+
const value: any;
|
|
3
|
+
export = value;
|
|
4
|
+
}
|
|
5
|
+
declare module '*.svg' {
|
|
6
|
+
import type { FunctionComponent, SVGProps } from 'react';
|
|
7
|
+
|
|
8
|
+
export const ReactComponent: FunctionComponent<SVGProps<SVGSVGElement> & { title?: string }>;
|
|
9
|
+
const src: string;
|
|
10
|
+
export default src;
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
// @TODO Gilad
|
|
14
|
+
declare module '*.jpg' {
|
|
15
|
+
const value: any;
|
|
16
|
+
export = value;
|
|
17
|
+
}
|
|
18
|
+
declare module '*.jpeg' {
|
|
19
|
+
const value: any;
|
|
20
|
+
export = value;
|
|
21
|
+
}
|
|
22
|
+
declare module '*.gif' {
|
|
23
|
+
const value: any;
|
|
24
|
+
export = value;
|
|
25
|
+
}
|
|
26
|
+
declare module '*.bmp' {
|
|
27
|
+
const value: any;
|
|
28
|
+
export = value;
|
|
29
|
+
}
|
package/types/style.d.ts
ADDED
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
declare module '*.module.css' {
|
|
2
|
+
const classes: { readonly [key: string]: string };
|
|
3
|
+
export default classes;
|
|
4
|
+
}
|
|
5
|
+
declare module '*.module.scss' {
|
|
6
|
+
const classes: { readonly [key: string]: string };
|
|
7
|
+
export default classes;
|
|
8
|
+
}
|
|
9
|
+
declare module '*.module.sass' {
|
|
10
|
+
const classes: { readonly [key: string]: string };
|
|
11
|
+
export default classes;
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
declare module '*.module.less' {
|
|
15
|
+
const classes: { readonly [key: string]: string };
|
|
16
|
+
export default classes;
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
declare module '*.less' {
|
|
20
|
+
const classes: { readonly [key: string]: string };
|
|
21
|
+
export default classes;
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
declare module '*.css' {
|
|
25
|
+
const classes: { readonly [key: string]: string };
|
|
26
|
+
export default classes;
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
declare module '*.sass' {
|
|
30
|
+
const classes: { readonly [key: string]: string };
|
|
31
|
+
export default classes;
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
declare module '*.scss' {
|
|
35
|
+
const classes: { readonly [key: string]: string };
|
|
36
|
+
export default classes;
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
declare module '*.mdx' {
|
|
40
|
+
const component: any;
|
|
41
|
+
export default component;
|
|
42
|
+
}
|