@seeka-labs/cli-apps 1.1.23 → 1.1.25
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/LICENSE +19 -19
- package/dist/index.js +10 -10
- package/dist/index.js.map +4 -4
- package/dist/init-templates/aws-lambda/.example.gitignore +48 -48
- package/dist/init-templates/aws-lambda/.nvmrc +1 -1
- package/dist/init-templates/aws-lambda/README.md +76 -76
- package/dist/init-templates/aws-lambda/jest.config.js +4 -4
- package/dist/init-templates/aws-lambda/package.json +51 -54
- package/dist/init-templates/aws-lambda/src/index.test.ts +6 -6
- package/dist/init-templates/aws-lambda/src/lib/logging/index.ts +87 -87
- package/dist/init-templates/aws-lambda/src/lib/state/redis/index.ts +64 -64
- package/dist/init-templates/aws-lambda/src/lib/state/seeka/installations.ts +66 -66
- package/dist/init-templates/aws-lambda/src/routes/seekaAppWebhook.ts +193 -193
- package/dist/init-templates/azure-function/.example.gitignore +47 -47
- package/dist/init-templates/azure-function/README.md +107 -107
- package/dist/init-templates/azure-function/jest.config.js +4 -4
- package/dist/init-templates/azure-function/package.json +45 -48
- package/dist/init-templates/azure-function/scripts/dev-queue-setup.js +29 -29
- package/dist/init-templates/azure-function/src/functions/healthCheck.ts +13 -13
- package/dist/init-templates/azure-function/src/functions/pollingExample.ts +39 -39
- package/dist/init-templates/azure-function/src/functions/queueExample.ts +66 -66
- package/dist/init-templates/azure-function/src/functions/seekaAppWebhook.ts +236 -236
- package/dist/init-templates/azure-function/src/index.test.ts +6 -6
- package/dist/init-templates/azure-function/src/lib/browser/index.ts +54 -54
- package/dist/init-templates/azure-function/src/lib/browser/models/index.ts +6 -6
- package/dist/init-templates/azure-function/src/lib/jobs/index.ts +95 -95
- package/dist/init-templates/azure-function/src/lib/logging/index.ts +92 -92
- package/dist/init-templates/azure-function/src/lib/state/redis/index.ts +64 -64
- package/dist/init-templates/azure-function/src/lib/state/seeka/installations.ts +66 -66
- package/dist/init-templates/browser/.editorconfig +14 -14
- package/dist/init-templates/browser/.eslintrc.cjs +1 -1
- package/dist/init-templates/browser/.yarnrc +1 -1
- package/dist/init-templates/browser/jest.config.js +11 -11
- package/dist/init-templates/browser/package.json +3 -3
- package/dist/init-templates/browser/scripts/esbuild/build-browser-plugin.mjs +110 -110
- package/dist/init-templates/browser/scripts/esbuild/plugins/importAsGlobals.mjs +38 -38
- package/dist/init-templates/browser/src/browser.ts +12 -12
- package/dist/init-templates/browser/src/plugin/index.test.ts +6 -6
- package/dist/init-templates/browser/src/plugin/index.ts +49 -49
- package/dist/init-templates/browser/tsconfig.json +34 -34
- package/dist/init-templates/netlify-function/.env.example +17 -17
- package/dist/init-templates/netlify-function/.example.gitignore +36 -36
- package/dist/init-templates/netlify-function/.nvmrc +1 -1
- package/dist/init-templates/netlify-function/.vscode/launch.json +44 -44
- package/dist/init-templates/netlify-function/README.md +61 -61
- package/dist/init-templates/netlify-function/jest.config.js +4 -4
- package/dist/init-templates/netlify-function/netlify.toml +6 -6
- package/dist/init-templates/netlify-function/package.json +11 -14
- package/dist/init-templates/netlify-function/src/api/example-job-background/index.ts +51 -51
- package/dist/init-templates/netlify-function/src/api/polling-example-job-scheduled/index.ts +45 -45
- package/dist/init-templates/netlify-function/src/api/seeka-app-webhook/index.ts +216 -216
- package/dist/init-templates/netlify-function/src/index.test.ts +6 -6
- package/dist/init-templates/netlify-function/src/lib/jobs/index.ts +67 -67
- package/dist/init-templates/netlify-function/src/lib/logging/index.ts +90 -90
- package/dist/init-templates/netlify-function/src/lib/state/redis/index.ts +64 -64
- package/dist/init-templates/netlify-function/src/lib/state/seeka/installations.ts +66 -66
- package/package.json +7 -7
|
@@ -1,67 +1,67 @@
|
|
|
1
|
-
import type { Logger } from 'winston';
|
|
2
|
-
|
|
3
|
-
import { getList, remove, set, tryGet } from '../redis';
|
|
4
|
-
|
|
5
|
-
export interface SeekaAppInstallState {
|
|
6
|
-
/** ID of the organisation that installed the app */
|
|
7
|
-
organisationId: string;
|
|
8
|
-
/** ID of the brand that installed the app */
|
|
9
|
-
organisationBrandId: string;
|
|
10
|
-
/** ID of the installation of the app */
|
|
11
|
-
applicationInstallId: string;
|
|
12
|
-
// Installation settings provided by the user installing the app
|
|
13
|
-
installationSettings: SampleAppInstallSettings
|
|
14
|
-
// State relating to the app and installation of the app
|
|
15
|
-
installationState: SampleAppInstallState;
|
|
16
|
-
|
|
17
|
-
// When the app was installed
|
|
18
|
-
installedAt: string; // new Date().toISOString()
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
export interface SampleAppInstallState {
|
|
22
|
-
stateItem1?: string
|
|
23
|
-
stateItem2?: string
|
|
24
|
-
grantedPermissions?: string[]
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
export type SampleAppInstallSettings = { [key: string]: any; } | {
|
|
28
|
-
myAppInstallSetting1: string | number | undefined;
|
|
29
|
-
myAppInstallSetting2: string | number | undefined;
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
const stateType = 'install'
|
|
33
|
-
|
|
34
|
-
export const tryGetInstallation = async (applicationInstallId: string, throwWhenNotFound: boolean, logger: Logger): Promise<SeekaAppInstallState | null> => {
|
|
35
|
-
const installation = await tryGet<SeekaAppInstallState>(stateType, applicationInstallId);
|
|
36
|
-
if (installation == null && throwWhenNotFound) {
|
|
37
|
-
throw new Error(`Seeka installation ${applicationInstallId} not found`);
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
return installation;
|
|
41
|
-
}
|
|
42
|
-
|
|
43
|
-
export const listInstallations = async (logger: Logger): Promise<SeekaAppInstallState[]> => {
|
|
44
|
-
const installations = await getList<SeekaAppInstallState>(stateType);
|
|
45
|
-
|
|
46
|
-
return installations;
|
|
47
|
-
}
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
export const createOrUpdateInstallation = async (state: SeekaAppInstallState, logger: Logger): Promise<SeekaAppInstallState> => {
|
|
51
|
-
if (!state.installationState) state.installationState = {};
|
|
52
|
-
if (!state.installedAt) state.installedAt = new Date().toISOString();
|
|
53
|
-
|
|
54
|
-
const creating = (await tryGetInstallation(state.applicationInstallId, false, logger)) === null;
|
|
55
|
-
|
|
56
|
-
await set(stateType, state.applicationInstallId, state);
|
|
57
|
-
|
|
58
|
-
logger.info(creating ? 'Created installation state' : 'Updated installation state', { applicationInstallId: state.applicationInstallId, organisationId: state.organisationId, organisationBrandId: state.organisationBrandId });
|
|
59
|
-
|
|
60
|
-
return state;
|
|
61
|
-
}
|
|
62
|
-
|
|
63
|
-
export const deleteInstallation = async (applicationInstallId: string, logger: Logger): Promise<void> => {
|
|
64
|
-
await remove(stateType, applicationInstallId);
|
|
65
|
-
|
|
66
|
-
logger.info('Deleted installation state', { applicationInstallId });
|
|
1
|
+
import type { Logger } from 'winston';
|
|
2
|
+
|
|
3
|
+
import { getList, remove, set, tryGet } from '../redis';
|
|
4
|
+
|
|
5
|
+
export interface SeekaAppInstallState {
|
|
6
|
+
/** ID of the organisation that installed the app */
|
|
7
|
+
organisationId: string;
|
|
8
|
+
/** ID of the brand that installed the app */
|
|
9
|
+
organisationBrandId: string;
|
|
10
|
+
/** ID of the installation of the app */
|
|
11
|
+
applicationInstallId: string;
|
|
12
|
+
// Installation settings provided by the user installing the app
|
|
13
|
+
installationSettings: SampleAppInstallSettings
|
|
14
|
+
// State relating to the app and installation of the app
|
|
15
|
+
installationState: SampleAppInstallState;
|
|
16
|
+
|
|
17
|
+
// When the app was installed
|
|
18
|
+
installedAt: string; // new Date().toISOString()
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
export interface SampleAppInstallState {
|
|
22
|
+
stateItem1?: string
|
|
23
|
+
stateItem2?: string
|
|
24
|
+
grantedPermissions?: string[]
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
export type SampleAppInstallSettings = { [key: string]: any; } | {
|
|
28
|
+
myAppInstallSetting1: string | number | undefined;
|
|
29
|
+
myAppInstallSetting2: string | number | undefined;
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
const stateType = 'install'
|
|
33
|
+
|
|
34
|
+
export const tryGetInstallation = async (applicationInstallId: string, throwWhenNotFound: boolean, logger: Logger): Promise<SeekaAppInstallState | null> => {
|
|
35
|
+
const installation = await tryGet<SeekaAppInstallState>(stateType, applicationInstallId);
|
|
36
|
+
if (installation == null && throwWhenNotFound) {
|
|
37
|
+
throw new Error(`Seeka installation ${applicationInstallId} not found`);
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
return installation;
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
export const listInstallations = async (logger: Logger): Promise<SeekaAppInstallState[]> => {
|
|
44
|
+
const installations = await getList<SeekaAppInstallState>(stateType);
|
|
45
|
+
|
|
46
|
+
return installations;
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
|
|
50
|
+
export const createOrUpdateInstallation = async (state: SeekaAppInstallState, logger: Logger): Promise<SeekaAppInstallState> => {
|
|
51
|
+
if (!state.installationState) state.installationState = {};
|
|
52
|
+
if (!state.installedAt) state.installedAt = new Date().toISOString();
|
|
53
|
+
|
|
54
|
+
const creating = (await tryGetInstallation(state.applicationInstallId, false, logger)) === null;
|
|
55
|
+
|
|
56
|
+
await set(stateType, state.applicationInstallId, state);
|
|
57
|
+
|
|
58
|
+
logger.info(creating ? 'Created installation state' : 'Updated installation state', { applicationInstallId: state.applicationInstallId, organisationId: state.organisationId, organisationBrandId: state.organisationBrandId });
|
|
59
|
+
|
|
60
|
+
return state;
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
export const deleteInstallation = async (applicationInstallId: string, logger: Logger): Promise<void> => {
|
|
64
|
+
await remove(stateType, applicationInstallId);
|
|
65
|
+
|
|
66
|
+
logger.info('Deleted installation state', { applicationInstallId });
|
|
67
67
|
}
|
|
@@ -1,14 +1,14 @@
|
|
|
1
|
-
# http://editorconfig.org
|
|
2
|
-
root = true
|
|
3
|
-
|
|
4
|
-
[*]
|
|
5
|
-
charset = utf-8
|
|
6
|
-
end_of_line = lf
|
|
7
|
-
indent_size = 2
|
|
8
|
-
indent_style = space
|
|
9
|
-
insert_final_newline = true
|
|
10
|
-
trim_trailing_whitespace = true
|
|
11
|
-
|
|
12
|
-
[*.md]
|
|
13
|
-
max_line_length = 0
|
|
14
|
-
trim_trailing_whitespace = true
|
|
1
|
+
# http://editorconfig.org
|
|
2
|
+
root = true
|
|
3
|
+
|
|
4
|
+
[*]
|
|
5
|
+
charset = utf-8
|
|
6
|
+
end_of_line = lf
|
|
7
|
+
indent_size = 2
|
|
8
|
+
indent_style = space
|
|
9
|
+
insert_final_newline = true
|
|
10
|
+
trim_trailing_whitespace = true
|
|
11
|
+
|
|
12
|
+
[*.md]
|
|
13
|
+
max_line_length = 0
|
|
14
|
+
trim_trailing_whitespace = true
|
|
@@ -1 +1 @@
|
|
|
1
|
-
module.exports = require('../../scripts/eslint/shared.eslint.cjs');
|
|
1
|
+
module.exports = require('../../scripts/eslint/shared.eslint.cjs');
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"@seeka-labs:registry" "https://npm.packages.seeka.services/"
|
|
1
|
+
"@seeka-labs:registry" "https://npm.packages.seeka.services/"
|
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
export default {
|
|
2
|
-
roots: ['<rootDir>/src'],
|
|
3
|
-
testMatch: [
|
|
4
|
-
"**/*.test.ts"
|
|
5
|
-
],
|
|
6
|
-
transform: {
|
|
7
|
-
"^.+\\.(ts|tsx)$": "ts-jest"
|
|
8
|
-
},
|
|
9
|
-
collectCoverageFrom: ["src/**/*.ts", "!**/node_modules/**"],
|
|
10
|
-
coverageReporters: ["html", "text", "text-summary", "cobertura"],
|
|
11
|
-
}
|
|
1
|
+
export default {
|
|
2
|
+
roots: ['<rootDir>/src'],
|
|
3
|
+
testMatch: [
|
|
4
|
+
"**/*.test.ts"
|
|
5
|
+
],
|
|
6
|
+
transform: {
|
|
7
|
+
"^.+\\.(ts|tsx)$": "ts-jest"
|
|
8
|
+
},
|
|
9
|
+
collectCoverageFrom: ["src/**/*.ts", "!**/node_modules/**"],
|
|
10
|
+
coverageReporters: ["html", "text", "text-summary", "cobertura"],
|
|
11
|
+
}
|
|
@@ -22,10 +22,10 @@
|
|
|
22
22
|
"devDependencies": {
|
|
23
23
|
"@jgoz/esbuild-plugin-typecheck": "^4.0.2",
|
|
24
24
|
"@types/jest": "^29.5.14",
|
|
25
|
-
"@typescript-eslint/eslint-plugin": "^8.
|
|
26
|
-
"@typescript-eslint/parser": "^8.
|
|
25
|
+
"@typescript-eslint/eslint-plugin": "^8.17.0",
|
|
26
|
+
"@typescript-eslint/parser": "^8.17.0",
|
|
27
27
|
"esbuild": "^0.24.0",
|
|
28
|
-
"eslint": "^9.
|
|
28
|
+
"eslint": "^9.16.0",
|
|
29
29
|
"eslint-plugin-unused-imports": "^4.1.4",
|
|
30
30
|
"jest": "^29.7.0",
|
|
31
31
|
"jest-junit": "^16.0.0",
|
|
@@ -1,111 +1,111 @@
|
|
|
1
|
-
import { importAsGlobals } from './plugins/importAsGlobals.mjs'
|
|
2
|
-
import { build, version, context } from 'esbuild'
|
|
3
|
-
import { typecheckPlugin } from '@jgoz/esbuild-plugin-typecheck';
|
|
4
|
-
import { copyFileSync, mkdirSync, existsSync } from 'fs'
|
|
5
|
-
import { resolve } from 'path'
|
|
6
|
-
import * as watch from 'watch'
|
|
7
|
-
|
|
8
|
-
console.log('esbuild version:', version);
|
|
9
|
-
|
|
10
|
-
if (process.argv.length < 3) {
|
|
11
|
-
throw new Error('Missing arg');
|
|
12
|
-
}
|
|
13
|
-
|
|
14
|
-
const pluginName = process.argv[2];
|
|
15
|
-
|
|
16
|
-
const mode = process.argv.length > 4 ? process.argv[4] : 'prod';
|
|
17
|
-
const watchBuild = process.argv.length > 5 ? process.argv[5] == 'watch' : false;
|
|
18
|
-
|
|
19
|
-
console.log('mode:', mode);
|
|
20
|
-
console.log('watchBuild:', process.argv[4]);
|
|
21
|
-
|
|
22
|
-
const opts = {
|
|
23
|
-
entryPoints: ['src/browser.ts'],
|
|
24
|
-
bundle: true,
|
|
25
|
-
metafile: true,
|
|
26
|
-
minify: mode === 'dev' ? false : true,
|
|
27
|
-
format: 'iife',
|
|
28
|
-
platform: 'browser',
|
|
29
|
-
//sourcemap: 'external',
|
|
30
|
-
sourcemap: mode === 'dev' ? true : false,
|
|
31
|
-
external: ['@seeka-labs/converge'],
|
|
32
|
-
outfile: `dist/${pluginName}.min.js`,
|
|
33
|
-
plugins: [
|
|
34
|
-
importAsGlobals({
|
|
35
|
-
"@seeka-labs/converge": "SeekaConvergeCore"
|
|
36
|
-
}),
|
|
37
|
-
typecheckPlugin()
|
|
38
|
-
]
|
|
39
|
-
}
|
|
40
|
-
|
|
41
|
-
const postBuild = () => {
|
|
42
|
-
// Copy outfile to ../dist/src/browser
|
|
43
|
-
if (!existsSync(resolve('../../dist/src/browser'))) {
|
|
44
|
-
mkdirSync(resolve('../../dist/src/browser'), {
|
|
45
|
-
recursive: true,
|
|
46
|
-
});
|
|
47
|
-
}
|
|
48
|
-
copyFileSync(resolve(opts.outfile), resolve('../../dist/src/browser', `${pluginName}.min.js`))
|
|
49
|
-
}
|
|
50
|
-
|
|
51
|
-
if (watchBuild) {
|
|
52
|
-
const ctx = await context(opts);
|
|
53
|
-
|
|
54
|
-
async function buildWatch() {
|
|
55
|
-
await ctx.rebuild();
|
|
56
|
-
postBuild();
|
|
57
|
-
console.log('build succeeded');
|
|
58
|
-
}
|
|
59
|
-
|
|
60
|
-
await buildWatch();
|
|
61
|
-
|
|
62
|
-
// Start watch
|
|
63
|
-
let monitorInstance;
|
|
64
|
-
watch.createMonitor(resolve('./src'), function (monitor) {
|
|
65
|
-
console.log('watching ./src, press any key to exit');
|
|
66
|
-
monitorInstance = monitor;
|
|
67
|
-
|
|
68
|
-
monitor.on("created", async function (f, stat) {
|
|
69
|
-
console.log('rebuilding due to file created', f)
|
|
70
|
-
try {
|
|
71
|
-
await buildWatch();
|
|
72
|
-
}
|
|
73
|
-
catch (e) {
|
|
74
|
-
console.error(e);
|
|
75
|
-
}
|
|
76
|
-
})
|
|
77
|
-
monitor.on("changed", async function (f, curr, prev) {
|
|
78
|
-
console.log('rebuilding due to file changed', f)
|
|
79
|
-
try {
|
|
80
|
-
await buildWatch();
|
|
81
|
-
}
|
|
82
|
-
catch (e) {
|
|
83
|
-
console.error(e);
|
|
84
|
-
}
|
|
85
|
-
})
|
|
86
|
-
monitor.on("removed", async function (f, stat) {
|
|
87
|
-
console.log('rebuilding due to file deleted', f)
|
|
88
|
-
try {
|
|
89
|
-
await buildWatch();
|
|
90
|
-
}
|
|
91
|
-
catch (e) {
|
|
92
|
-
console.error(e);
|
|
93
|
-
}
|
|
94
|
-
})
|
|
95
|
-
})
|
|
96
|
-
|
|
97
|
-
// Support stopping
|
|
98
|
-
var stdin = process.stdin;
|
|
99
|
-
stdin.setRawMode(true);
|
|
100
|
-
stdin.resume();
|
|
101
|
-
stdin.setEncoding('utf8');
|
|
102
|
-
stdin.on('data', function (key) {
|
|
103
|
-
console.log('Stopping watch...');
|
|
104
|
-
monitorInstance.stop();
|
|
105
|
-
process.exit();
|
|
106
|
-
});
|
|
107
|
-
}
|
|
108
|
-
else {
|
|
109
|
-
await build(opts);
|
|
110
|
-
postBuild();
|
|
1
|
+
import { importAsGlobals } from './plugins/importAsGlobals.mjs'
|
|
2
|
+
import { build, version, context } from 'esbuild'
|
|
3
|
+
import { typecheckPlugin } from '@jgoz/esbuild-plugin-typecheck';
|
|
4
|
+
import { copyFileSync, mkdirSync, existsSync } from 'fs'
|
|
5
|
+
import { resolve } from 'path'
|
|
6
|
+
import * as watch from 'watch'
|
|
7
|
+
|
|
8
|
+
console.log('esbuild version:', version);
|
|
9
|
+
|
|
10
|
+
if (process.argv.length < 3) {
|
|
11
|
+
throw new Error('Missing arg');
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
const pluginName = process.argv[2];
|
|
15
|
+
|
|
16
|
+
const mode = process.argv.length > 4 ? process.argv[4] : 'prod';
|
|
17
|
+
const watchBuild = process.argv.length > 5 ? process.argv[5] == 'watch' : false;
|
|
18
|
+
|
|
19
|
+
console.log('mode:', mode);
|
|
20
|
+
console.log('watchBuild:', process.argv[4]);
|
|
21
|
+
|
|
22
|
+
const opts = {
|
|
23
|
+
entryPoints: ['src/browser.ts'],
|
|
24
|
+
bundle: true,
|
|
25
|
+
metafile: true,
|
|
26
|
+
minify: mode === 'dev' ? false : true,
|
|
27
|
+
format: 'iife',
|
|
28
|
+
platform: 'browser',
|
|
29
|
+
//sourcemap: 'external',
|
|
30
|
+
sourcemap: mode === 'dev' ? true : false,
|
|
31
|
+
external: ['@seeka-labs/converge'],
|
|
32
|
+
outfile: `dist/${pluginName}.min.js`,
|
|
33
|
+
plugins: [
|
|
34
|
+
importAsGlobals({
|
|
35
|
+
"@seeka-labs/converge": "SeekaConvergeCore"
|
|
36
|
+
}),
|
|
37
|
+
typecheckPlugin()
|
|
38
|
+
]
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
const postBuild = () => {
|
|
42
|
+
// Copy outfile to ../dist/src/browser
|
|
43
|
+
if (!existsSync(resolve('../../dist/src/browser'))) {
|
|
44
|
+
mkdirSync(resolve('../../dist/src/browser'), {
|
|
45
|
+
recursive: true,
|
|
46
|
+
});
|
|
47
|
+
}
|
|
48
|
+
copyFileSync(resolve(opts.outfile), resolve('../../dist/src/browser', `${pluginName}.min.js`))
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
if (watchBuild) {
|
|
52
|
+
const ctx = await context(opts);
|
|
53
|
+
|
|
54
|
+
async function buildWatch() {
|
|
55
|
+
await ctx.rebuild();
|
|
56
|
+
postBuild();
|
|
57
|
+
console.log('build succeeded');
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
await buildWatch();
|
|
61
|
+
|
|
62
|
+
// Start watch
|
|
63
|
+
let monitorInstance;
|
|
64
|
+
watch.createMonitor(resolve('./src'), function (monitor) {
|
|
65
|
+
console.log('watching ./src, press any key to exit');
|
|
66
|
+
monitorInstance = monitor;
|
|
67
|
+
|
|
68
|
+
monitor.on("created", async function (f, stat) {
|
|
69
|
+
console.log('rebuilding due to file created', f)
|
|
70
|
+
try {
|
|
71
|
+
await buildWatch();
|
|
72
|
+
}
|
|
73
|
+
catch (e) {
|
|
74
|
+
console.error(e);
|
|
75
|
+
}
|
|
76
|
+
})
|
|
77
|
+
monitor.on("changed", async function (f, curr, prev) {
|
|
78
|
+
console.log('rebuilding due to file changed', f)
|
|
79
|
+
try {
|
|
80
|
+
await buildWatch();
|
|
81
|
+
}
|
|
82
|
+
catch (e) {
|
|
83
|
+
console.error(e);
|
|
84
|
+
}
|
|
85
|
+
})
|
|
86
|
+
monitor.on("removed", async function (f, stat) {
|
|
87
|
+
console.log('rebuilding due to file deleted', f)
|
|
88
|
+
try {
|
|
89
|
+
await buildWatch();
|
|
90
|
+
}
|
|
91
|
+
catch (e) {
|
|
92
|
+
console.error(e);
|
|
93
|
+
}
|
|
94
|
+
})
|
|
95
|
+
})
|
|
96
|
+
|
|
97
|
+
// Support stopping
|
|
98
|
+
var stdin = process.stdin;
|
|
99
|
+
stdin.setRawMode(true);
|
|
100
|
+
stdin.resume();
|
|
101
|
+
stdin.setEncoding('utf8');
|
|
102
|
+
stdin.on('data', function (key) {
|
|
103
|
+
console.log('Stopping watch...');
|
|
104
|
+
monitorInstance.stop();
|
|
105
|
+
process.exit();
|
|
106
|
+
});
|
|
107
|
+
}
|
|
108
|
+
else {
|
|
109
|
+
await build(opts);
|
|
110
|
+
postBuild();
|
|
111
111
|
}
|
|
@@ -1,39 +1,39 @@
|
|
|
1
|
-
export function importAsGlobals(mapping) {
|
|
2
|
-
// https://github.com/evanw/esbuild/issues/337
|
|
3
|
-
// https://stackoverflow.com/a/3561711/153718
|
|
4
|
-
const escRe = (s) => s.replace(/[-\/\\^$*+?.()|[\]{}]/g, "\\$&");
|
|
5
|
-
const filter = new RegExp(
|
|
6
|
-
Object.keys(mapping)
|
|
7
|
-
.map((mod) => `^${escRe(mod)}$`)
|
|
8
|
-
.join("|"),
|
|
9
|
-
);
|
|
10
|
-
|
|
11
|
-
return {
|
|
12
|
-
name: "global-imports",
|
|
13
|
-
setup(build) {
|
|
14
|
-
build.onResolve({ filter }, (args) => {
|
|
15
|
-
if (!mapping[args.path]) {
|
|
16
|
-
throw new Error("Unknown global: " + args.path);
|
|
17
|
-
}
|
|
18
|
-
return {
|
|
19
|
-
path: args.path,
|
|
20
|
-
namespace: "external-global",
|
|
21
|
-
};
|
|
22
|
-
});
|
|
23
|
-
|
|
24
|
-
build.onLoad(
|
|
25
|
-
{
|
|
26
|
-
filter,
|
|
27
|
-
namespace: "external-global",
|
|
28
|
-
},
|
|
29
|
-
async (args) => {
|
|
30
|
-
const global = mapping[args.path];
|
|
31
|
-
return {
|
|
32
|
-
contents: `module.exports = ${global};`,
|
|
33
|
-
loader: "js",
|
|
34
|
-
};
|
|
35
|
-
},
|
|
36
|
-
);
|
|
37
|
-
},
|
|
38
|
-
};
|
|
1
|
+
export function importAsGlobals(mapping) {
|
|
2
|
+
// https://github.com/evanw/esbuild/issues/337
|
|
3
|
+
// https://stackoverflow.com/a/3561711/153718
|
|
4
|
+
const escRe = (s) => s.replace(/[-\/\\^$*+?.()|[\]{}]/g, "\\$&");
|
|
5
|
+
const filter = new RegExp(
|
|
6
|
+
Object.keys(mapping)
|
|
7
|
+
.map((mod) => `^${escRe(mod)}$`)
|
|
8
|
+
.join("|"),
|
|
9
|
+
);
|
|
10
|
+
|
|
11
|
+
return {
|
|
12
|
+
name: "global-imports",
|
|
13
|
+
setup(build) {
|
|
14
|
+
build.onResolve({ filter }, (args) => {
|
|
15
|
+
if (!mapping[args.path]) {
|
|
16
|
+
throw new Error("Unknown global: " + args.path);
|
|
17
|
+
}
|
|
18
|
+
return {
|
|
19
|
+
path: args.path,
|
|
20
|
+
namespace: "external-global",
|
|
21
|
+
};
|
|
22
|
+
});
|
|
23
|
+
|
|
24
|
+
build.onLoad(
|
|
25
|
+
{
|
|
26
|
+
filter,
|
|
27
|
+
namespace: "external-global",
|
|
28
|
+
},
|
|
29
|
+
async (args) => {
|
|
30
|
+
const global = mapping[args.path];
|
|
31
|
+
return {
|
|
32
|
+
contents: `module.exports = ${global};`,
|
|
33
|
+
loader: "js",
|
|
34
|
+
};
|
|
35
|
+
},
|
|
36
|
+
);
|
|
37
|
+
},
|
|
38
|
+
};
|
|
39
39
|
}
|
|
@@ -1,12 +1,12 @@
|
|
|
1
|
-
import { SampleAppConvergeSdkPlugin } from "./plugin";
|
|
2
|
-
import type { ISampleAppBrowserSdkPluginConfig } from "../../lib/browser/models";
|
|
3
|
-
|
|
4
|
-
declare global {
|
|
5
|
-
interface Window {
|
|
6
|
-
SampleAppConvergeSdkPlugin: (pluginConfig: ISampleAppBrowserSdkPluginConfig) => SampleAppConvergeSdkPlugin;
|
|
7
|
-
}
|
|
8
|
-
}
|
|
9
|
-
|
|
10
|
-
(window as Window).SampleAppConvergeSdkPlugin = (pluginConfig: ISampleAppBrowserSdkPluginConfig) => {
|
|
11
|
-
return new SampleAppConvergeSdkPlugin(pluginConfig);
|
|
12
|
-
};
|
|
1
|
+
import { SampleAppConvergeSdkPlugin } from "./plugin";
|
|
2
|
+
import type { ISampleAppBrowserSdkPluginConfig } from "../../lib/browser/models";
|
|
3
|
+
|
|
4
|
+
declare global {
|
|
5
|
+
interface Window {
|
|
6
|
+
SampleAppConvergeSdkPlugin: (pluginConfig: ISampleAppBrowserSdkPluginConfig) => SampleAppConvergeSdkPlugin;
|
|
7
|
+
}
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
(window as Window).SampleAppConvergeSdkPlugin = (pluginConfig: ISampleAppBrowserSdkPluginConfig) => {
|
|
11
|
+
return new SampleAppConvergeSdkPlugin(pluginConfig);
|
|
12
|
+
};
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
|
|
2
|
-
describe("SampleTest", () => {
|
|
3
|
-
test("Sample", () => {
|
|
4
|
-
expect(1).toStrictEqual(1);
|
|
5
|
-
});
|
|
6
|
-
});
|
|
1
|
+
|
|
2
|
+
describe("SampleTest", () => {
|
|
3
|
+
test("Sample", () => {
|
|
4
|
+
expect(1).toStrictEqual(1);
|
|
5
|
+
});
|
|
6
|
+
});
|
|
@@ -1,50 +1,50 @@
|
|
|
1
|
-
|
|
2
|
-
import {
|
|
3
|
-
ConvergeSdk,
|
|
4
|
-
IConvergePlugin,
|
|
5
|
-
TrackingActivityNames, getActivityName
|
|
6
|
-
} from '@seeka-labs/converge';
|
|
7
|
-
|
|
8
|
-
import type { ISampleAppBrowserSdkPluginConfig } from '../../../lib/browser/models'
|
|
9
|
-
|
|
10
|
-
import { version, dependencies } from '../../package.json';
|
|
11
|
-
|
|
12
|
-
const checkSdkAndPluginVersion = (expectedVersion: string, sdk: ConvergeSdk, pluginName: string): void => {
|
|
13
|
-
let runtimeVersion = sdk.config.runtime.ver as string;
|
|
14
|
-
runtimeVersion = runtimeVersion.replace('^', '');
|
|
15
|
-
expectedVersion = expectedVersion.replace('^', '');
|
|
16
|
-
|
|
17
|
-
if (expectedVersion !== runtimeVersion) {
|
|
18
|
-
sdk.debug.warn(`The expected SDK version of ${expectedVersion} for the ${pluginName} plugin does not match the current installlation runtime of ${runtimeVersion}`);
|
|
19
|
-
}
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
export class SampleAppConvergeSdkPlugin implements IConvergePlugin<ISampleAppBrowserSdkPluginConfig> {
|
|
23
|
-
constructor(pluginConfig: ISampleAppBrowserSdkPluginConfig) {
|
|
24
|
-
this.type = "seeka-app-example-name";
|
|
25
|
-
// this.name = this.type + "-" + pluginConfig.siteId;
|
|
26
|
-
this.name = this.type;
|
|
27
|
-
this.version = version;
|
|
28
|
-
this.sdk = {} as ConvergeSdk;
|
|
29
|
-
this.config = pluginConfig || {};
|
|
30
|
-
}
|
|
31
|
-
sdk: ConvergeSdk;
|
|
32
|
-
|
|
33
|
-
privacyConfig = {
|
|
34
|
-
// TODO
|
|
35
|
-
requiresIabPurposes: []
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
name: string;
|
|
39
|
-
type: string;
|
|
40
|
-
version: string;
|
|
41
|
-
config: ISampleAppBrowserSdkPluginConfig;
|
|
42
|
-
|
|
43
|
-
async init(_params: any): Promise<void> {
|
|
44
|
-
checkSdkAndPluginVersion(dependencies['@seeka-labs/converge'], this.sdk, this.name)
|
|
45
|
-
}
|
|
46
|
-
|
|
47
|
-
isLoaded(): boolean {
|
|
48
|
-
return true;
|
|
49
|
-
}
|
|
1
|
+
|
|
2
|
+
import {
|
|
3
|
+
ConvergeSdk,
|
|
4
|
+
IConvergePlugin,
|
|
5
|
+
TrackingActivityNames, getActivityName
|
|
6
|
+
} from '@seeka-labs/converge';
|
|
7
|
+
|
|
8
|
+
import type { ISampleAppBrowserSdkPluginConfig } from '../../../lib/browser/models'
|
|
9
|
+
|
|
10
|
+
import { version, dependencies } from '../../package.json';
|
|
11
|
+
|
|
12
|
+
const checkSdkAndPluginVersion = (expectedVersion: string, sdk: ConvergeSdk, pluginName: string): void => {
|
|
13
|
+
let runtimeVersion = sdk.config.runtime.ver as string;
|
|
14
|
+
runtimeVersion = runtimeVersion.replace('^', '');
|
|
15
|
+
expectedVersion = expectedVersion.replace('^', '');
|
|
16
|
+
|
|
17
|
+
if (expectedVersion !== runtimeVersion) {
|
|
18
|
+
sdk.debug.warn(`The expected SDK version of ${expectedVersion} for the ${pluginName} plugin does not match the current installlation runtime of ${runtimeVersion}`);
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
export class SampleAppConvergeSdkPlugin implements IConvergePlugin<ISampleAppBrowserSdkPluginConfig> {
|
|
23
|
+
constructor(pluginConfig: ISampleAppBrowserSdkPluginConfig) {
|
|
24
|
+
this.type = "seeka-app-example-name";
|
|
25
|
+
// this.name = this.type + "-" + pluginConfig.siteId;
|
|
26
|
+
this.name = this.type;
|
|
27
|
+
this.version = version;
|
|
28
|
+
this.sdk = {} as ConvergeSdk;
|
|
29
|
+
this.config = pluginConfig || {};
|
|
30
|
+
}
|
|
31
|
+
sdk: ConvergeSdk;
|
|
32
|
+
|
|
33
|
+
privacyConfig = {
|
|
34
|
+
// TODO
|
|
35
|
+
requiresIabPurposes: []
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
name: string;
|
|
39
|
+
type: string;
|
|
40
|
+
version: string;
|
|
41
|
+
config: ISampleAppBrowserSdkPluginConfig;
|
|
42
|
+
|
|
43
|
+
async init(_params: any): Promise<void> {
|
|
44
|
+
checkSdkAndPluginVersion(dependencies['@seeka-labs/converge'], this.sdk, this.name)
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
isLoaded(): boolean {
|
|
48
|
+
return true;
|
|
49
|
+
}
|
|
50
50
|
}
|