test-bdk-cli 0.1.7 → 0.1.9

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.
@@ -118,7 +118,61 @@ function registerCreate(program) {
118
118
  }
119
119
  await copyRecursive(templatesDir, targetDir);
120
120
  }
121
+ // Ensure template contains basic assets and translations. If the template
122
+ // did not include them, create defaults (iframe, logos, translations).
123
+ try {
124
+ const assetsDir = path_1.default.join(targetDir, 'assets');
125
+ if (!fs_1.default.existsSync(assetsDir))
126
+ fs_1.default.mkdirSync(assetsDir, { recursive: true });
127
+ const iframePath = path_1.default.join(assetsDir, 'iframe.html');
128
+ if (!fs_1.default.existsSync(iframePath)) {
129
+ fs_1.default.writeFileSync(iframePath, `<!doctype html>\n<html lang="en">\n <head>\n <meta charset="utf-8" />\n <meta name="viewport" content="width=device-width,initial-scale=1" />\n <title>Sample Iframe</title>\n <style>body{font-family:Arial,Helvetica,sans-serif;padding:20px}</style>\n </head>\n <body>\n <h1>Hello from the app iframe</h1>\n <p>This is a simple placeholder iframe page generated by the CLI.</p>\n </body>\n</html>\n`, 'utf8');
130
+ }
131
+ const logoPath = path_1.default.join(assetsDir, 'logo.svg');
132
+ if (!fs_1.default.existsSync(logoPath)) {
133
+ fs_1.default.writeFileSync(logoPath, `<svg xmlns="http://www.w3.org/2000/svg" width="240" height="240" viewBox="0 0 240 240">\n <rect width="240" height="240" rx="24" fill="#0b6c6c" />\n <g fill="#fff" transform="translate(40,40)">\n <rect x="0" y="0" width="160" height="160" rx="12" />\n </g>\n</svg>\n`, 'utf8');
134
+ }
135
+ const logoSmall = path_1.default.join(assetsDir, 'logo-small.svg');
136
+ if (!fs_1.default.existsSync(logoSmall)) {
137
+ fs_1.default.writeFileSync(logoSmall, `<svg xmlns="http://www.w3.org/2000/svg" width="64" height="64" viewBox="0 0 64 64">\n <rect width="64" height="64" rx="8" fill="#0b6c6c" />\n <rect x="12" y="12" width="40" height="40" rx="6" fill="#fff" />\n</svg>\n`, 'utf8');
138
+ }
139
+ const translationsDir = path_1.default.join(targetDir, 'translations');
140
+ if (!fs_1.default.existsSync(translationsDir))
141
+ fs_1.default.mkdirSync(translationsDir, { recursive: true });
142
+ const enPath = path_1.default.join(translationsDir, 'en.json');
143
+ if (!fs_1.default.existsSync(enPath)) {
144
+ fs_1.default.writeFileSync(enPath, JSON.stringify({
145
+ app: {
146
+ name: 'Zen Tunes',
147
+ short_description: 'Play the famous zen tunes in your help desk.',
148
+ long_description: 'Play the famous zen tunes in your help desk and \n listen to the beats it has to offer.',
149
+ installation_instructions: 'Simply click install.'
150
+ }
151
+ }, null, 2), 'utf8');
152
+ }
153
+ }
154
+ catch (e) {
155
+ // ignore any template-creation errors
156
+ }
121
157
  const manifestPath = path_1.default.resolve(targetDir, 'manifest.json');
158
+ // If template didn't include a manifest, create a sensible default so
159
+ // the CLI can prompt and the app can be packaged.
160
+ if (!fs_1.default.existsSync(manifestPath)) {
161
+ const defaultManifest = {
162
+ name: appName,
163
+ version: '0.1.0',
164
+ author: '',
165
+ description: '',
166
+ main: 'dist/index.html',
167
+ permissions: []
168
+ };
169
+ try {
170
+ fs_1.default.writeFileSync(manifestPath, JSON.stringify(defaultManifest, null, 2), 'utf8');
171
+ }
172
+ catch (e) {
173
+ // ignore write errors
174
+ }
175
+ }
122
176
  if (fs_1.default.existsSync(manifestPath)) {
123
177
  const manifest = JSON.parse(fs_1.default.readFileSync(manifestPath, 'utf8'));
124
178
  const dynamicImport = new Function('s', 'return import(s)');
@@ -11,14 +11,15 @@ const ajv_1 = __importDefault(require("ajv"));
11
11
  const child_process_1 = require("child_process");
12
12
  function registerPack(program) {
13
13
  program
14
- .command('pack')
14
+ .command('pack [source]')
15
+ .alias('apps:pack')
15
16
  .description('Package the app for publishing')
16
17
  .option('--output <path>', 'output directory or filename', './dist')
17
18
  .option('--format <fmt>', 'archive format (zip|tar)', 'zip')
18
19
  .option('--no-validate', 'skip manifest validation')
19
20
  .option('--source <dir>', 'source directory to package', '.')
20
- .action(async (opts) => {
21
- const sourceDir = path_1.default.resolve(process.cwd(), opts.source || '.');
21
+ .action(async (sourceArg, opts) => {
22
+ const sourceDir = path_1.default.resolve(process.cwd(), sourceArg || opts.source || '.');
22
23
  const manifestPath = path_1.default.resolve(sourceDir, 'manifest.json');
23
24
  if (!fs_1.default.existsSync(manifestPath)) {
24
25
  console.error('manifest.json not found in source directory:', sourceDir);
@@ -29,7 +30,7 @@ function registerPack(program) {
29
30
  if (fs_1.default.existsSync(schemaPath)) {
30
31
  const manifest = JSON.parse(fs_1.default.readFileSync(manifestPath, 'utf8'));
31
32
  const schema = JSON.parse(fs_1.default.readFileSync(schemaPath, 'utf8'));
32
- const ajv = new ajv_1.default();
33
+ const ajv = new ajv_1.default({ allowUnionTypes: true });
33
34
  const validate = ajv.compile(schema);
34
35
  const valid = validate(manifest);
35
36
  if (!valid) {
@@ -9,7 +9,8 @@ const path_1 = __importDefault(require("path"));
9
9
  const child_process_1 = require("child_process");
10
10
  function registerPublish(program) {
11
11
  program
12
- .command('publish')
12
+ .command('publish [source]')
13
+ .alias('apps:publish')
13
14
  .description('Publish app archive to BoldDesk marketplace')
14
15
  .option('--file <path>', 'package file to upload (zip or tar)')
15
16
  .option('--token <token>', 'API token for BoldDesk')
@@ -17,14 +18,15 @@ function registerPublish(program) {
17
18
  .option('--dry-run', 'do not actually upload, show what would be sent', false)
18
19
  .option('--private', 'mark uploaded app as private', false)
19
20
  .option('--source <dir>', 'source directory to pack before publishing', '.')
20
- .action(async (opts) => {
21
+ .action(async (sourceArg, opts) => {
21
22
  try {
22
23
  let filePath = opts.file;
23
- const sourceDir = path_1.default.resolve(process.cwd(), opts.source || '.');
24
+ const sourceDir = path_1.default.resolve(process.cwd(), sourceArg || opts.source || '.');
24
25
  if (!filePath) {
25
26
  console.log('No package file given — running `bdk pack` to create archive...');
26
27
  try {
27
- (0, child_process_1.execSync)('node dist/index.js pack --source . --output ./dist --format zip', { cwd: sourceDir, stdio: 'inherit' });
28
+ const cliEntry = path_1.default.resolve(__dirname, '../index.js');
29
+ (0, child_process_1.execSync)(`node "${cliEntry}" pack --source . --output ./dist --format zip`, { cwd: sourceDir, stdio: 'inherit' });
28
30
  }
29
31
  catch (e) {
30
32
  console.error('Automatic pack failed; please run `bdk pack` manually or provide --file');
@@ -4,6 +4,7 @@ exports.registerRun = registerRun;
4
4
  function registerRun(program) {
5
5
  program
6
6
  .command('run')
7
+ .alias('apps:run')
7
8
  .description('Run the app locally with live reload')
8
9
  .option('--port <number>', 'port to run', '3000')
9
10
  .option('--env <env>', 'environment', 'dev')
@@ -5,6 +5,7 @@ const child_process_1 = require("child_process");
5
5
  function registerTest(program) {
6
6
  program
7
7
  .command('test')
8
+ .alias('apps:test')
8
9
  .description('Run unit and integration tests')
9
10
  .option('--watch', 're-run tests on file changes', false)
10
11
  .option('--coverage', 'generate coverage report', false)
@@ -26,6 +26,7 @@ function bumpVersion(v, level) {
26
26
  function registerVersion(program) {
27
27
  program
28
28
  .command('version')
29
+ .alias('apps:version')
29
30
  .description('Show or bump app version')
30
31
  .option('--bump <level>', 'patch|minor|major')
31
32
  .option('--set <version>', 'set exact version')
Binary file
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "test-bdk-cli",
3
- "version": "0.1.7",
3
+ "version": "0.1.9",
4
4
  "description": "test CLI",
5
5
  "author": "@raisulaslam",
6
6
  "bin": {
@@ -21,8 +21,7 @@
21
21
  "commander": "^10.0.0",
22
22
  "form-data": "^4.0.0",
23
23
  "inquirer": "^9.0.0",
24
- "node-fetch": "^2.6.7",
25
- "test-bdk-cli": "^0.1.6"
24
+ "node-fetch": "^2.6.7"
26
25
  },
27
26
  "devDependencies": {
28
27
  "@types/archiver": "^7.0.0",
@@ -5,7 +5,7 @@
5
5
  "required": ["name", "version", "author"],
6
6
  "properties": {
7
7
  "name": { "type": "string" },
8
- "version": { "type": "string", "pattern": "^\\d+\\.\\d+\\.\\d+$" },
8
+ "version": { "type": "string", "pattern": "^\\d+\\.\\d+\\.\\d+(?:[-+][0-9A-Za-z.-]+)?$" },
9
9
  "author": { "type": ["string", "object"] },
10
10
  "description": { "type": "string" },
11
11
  "main": { "type": "string" },
@@ -1,3 +0,0 @@
1
- # React template
2
-
3
- This is a minimal React template for BoldDesk apps. Use `bdk create my-app --template react` to scaffold.
@@ -1,8 +0,0 @@
1
- {
2
- "name": "sample-react-app",
3
- "version": "0.1.0",
4
- "author": "Your Name",
5
- "description": "A sample React BoldDesk app",
6
- "main": "dist/index.html",
7
- "permissions": []
8
- }