rad-coder 1.0.0 → 1.0.1

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/bin/cli.js CHANGED
@@ -6,8 +6,45 @@ const fs = require('fs');
6
6
  // Get the package root directory
7
7
  const packageRoot = path.join(__dirname, '..');
8
8
 
9
- // Get user's current working directory
10
- const userDir = process.cwd();
9
+ // Extract creative ID from input (can be a direct ID or a preview URL)
10
+ function extractCreativeId(input) {
11
+ if (!input) return null;
12
+ const urlMatch = input.match(/creatives\/([a-f0-9]+)/i);
13
+ return urlMatch ? urlMatch[1] : input;
14
+ }
15
+
16
+ // Get creative ID from command line argument
17
+ const input = process.argv[2];
18
+ const creativeId = extractCreativeId(input);
19
+
20
+ if (!creativeId) {
21
+ console.log('Usage: npx rad-coder <creativeId or previewUrl>');
22
+ console.log('');
23
+ console.log('Examples:');
24
+ console.log(' npx rad-coder 697b80fcc6e904025f5147a0');
25
+ console.log(' npx rad-coder https://studio.responsiveads.com/creatives/697b80fcc6e904025f5147a0/preview');
26
+ process.exit(1);
27
+ }
28
+
29
+ // Determine the target directory
30
+ const cwd = process.cwd();
31
+ const currentDirName = path.basename(cwd);
32
+ let userDir;
33
+
34
+ if (currentDirName === creativeId) {
35
+ // Already in the correct folder
36
+ userDir = cwd;
37
+ console.log(`Using existing folder: ./${creativeId}`);
38
+ } else {
39
+ // Create or use a folder with the creative ID
40
+ userDir = path.join(cwd, creativeId);
41
+ if (!fs.existsSync(userDir)) {
42
+ fs.mkdirSync(userDir);
43
+ console.log(`Created folder: ./${creativeId}`);
44
+ } else {
45
+ console.log(`Using existing folder: ./${creativeId}`);
46
+ }
47
+ }
11
48
 
12
49
  // Files to copy to user's directory on first run
13
50
  const filesToCopy = [
@@ -23,7 +60,7 @@ filesToCopy.forEach(({ template, target }) => {
23
60
  const templatePath = path.join(packageRoot, 'templates', template);
24
61
  if (fs.existsSync(templatePath)) {
25
62
  fs.copyFileSync(templatePath, targetPath);
26
- console.log(` Created ${target}`);
63
+ console.log(` Created ${target}`);
27
64
  filesCreated = true;
28
65
  }
29
66
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "rad-coder",
3
- "version": "1.0.0",
3
+ "version": "1.0.1",
4
4
  "description": "Development environment for testing ResponsiveAds creative custom JS with hot-reload",
5
5
  "bin": {
6
6
  "rad-coder": "./bin/cli.js"
package/server/index.js CHANGED
@@ -174,9 +174,9 @@ async function fetchCreativeConfig(creativeId) {
174
174
  flowlineName: fl.name || 'Unknown',
175
175
  sizes: sizes,
176
176
  isFluid: fl.fullyFluid || false,
177
- adSource: '//publish.responsiveads.com/ads/',
178
- flSource: '//publish.responsiveads.com/flowlines/',
179
- radicalScript: 'https://publish.responsiveads.com/libs/radical.r8.min.js',
177
+ adSource: '//edit.responsiveads.com/ads/',
178
+ flSource: '//edit.responsiveads.com/flowlines/',
179
+ radicalScript: 'https://studio.responsiveads.com/js/libs/radical.min.js',
180
180
  server: {
181
181
  port: 3000,
182
182
  host: 'localhost'