Skip to content

Commit ddbce16

Browse files
committed
Merge branch 'find-ASC-token' into Dev
2 parents 9a59cc1 + af4e1e7 commit ddbce16

18 files changed

+506
-308
lines changed

CHANGELOG.md

Lines changed: 68 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -4,68 +4,110 @@ All notable changes to the Adobe Script Runner extension will be documented in t
44

55
## [Unreleased]
66

7-
## Released
7+
### Added
8+
9+
* Option to always **Execute File From Config** file defined in **Execute This** section, ignoring the one in active viewer.
10+
* Option to **Execute File From Token** `Adobe-Script-Runner "path/to/file.jsx"` in active document to execute file between the quotes.
11+
12+
### Changed
13+
14+
* Codebase rewritten from scratch.
15+
* Renamed configuration keys and titles.
16+
17+
### Fixed
18+
19+
*
20+
21+
### Removed
22+
23+
* Checkbox **Run Untitled**.
24+
25+
---
826

927
## [0.2.1] 2019-01-05
1028

11-
- Updates default Windows paths to CC2019 version.
12-
- Updates descriptions for `Run Untitled`, `Save Dirty`, and `Temp File` in extensions Settings window.
29+
### Changed
30+
31+
* Updates default Windows paths to CC2019 version.
32+
* Updates descriptions for `Run Untitled`, `Save Dirty`, and `Temp File` in extensions Settings window.
33+
34+
---
1335

1436
## [0.2.0] 2018-03-29
1537

16-
- Fixed bug when settings were not registered until app restart.
17-
- Fixed issue with HOME "~/" paths.
18-
- Changed code flow. Splits everything to modules for easier maintenance and development. Also makes it easier for other apps to adopt the functionality.
19-
- Ports functionality to [Atom.io](https://atom.io/packages/adobe-script-runner).
38+
### Fixed
39+
40+
* Fixed bug when settings were not registered until app restart.
41+
* Fixed issue with HOME "~/" paths.
42+
43+
### Changed
44+
45+
* Changed code flow. Splits everything into modules for easier maintenance and development. Also makes it easier for other apps to adopt the functionality.
46+
* Ports functionality to [Atom.io](https://atom.io/packages/adobe-script-runner).
47+
48+
---
2049

2150
## [0.1.2] 2018-03-14
2251

2352
### Added
2453

25-
- Added default keybinding `Cmd+R` ro tun `adobeScriptRunner.ae` command.
26-
- Added instructions on how to assign keybindings to commands in `README.md` file.
54+
* Default keybinding `Cmd+R` ro tun `adobeScriptRunner.ae` command.
55+
* Instructions on how to assign keybindings to commands in `README.md` file.
56+
57+
---
2758

2859
## [0.1.1] 2018-03-14
2960

3061
### Changed
3162

32-
- Changed extension icon.
63+
* Extension icon.
64+
65+
---
3366

3467
## [0.1.0] 2018-03-13
3568

3669
### Added
3770

38-
- Support to open scripts inside `Adobe InCopy`.
39-
- Support for Windows.
71+
* Support to execute scripts in `Adobe InCopy`.
72+
* Support for Windows.
73+
74+
---
4075

4176
## [0.0.3] 2018-03-12
4277

4378
### Added
4479

45-
- Support to open scripts inside `Adobe ExtendScript Toolkit`.
46-
- Looping gif to README.md file that looks fantastic.
47-
80+
* Support to open scripts inside `Adobe ExtendScript Toolkit`.
81+
* Looping gif to README.md file that looks amazing.
82+
83+
### Fixed
84+
85+
* Fixed typos in `README.md`.
86+
4887
### Changed
4988

50-
- Updated `extension.js` to use es6 syntax.
51-
- Updated info message to show app name the script has been sent to.
52-
- Renamed settings object `adobeScriptLauncher` to `adobeScriptRunner`.
53-
- Fixed typos in `README.md`.
54-
- Changed location of temp file `Snippet.js` to `~/.vscode` instead of `~/Desktop` folder.
55-
- Created `resources` folder to dump all image files there.
89+
* Updated `extension.js` to use es6 syntax.
90+
* Updated info message to show app name the script has been sent to.
91+
* Renamed settings object `adobeScriptLauncher` to `adobeScriptRunner`.
92+
* Changed location of temp file `Snippet.js` to `~/.vscode` instead of `~/Desktop` folder.
93+
* Created `resources` folder to dump all image files there.
94+
95+
---
5696

5797
## [0.0.2] 2018-03-11
5898

5999
### Added
60100

61-
- Support to run scripts inside `Adobe Illustrator`.
62-
- Support to run scripts inside `Adobe InDesign`.
101+
* Support to execute scripts in `Adobe Illustrator`.
102+
* Support to execute scripts in `Adobe InDesign`.
63103

64104
### Changed
65105

66-
- README.md and CHANGELOG.md files to reflect changes.
67-
- Refactored `scriptCommands` object.
106+
* README.md and CHANGELOG.md files to reflect changes.
107+
* Refactored `scriptCommands` object.
108+
109+
---
68110

69111
## [0.0.1] 2018-03-10
70112

71-
- Initial release
113+
* Initial release

README.md

Lines changed: 44 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# Adobe Script Runner
22

3-
Script runner for Adobe applications right from VSCode. Extension also available for [Atom.io](https://atom.io/packages/adobe-script-runner).
3+
Script runner for Adobe applications right from VSCode. Extension available for [Atom.io](https://atom.io/packages/adobe-script-runner), [Sublime Text](https://github.com/rendertom/Sublime-Text-Adobe-Script-Runner) and [VSCode](https://marketplace.visualstudio.com/items?itemName=renderTom.adobe-script-runner).
44

55
![Adobe Script Runner](/resources/Adobe-Script-Runner.gif)
66

@@ -15,15 +15,15 @@ Script runner for Adobe applications right from VSCode. Extension also available
1515

1616
## Features
1717

18-
Run commands are accessible via `Command Palette`. Simply click `F1` or `Cmd+Shift+P` and start typing the name of `supported applications`. Click enter to run script inside the selected application.
18+
Run commands are accessible via `Command Palette`. Simply click `F1` or `Cmd+Shift+P` and start typing the name of `supported applications`. Click enter to run the script inside the selected application.
1919

20-
Extension will open host application first if it's not running, and then execute the script.
20+
The extension will open host application first if it's not running, and then execute the script.
2121

22-
> Tip: You don't need to have file saved inside VSCode. Extension will be able to run code from unsaved documents. Kaboom!
22+
> Tip: You don't need to have the file saved inside VSCode. The extension will be able to run code from unsaved documents.
2323
24-
Map keyboard shortcuts to execute script even faster - `Cmd+R` is bind to run script inside After Effects by default. Read how to change it in [Key bindings](#key-bindings).
24+
Map keyboard shortcuts to execute a script even faster - `Cmd+R` is bind to run a script inside After Effects by default. Read how to change it in [Key bindings](#key-bindings).
2525

26-
**Note:** Contribution to support other Adobe applications is highly encouraged.
26+
Adobe Script Runner executes script in the active viewer by default. However, when working with multi-file scripts, it is common to set a path to execute a master file, i.e `index.js`, from within a file that's in the active view. Such behavior can be modified using [Token](#token) or setting up [execute this](#execute-this) file in the settings.
2727

2828
## Installation
2929

@@ -37,20 +37,20 @@ Map keyboard shortcuts to execute script even faster - `Cmd+R` is bind to run sc
3737

3838
## In action
3939

40-
- Launch VSCode and open your own jsx file, or for testing just type `alert("Hello World")`.
41-
- Click `Cmd+R` on Mac or `Ctrl+R` on Windows or launch `Command Palette` with keyboard shortcut `F1` or `Cmd+Shift+P` and type `Adobe After Effects` and click enter.
42-
- Hopefully After Effects will fire up and run your script 🙏
40+
- Launch VSCode and open jsx file, or for testing simply type `alert("Hello World");`.
41+
- Click `Cmd+R` on Mac or `Ctrl+R` on Windows, or launch `Command Palette` with keyboard shortcut `F1` or `Cmd+Shift+P`, and type `Adobe After Effects` and click enter.
42+
- Hopefully After Effects will fire up and execute your script 🙏
4343

4444
## Key bindings
4545

46-
Keyboard shortcut `Cmd+R` is bind to `adobeScriptRunner.ae` command, which will run script inside Adobe After Effects. To change the command or assign different shortcut, do the following:
46+
Keyboard shortcut `Cmd+R` is bind to `adobeScriptRunner.ae` command, which will run a script inside Adobe After Effects. To change the command or assign a different shortcut, do the following:
4747

4848
- Open Keyboard Shortcuts editor and click on the link `keybindings.json`.
4949
- This will open the Default Keyboard Shortcuts on the left and your `keybindings.json` file where you can overwrite the default bindings on the right.
50-
- With `keybindings.json` in focus click `Cmd+K` twice to open interactive keybinding modal window (or whatever it’s called) and follow the on screen instructions. This will create a new binding entry in `keybindings.json` file.
51-
- Edit the `command` property to `adobeScriptRunner.XX`, where XX is abbreviation of the application. Check available abbreviations in `Extensions > Adobe Script Runner > Contributions` tab.
50+
- With `keybindings.json` in focus click `Cmd+K` twice to open an interactive keybinding modal window (or whatever it’s called) and follow the on-screen instructions. This will create a new binding entry in the `keybindings.json` file.
51+
- Edit the `command` property to `adobeScriptRunner.XX`, where XX is an abbreviation of the application. Check available abbreviations in `Extensions > Adobe Script Runner > Contributions` tab.
5252

53-
End result should look like this.
53+
The result should look something like this:
5454

5555
```json
5656
{
@@ -60,25 +60,48 @@ End result should look like this.
6060
},
6161
```
6262

63-
For more information about keybinding check official [Key Bindings for Visual Studio Code]( https://code.visualstudio.com/docs/getstarted/keybindings).
63+
For more information about keybinding check official [Key Bindings for Visual Studio Code](https://code.visualstudio.com/docs/getstarted/keybindings).
64+
65+
## Token
66+
67+
Use token to execute a different file, rather than the one in the viewer. Add `Adobe-script-runner "path/to/file.jsx"` at the beginning of the file in the active document to always execute the file between quotes.
68+
69+
```javascript
70+
/*
71+
Adobe-script-runner '../../index.js'
72+
Executes file between quotes rather than the one in the active viewer.
73+
*/
74+
75+
alert('Hello World'); // This line never gets executed, unless `index.js` is referencing the file in viewer.
76+
```
77+
78+
The file path gets resolved by joining the path of the file in the viewer and the file within the quotes.
79+
80+
## Execute this
81+
82+
Use this option to set-up a path to a file to execute always, ignoring the file in the viewer, globally or per-project basis. To do so, open settings (`Cmd+,` on Mac or `Ctrl+,` on Windows) and set the path to a file in **Extensions -> Adobe Script Runner -> Execute This**.
83+
84+
The file path gets resolved by joining this path and the Workspace (or Root `/`) folder.
6485

6586
## Settings
6687

6788
Click `Cmd+,` on Mac or `Ctrl+,` on Windows to modify settings. Extension exposes the following settings:
6889

69-
- `adobeScriptRunner.saveDirty`: toggle to run unsaved (dirty) files.
70-
- `adobeScriptRunner.runUntitled`: toggle to run untitled files. Define location of temporary file in `adobeScriptRunner.tempFile` setting.
71-
- `adobeScriptRunner.tempFile`: location to save temporary file. Used only when `adobeScriptRunner.runUntitled` is enabled.
90+
- `adobeScriptRunner.executeFileFromConfig`: Whether to execute file, defined in config `.vscode/settings.json` file. See more in [Execute this](#execute-this) section.
91+
- `adobeScriptRunner.executeFileFromToken`: Whether to search for `Adobe-Script-Runner "path/to/file.jsx"` token in active document, and execute file within the quotes. See more in [Token](#token) section.
92+
- `adobeScriptRunner.executeThis`: A path to a file to execute always, ignoring the file in the viewer, globally or per-project basis. See more in [Execute this](#execute-this) section.
93+
- `adobeScriptRunner.saveFileBeforeExecution`: Whether to save file before execution.
94+
- `adobeScriptRunner.temporaryFile`: Path to a temporary file where Untitled document gets saved prior to execution.
7295

7396
**For Windows users only:**
7497

75-
- `adobeScriptRunner.winEstkExe`: path to Adobe ExtendScript Toolkit executable (ExtendScript Toolkit.exe).
76-
- `adobeScriptRunner.winAfterFxExe`: path to Adobe After Effects executable (AfterFX.exe).
98+
- `adobeScriptRunner.winAfterEffectsExe`: path to Adobe After Effects executable (AfterFX.exe).
99+
- `adobeScriptRunner.winExtendscriptToolkitExe`: path to Adobe ExtendScript Toolkit executable (ExtendScript Toolkit.exe).
77100
- `adobeScriptRunner.winIllustratorExe`: path to Adobe Illustrator executable (Illustrator.exe).
78101
- `adobeScriptRunner.winPhotoshopExe`: path to Adobe Photoshop executable (Photoshop.exe).
79102

80-
Executable paths for InCopy and InDesign for Windows are not exposed because they are handled differently than the rest of the apps. Go figure Adobe ¯\\\_(ツ)\_
103+
Executable paths for InCopy and InDesign for Windows are not exposed because they are handled differently than the rest of the Adobe apps. Go figure Adobe ¯\\\_(ツ)\_
81104

82105
## Known issues
83106

84-
- Host application does not get focus on script run.
107+
- The host application does not get focus on script run.

lib/buildCommand.js

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
const cp = require('child_process');
2+
const getScriptFile = require('./getScriptFile.js');
3+
const getShellCommand = require('./getShellCommand.js');
4+
const ide = require('./ide.js');
5+
6+
/**
7+
* Builds and executes command.
8+
* @param {Object} hostApp entry from hostApps[hostApp].
9+
*/
10+
function buildCommand(hostApp) {
11+
try {
12+
getScriptFile(function(scriptFile) {
13+
getShellCommand(hostApp, scriptFile, function(command) {
14+
console.log('Running shell command:', command);
15+
cp.exec(command, (error, stdout, stderr) => {
16+
if (error) {
17+
console.error(`exec error: ${error}`);
18+
return;
19+
}
20+
21+
console.log(stdout);
22+
console.log(stderr);
23+
});
24+
ide.showInformationMessage(`Script sent to ${hostApp.appName}`);
25+
});
26+
});
27+
} catch (error) {
28+
if (typeof error !== 'undefined') {
29+
console.log(error);
30+
}
31+
}
32+
}
33+
34+
module.exports = buildCommand;

lib/config.js

Lines changed: 0 additions & 7 deletions
This file was deleted.

lib/editor.js

Lines changed: 0 additions & 29 deletions
This file was deleted.

lib/extension.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
const buildCommand = require('./static/buildCommand.js');
2-
const hostApps = require('./static/hostApps.js');
1+
const buildCommand = require('./buildCommand.js');
2+
const hostApps = require('./hostApps.js');
33
const vscode = require('vscode');
44

55
/**

lib/file.js

Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
const fs = require('fs');
2+
const os = require('os');
3+
const path = require('path');
4+
5+
const file = {
6+
/**
7+
* Checks if file exists at a given path.
8+
* @param {String} filePath Path to file.
9+
* @returns {Boolean} `True` if exists, `False` otherwise.
10+
*/
11+
exists(filePath) {
12+
return fs.existsSync(filePath);
13+
},
14+
15+
/**
16+
* Checks whether file exists at a path is file.
17+
* @param {String} filePath Path to file.
18+
* @returns {Boolean} `True` if file exists and is file, `False` otherwise.
19+
*/
20+
isFile(filePath) {
21+
return this.exists(filePath) && fs.lstatSync(filePath).isFile();
22+
},
23+
24+
/**
25+
* Saves contents of the file.
26+
* @param {String} contents Contents to save.
27+
* @param {String} filePath Path to a file.
28+
* @returns {String} Path to a saved file.
29+
*/
30+
saveFile(contents, filePath) {
31+
filePath = this.untildify(filePath);
32+
33+
const folder = path.dirname(filePath);
34+
if (!fs.existsSync(folder)) {
35+
fs.mkdirSync(folder, {
36+
recursive: true
37+
});
38+
}
39+
40+
fs.writeFileSync(filePath, contents);
41+
42+
return filePath;
43+
},
44+
45+
/**
46+
* Convert a tilde '~' path to an absolute path: '~/Desktop' to '/user/XXX/Desktop'
47+
* @param {String} pathWithTilde Path to untildify.
48+
* @returns {String} Absolute path as string.
49+
*/
50+
untildify(pathWithTilde) {
51+
const homeDirectory = os.homedir();
52+
53+
if (typeof pathWithTilde !== 'string') {
54+
throw new TypeError(`Expected a string, got ${typeof pathWithTilde}`);
55+
}
56+
57+
return homeDirectory ? pathWithTilde.replace(/^~(?=$|\/|\\)/, homeDirectory) : pathWithTilde;
58+
},
59+
};
60+
61+
module.exports = file;

0 commit comments

Comments
 (0)