Skip to content

Commit

Permalink
Merge pull request #135 from monaca/dev_fix_build_path_monaca_import_…
Browse files Browse the repository at this point in the history
…clone

Fix monaca import and build path
  • Loading branch information
yong-asial authored Jul 25, 2018
2 parents 918c645 + 98b9cf7 commit 5d24f80
Show file tree
Hide file tree
Showing 5 changed files with 59 additions and 21 deletions.
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,11 @@
CHANGELOG
====

v2.7.9
----
* Modified `monaca remote build` to ask users providing the build directory if it is not specified. In addition, the default build directory is changed to `Desktop` directory.
* Fixed `monaca import` to NOT set `project_id` to `local_properties.json` (with `monaca-lib@2.7.9`)

v2.7.8
----
* Always append `webpack-dev-server/client` to webpack configuration to fix `Angular`'s `live reloading` with `monaca-lib@2.7.8`
Expand Down
8 changes: 4 additions & 4 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

7 changes: 3 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "monaca",
"version": "2.7.8",
"version": "2.7.9",
"description": "Monaca Command Line Tool",
"bin": {
"monaca": "bin/monaca"
Expand Down Expand Up @@ -39,13 +39,12 @@
"ip": "^1.1.5",
"live-server": "1.2.0",
"monaca-inquirer": "^1.0.4",
"monaca-lib": "^2.7.8",
"monaca-lib": "^2.7.9",
"open": "0.0.5",
"optimist": "^0.6.1",
"portfinder": "^1.0.7",
"q": "^1.1.2",
"shelljs": "^0.3.0",
"xmldom": "^0.1.19"
},
"devDependencies": {}
}
}
58 changes: 46 additions & 12 deletions src/remote.js
Original file line number Diff line number Diff line change
Expand Up @@ -165,12 +165,28 @@ RemoteTask.remote = function(task) {
return result.binary_url ? monaca.getSessionUrl(result.binary_url) : Q.reject(result.error_message);
}
)
// Getting session URL.
// Getting session URL && Preparing the file path
.then(
function(sessionUrl) {
// return the filepath if it is specified
if (params.output) {
return Q.resolve({
sessionUrl: sessionUrl,
buildDir: params.output
});
} else {
return specifyBuildDirectory(sessionUrl);
}
}
)
// Download file
.then(
function(result) {
let sessionUrl = result.sessionUrl;
let buildDir = result.buildDir;
return monaca.download(sessionUrl, {}, function(response) {
if (params.output) {
return path.resolve(params.output);
return path.resolve(params.output); //filepath specified by --path
}

var filename = 'output.bin';
Expand All @@ -181,16 +197,8 @@ RemoteTask.remote = function(task) {
}
}

let build_path = '';
try {
build_path = path.join( process.env[(process.platform == 'win32') ? 'USERPROFILE' : 'HOME'], 'Desktop');
} catch (e) {
build_path = '/tmp/build';
console.log('could not get the desktop directory', e);
console.log('save to ', build_path);
shell.mkdir('-p', build_path);
}
return path.join(build_path, filename);
shell.mkdir('-p', buildDir);
return path.join(buildDir, filename);
});
}
)
Expand All @@ -206,6 +214,32 @@ RemoteTask.remote = function(task) {
util.fail
);

var specifyBuildDirectory = function(sessionUrl) {
let deferred = Q.defer();

// get the build directory from user
let default_path = path.join( process.env[(process.platform == 'win32') ? 'USERPROFILE' : 'HOME'], 'Desktop');
util.print(''); //insert an empty line
inquirer.prompt({
type: 'input',
name: 'build_path',
message: 'Please enter the directory to save the file or press Enter to accept the default:',
default: default_path
})
.then(
function(response) {
if (response && response.build_path) {
return deferred.resolve({
sessionUrl: sessionUrl,
buildDir: response.build_path
});
}
}
);

return deferred.promise;
};

var requestBuildSelection = function(validBuilds) {
var deferred = Q.defer();

Expand Down
2 changes: 1 addition & 1 deletion src/sync.js
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,7 @@ SyncTask.clone = function(saveCloudProjectID) {
.then(
function() {
util.print((saveCloudProjectID ? 'Cloning' : 'Importing') + ' \'' + project.name + '\' to ' + project.absolutePath);
return monaca.cloneProject(project.projectId, project.destPath)
return monaca.cloneProject(project.projectId, project.destPath, saveCloudProjectID)
.progress(util.displayProgress);
}
)
Expand Down

0 comments on commit 5d24f80

Please sign in to comment.